From 39b3a08005117f87a454e60ae435b1f787f42f05 Mon Sep 17 00:00:00 2001 From: Clara Ni Date: Tue, 24 Dec 2024 16:20:55 +0100 Subject: [PATCH] front: drop ViaStopDurationSelector Not used anymore since the end of TS V2 migration and the new STDCM view page Signed-off-by: Clara Ni --- .../ViaStopDurationSelector.tsx | 75 ------------------- .../Itinerary/DisplayItinerary/Vias.tsx | 15 +--- .../components/Itinerary/Itinerary.tsx | 11 +-- .../osrdConfCommon/__tests__/utils.ts | 20 ----- .../reducers/osrdconf/osrdConfCommon/index.ts | 23 +----- 5 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx diff --git a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx deleted file mode 100644 index 17917ac1703..00000000000 --- a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { useEffect, useState } from 'react'; - -import InputSNCF from 'common/BootstrapSNCF/InputSNCF'; -import { useOsrdConfActions } from 'common/osrdContext'; -import type { PathStep } from 'reducers/osrdconf/types'; -import { useAppDispatch } from 'store'; -import { useDebounce } from 'utils/helpers'; -import { ISO8601Duration2sec, formatDurationAsISO8601 } from 'utils/timeManipulation'; - -const ViaStopDurationSelector = ({ - via, - focusedViaId, - setFocusedViaId, -}: { - via: PathStep; - focusedViaId?: string; - setFocusedViaId: (focusedViaIndex?: string) => void; -}) => { - const dispatch = useAppDispatch(); - const { updateViaStopTime } = useOsrdConfActions(); - - const currentStopTime = via.stopFor ? ISO8601Duration2sec(via.stopFor) : 0; - - const [stopTime, setStopTime] = useState(currentStopTime); - const debouncedStopTime = useDebounce(stopTime, 2000); - - const updateViaStopDuration = (durationInSec: number) => { - dispatch(updateViaStopTime({ via, duration: formatDurationAsISO8601(durationInSec) })); - }; - - useEffect(() => { - if (debouncedStopTime !== currentStopTime) { - updateViaStopDuration(debouncedStopTime); - setFocusedViaId(undefined); - } - }, [debouncedStopTime]); - - return ( - <> - {via.id !== focusedViaId && ( -
- - - -
- )} -
setFocusedViaId(via.id)}> - {via.id === focusedViaId ? ( - setStopTime(Number(e.target.value))} - value={stopTime} - unit="s" - focus - selectAllOnFocus - sm - noMargin - textRight - /> - ) : ( -
{`${currentStopTime}s`}
- )} -
- - ); -}; - -export default ViaStopDurationSelector; diff --git a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx index 8f4864849ca..1eeea37e191 100644 --- a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx +++ b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx @@ -1,5 +1,3 @@ -import { useState } from 'react'; - import { XCircle } from '@osrd-project/ui-icons'; import cx from 'classnames'; import type { Position } from 'geojson'; @@ -13,20 +11,16 @@ import { isPathStepInvalid } from 'modules/pathfinding/utils'; import { moveElement, removeElementAtIndex } from 'utils/array'; import { formatUicToCi } from 'utils/strings'; -import ViaStopDurationSelector from './ViaStopDurationSelector'; - type ViasProps = { - shouldManageStopDuration?: boolean; zoomToFeaturePoint: (lngLat?: Position, id?: string) => void; }; -const Vias = ({ zoomToFeaturePoint, shouldManageStopDuration }: ViasProps) => { +const Vias = ({ zoomToFeaturePoint }: ViasProps) => { const { t } = useTranslation('operationalStudies/manageTrainSchedule'); const { getVias, getPathSteps } = useOsrdConfSelectors(); const vias = useSelector(getVias()); const pathSteps = useSelector(getPathSteps); const { launchPathfinding } = useManageTrainScheduleContext(); - const [focusedViaId, setFocusedViaId] = useState(); return ( { )} - {shouldManageStopDuration && ( - - )}