-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Missions] Edition de la mission depuis la fiche navire (#2307)
## Linked issues - Resolve #2276 - Affiche un message d'erreur et le retry au lieu du chargement infini lorsque la requête pour chercher les missions ne trouve pas de mission : ![Screenshot from 2023-07-10 16-18-25](https://github.com/MTES-MCT/monitorfish/assets/14853556/fcc89648-25e4-4fdb-9a32-8034d7246f6f) ---- - [x] Tests E2E (Cypress)
- Loading branch information
Showing
44 changed files
with
352 additions
and
200 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DisplayedError } from '../../../libs/DisplayedError' | ||
import { INITIAL_STATE, setDisplayedErrors } from '../../shared_slices/DisplayedError' | ||
import { setError } from '../../shared_slices/Global' | ||
|
||
import type { RetryableUseCase } from '../../../libs/DisplayedError' | ||
|
||
/** | ||
* Dispatch: | ||
* - A toast error if the use-case was triggered by the cron | ||
* - A displayedError to be shown in the vessel sidebar if the use-case was triggered by the user | ||
*/ | ||
export const displayOrLogError = | ||
( | ||
error: Error, | ||
retryableUseCase: RetryableUseCase | undefined, | ||
isFromUserAction: boolean, | ||
displayedErrorBoundary: string | ||
) => | ||
async dispatch => { | ||
/** | ||
* If the use-case was triggered by the cron, we only log an error with a Toast | ||
*/ | ||
if (!isFromUserAction) { | ||
dispatch(setError(error)) | ||
|
||
return | ||
} | ||
|
||
/** | ||
* Else, the use-case was an user action, we show a fallback error UI to the user. | ||
* We first check if the `displayedErrorBoundary` is correct (included in the DisplayedErrorState type) | ||
*/ | ||
if (!Object.keys(INITIAL_STATE).includes(displayedErrorBoundary)) { | ||
return | ||
} | ||
|
||
const displayedError = new DisplayedError(error.message, retryableUseCase) | ||
dispatch(setDisplayedErrors({ [displayedErrorBoundary]: displayedError })) | ||
} |
28 changes: 0 additions & 28 deletions
28
frontend/src/domain/use_cases/error/displayOrLogVesselSidebarError.ts
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,16 @@ | ||
import type { RetryableUseCase } from '../../../libs/DisplayedError' | ||
|
||
export const retry = (retryableUseCase: RetryableUseCase | undefined) => async dispatch => { | ||
if (!retryableUseCase) { | ||
return | ||
} | ||
|
||
const parameters = retryableUseCase?.parameters | ||
if (!parameters) { | ||
dispatch(retryableUseCase?.func()) | ||
|
||
return | ||
} | ||
|
||
dispatch(retryableUseCase?.func(...parameters)) | ||
} |
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.