-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fixes] Amélioration de l'affichage des sémaphores, du menu latéral e…
…t du statut de mission en cas de réouverture (#619) - Resolve #465 - Resolve #528 - Resolve #587 (Traitement des retours en bas de ticket suite à la review en intégration)
- Loading branch information
Showing
14 changed files
with
129 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useEffect } from 'react' | ||
import { toast as toastifyToast } from 'react-toastify' | ||
|
||
import { ErrorType } from '../domain/entities/errors' | ||
import { useAppSelector } from '../hooks/useAppSelector' | ||
|
||
import type { ToastOptions } from 'react-toastify' | ||
|
||
const DEFAULT_TOAST_TYPE = 'error' | ||
|
||
const DEFAULT_TOAST_OPTIONS: ToastOptions = { | ||
autoClose: 3000, | ||
containerId: 'default', | ||
position: 'bottom-right' | ||
} | ||
|
||
// todo use monitor-ui component | ||
export function ToastNotification() { | ||
const { toast } = useAppSelector(state => state.global) | ||
|
||
useEffect(() => { | ||
if (toast) { | ||
const TOAST_OPTIONS = toast.containerId | ||
? { ...DEFAULT_TOAST_OPTIONS, containerId: toast.containerId } | ||
: DEFAULT_TOAST_OPTIONS | ||
|
||
if (toast.type && toast.type === ErrorType.INFO_AND_HIDDEN) { | ||
return | ||
} | ||
const toastMessage = toast.message | ||
|
||
if (toastMessage instanceof Error) { | ||
toastifyToast.error(toastMessage.message, TOAST_OPTIONS) | ||
|
||
return | ||
} | ||
|
||
const type = toast.type || DEFAULT_TOAST_TYPE | ||
|
||
switch (type) { | ||
case ErrorType.INFO: | ||
toastifyToast.info(toastMessage, TOAST_OPTIONS) | ||
break | ||
case ErrorType.SUCCESS: | ||
toastifyToast.success(toastMessage, TOAST_OPTIONS) | ||
break | ||
case ErrorType.WARNING: | ||
toastifyToast.warn(toastMessage, TOAST_OPTIONS) | ||
break | ||
case ErrorType.ERROR: | ||
default: | ||
toastifyToast.error(toastMessage, TOAST_OPTIONS) | ||
break | ||
} | ||
} | ||
}, [toast]) | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export enum ErrorType { | ||
ERROR = 'error', | ||
INFO = 'info', | ||
INFO_AND_HIDDEN = 'hidden', | ||
SUCCESS = 'success', | ||
WARNING = 'warning' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import { missionsAPI } from '../../../api/missionsAPI' | ||
import { sideWindowActions } from '../../../features/SideWindow/slice' | ||
import { sideWindowPaths } from '../../entities/sideWindow' | ||
import { setError } from '../../shared_slices/Global' | ||
import { setToast } from '../../shared_slices/Global' | ||
|
||
export const deleteMissionAndGoToMissionsList = id => (dispatch, getState) => { | ||
const { sideWindow } = getState() | ||
dispatch(missionsAPI.endpoints.deleteMission.initiate({ id })).then(response => { | ||
if ('error' in response) { | ||
dispatch(setError(response.error)) | ||
} else { | ||
dispatch(sideWindowActions.focusAndGoTo(sideWindow.nextPath || sideWindowPaths.MISSIONS)) | ||
} | ||
}) | ||
dispatch(missionsAPI.endpoints.deleteMission.initiate({ id })) | ||
.then(response => { | ||
if ('error' in response) { | ||
throw Error('Erreur à la suppression de la mission') | ||
} else { | ||
dispatch(sideWindowActions.focusAndGoTo(sideWindow.nextPath || sideWindowPaths.MISSIONS)) | ||
} | ||
}) | ||
.catch(error => { | ||
dispatch(setToast({ containerId: 'sideWindow', message: error })) | ||
}) | ||
} |
5 changes: 3 additions & 2 deletions
5
frontend/src/domain/use_cases/regulatory/loadRegulatoryData.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { getAllRegulatoryLayersFromAPI } from '../../../api/regulatoryLayersAPI' | ||
import { setError } from '../../shared_slices/Global' | ||
import { setToast } from '../../shared_slices/Global' | ||
import { setRegulatoryLayers } from '../../shared_slices/Regulatory' | ||
|
||
export const loadRegulatoryData = () => async dispatch => | ||
getAllRegulatoryLayersFromAPI() | ||
.then(features => dispatch(setRegulatoryLayers(features))) | ||
.catch(error => { | ||
// eslint-disable-next-line no-console | ||
console.error(error) | ||
dispatch(setError(error)) | ||
dispatch(setToast({ message: error })) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.