From f94ec000282474db8040c7715f5e75af01a5f794 Mon Sep 17 00:00:00 2001 From: Mathieu Richard Date: Thu, 30 Nov 2023 13:11:08 +0100 Subject: [PATCH] front: fix pathfinding success message persistence --- .../views/ManageTrainSchedule.tsx | 2 +- front/src/common/Pathfinding/Pathfinding.tsx | 29 ++++++++++--------- .../Itinerary/Itinerary.tsx | 9 ++++-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx b/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx index b998195b034..c04e9f8af0e 100644 --- a/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx +++ b/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx @@ -103,7 +103,7 @@ export default function ManageTrainSchedule() { content: (
- +
diff --git a/front/src/common/Pathfinding/Pathfinding.tsx b/front/src/common/Pathfinding/Pathfinding.tsx index 55e8c46ee54..db8b62c61c4 100644 --- a/front/src/common/Pathfinding/Pathfinding.tsx +++ b/front/src/common/Pathfinding/Pathfinding.tsx @@ -172,6 +172,7 @@ function init({ interface PathfindingProps { zoomToFeature: (lngLat: Position, id?: undefined, source?: undefined) => void; + path?: Path; } export function getPathfindingQuery({ @@ -257,7 +258,7 @@ export function getPathfindingQuery({ return null; } -function Pathfinding({ zoomToFeature }: PathfindingProps) { +function Pathfinding({ zoomToFeature, path }: PathfindingProps) { const { t } = useTranslation(['operationalStudies/manageTrainSchedule']); const [pathfindingRequest, setPathfindingRequest] = useState>(); @@ -293,7 +294,6 @@ function Pathfinding({ zoomToFeature }: PathfindingProps) { } ); const [reloadInfra] = osrdEditoastApi.usePostInfraByIdLoadMutation(); - useEffect(() => { if (reloadCount <= 5 && infra && infra.state === 'TRANSIENT_ERROR') { setTimeout(() => { @@ -518,23 +518,24 @@ function Pathfinding({ zoomToFeature }: PathfindingProps) { ? displayInfraSoftError() : infra.state === 'ERROR' && displayInfraHardError())} - {isPathFindingActive ? ( + {!pathfindingState.error && !pathfindingState.running && path && origin && destination && ( +
+ + + + {t('pathfindingDone')} + + {geojson?.length && formatKmValue(geojson?.length / 1000, 3)} + +
+ )} + + {!path && isPathFindingActive ? (
{t('pathfindingNoState')}
) : ( <> - {pathfindingState.done && !pathfindingState.error && ( -
- - - - {t('pathfindingDone')} - - {geojson?.length && formatKmValue(geojson?.length / 1000, 3)} - -
- )} {pathfindingState.error && (
- +