Skip to content

Commit

Permalink
front: fix translations for pathfinding error in itinerary
Browse files Browse the repository at this point in the history
Signed-off-by: romainvalls <[email protected]>
  • Loading branch information
RomainValls committed Nov 18, 2024
1 parent 36eb346 commit eb40dab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"cancelPathfinding": "Cancel",
"chooseOnMap": "Choose on the map",
"composition": "Composition",
"coreErrors": {
"path_with_repeated_tracks": "The path goes over the same track multiple times"
},
"deleteVias": "Delete steps",
"deleteRoute": "Delete the route",
"destination": "Destination",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"cancelPathfinding": "Annuler",
"chooseOnMap": "Choisir sur la carte",
"composition": "Composition",
"coreErrors": {
"path_with_repeated_tracks": "Le chemin emprunte plusieurs fois la même voie"
},
"deleteRoute": "Supprimer l'itinéraire",
"deleteVias": "Supprimer les étapes",
"destination": "Destination",
Expand Down
11 changes: 8 additions & 3 deletions front/src/modules/pathfinding/hooks/usePathfinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,24 @@ export const usePathfinding = (
} else {
pathfindingDispatch({
type: 'PATHFINDING_INCOMPATIBLE_CONSTRAINTS',
message: `pathfindingErrors.${pathfindingResult.error_type}`,
message: t(`pathfindingErrors.${pathfindingResult.error_type}`),
});
}
}
} else if (pathfindingResult.failed_status === 'internal_error') {
const translationKey = pathfindingResult.core_error.type.startsWith('core:')
? pathfindingResult.core_error.type.replace('core:', '')
: pathfindingResult.core_error.type;
pathfindingDispatch({
type: 'PATHFINDING_ERROR',
message: `pathfindingErrors.${pathfindingResult.core_error.message}`,
message: t(`coreErrors.${translationKey}`, {
defaultValue: pathfindingResult.core_error.message,
}),
});
} else {
pathfindingDispatch({
type: 'PATHFINDING_ERROR',
message: `pathfindingErrors.${pathfindingResult.error_type}`,
message: t(`pathfindingErrors.${pathfindingResult.error_type}`),
});
}
} catch (e) {
Expand Down

0 comments on commit eb40dab

Please sign in to comment.