diff --git a/front/public/locales/en/stdcm.json b/front/public/locales/en/stdcm.json
index cd1e8f267af..4cf9b3a82dc 100644
--- a/front/public/locales/en/stdcm.json
+++ b/front/public/locales/en/stdcm.json
@@ -77,8 +77,15 @@
"origin": "Origin",
"preciseTime": "precise time",
"stopFor": "Minimum stop time",
+ "stopType": {
+ "driverSwitch": "driver switch",
+ "passageTime":"passage time",
+ "serviceStop": "service stop"
+ },
"time": "Time",
"tolerance": "Tolerance",
- "vias": "Intermediate OP"
+ "type": "Type",
+ "vias": "Intermediate OP",
+ "warningMinStopTime": "The driver switch stop time must be at least 3 minutes."
}
}
diff --git a/front/public/locales/fr/stdcm.json b/front/public/locales/fr/stdcm.json
index 5e4363ff9bd..5c6f0ebc19c 100644
--- a/front/public/locales/fr/stdcm.json
+++ b/front/public/locales/fr/stdcm.json
@@ -77,8 +77,15 @@
"origin": "Origine",
"preciseTime": "horaire précis",
"stopFor": "Temps d'arrêt minimum",
+ "stopType": {
+ "driverSwitch": "relève conducteur",
+ "passageTime":"passage",
+ "serviceStop": "arrêt de service"
+ },
"time": "Heure",
"tolerance": "Tolérance",
- "vias": "PR intermédiaire"
+ "type": "Type",
+ "vias": "PR intermédiaire",
+ "warningMinStopTime": "Le temps d'arrêt d'une relève conducteur est d'au moins 3 minutes."
}
}
diff --git a/front/src/applications/stdcmV2/components/StdcmInputVia.tsx b/front/src/applications/stdcmV2/components/StdcmInputVia.tsx
index 009567604d2..5a74e967dab 100644
--- a/front/src/applications/stdcmV2/components/StdcmInputVia.tsx
+++ b/front/src/applications/stdcmV2/components/StdcmInputVia.tsx
@@ -1,4 +1,4 @@
-import { useState, useMemo } from 'react';
+import { useState, useMemo, useEffect } from 'react';
import { Input } from '@osrd-project/ui-core';
import { debounce } from 'lodash';
@@ -7,10 +7,14 @@ import { useTranslation } from 'react-i18next';
import type { PathStep } from 'reducers/osrdconf/types';
import { ISO8601Duration2sec } from 'utils/timeManipulation';
+import { StdcmStopTypes } from '../types';
+
const StdcmInputVia = ({
+ stopType,
pathStep,
updatePathStepStopTime,
}: {
+ stopType: StdcmStopTypes;
pathStep: PathStep;
updatePathStepStopTime: (stopTime: string) => void;
}) => {
@@ -20,27 +24,61 @@ const StdcmInputVia = ({
pathStep.stopFor ? `${ISO8601Duration2sec(pathStep.stopFor) / 60}` : ''
);
+ const [showWarning, setShowWarning] = useState(false);
+
const debounceUpdatePathStepStopTime = useMemo(
() => debounce((value) => updatePathStepStopTime(value), 500),
[]
);
+ useEffect(() => {
+ let newStopTime = pathStepStopTime;
+ let warning = false;
+
+ const isDriverSwitch = stopType === StdcmStopTypes.DRIVER_SWITCH;
+ const isPassageTime = stopType === StdcmStopTypes.PASSAGE_TIME;
+ const isServiceStop = stopType === StdcmStopTypes.SERVICE_STOP;
+
+ if (isPassageTime && pathStepStopTime !== '0') {
+ newStopTime = '0';
+ } else if (isDriverSwitch) {
+ const stopTimeValue = Number(pathStepStopTime);
+ if (stopTimeValue === 0) {
+ newStopTime = '3';
+ } else if (stopTimeValue < 3) {
+ warning = true;
+ }
+ } else if (isServiceStop && pathStepStopTime !== '0') {
+ newStopTime = '';
+ }
+
+ if (newStopTime !== pathStepStopTime) {
+ setPathStepStopTime(newStopTime);
+ updatePathStepStopTime(newStopTime);
+ }
+
+ setShowWarning(warning);
+ }, [stopType, pathStepStopTime]);
+
return (
-
- {
- // TODO: Find a better way to prevent user from entering decimal values
- const value = e.target.value.replace(/[\D.,]/g, '');
- setPathStepStopTime(value);
- debounceUpdatePathStepStopTime(value);
- }}
- value={pathStepStopTime}
- trailingContent="minutes"
- />
-
+ stopType !== StdcmStopTypes.PASSAGE_TIME && (
+
+
{
+ // TODO: Find a better way to prevent user from entering decimal values
+ const value = e.target.value.replace(/[\D.,]/g, '');
+ setPathStepStopTime(value);
+ debounceUpdatePathStepStopTime(value);
+ }}
+ value={pathStepStopTime}
+ trailingContent="minutes"
+ />
+ {showWarning &&
{t('trainPath.warningMinStopTime')}
}
+
+ )
);
};
diff --git a/front/src/applications/stdcmV2/components/StdcmStopType.tsx b/front/src/applications/stdcmV2/components/StdcmStopType.tsx
new file mode 100644
index 00000000000..edbe6a1f910
--- /dev/null
+++ b/front/src/applications/stdcmV2/components/StdcmStopType.tsx
@@ -0,0 +1,33 @@
+import { Select } from '@osrd-project/ui-core';
+import { useTranslation } from 'react-i18next';
+
+import type { StdcmStopTypes } from '../types';
+
+type StdcmStopTypeProps = {
+ stopTypes: StdcmStopTypes;
+ onStdcmStopTypesChange: (arrivalType: StdcmStopTypes) => void;
+};
+
+const StdcmStopType = ({ stopTypes, onStdcmStopTypesChange }: StdcmStopTypeProps) => {
+ const { t } = useTranslation('stdcm');
+
+ return (
+
+
+ );
+};
+
+export default StdcmStopType;
diff --git a/front/src/applications/stdcmV2/components/StdcmVias.tsx b/front/src/applications/stdcmV2/components/StdcmVias.tsx
index 115fe6255cd..c32c2500229 100644
--- a/front/src/applications/stdcmV2/components/StdcmVias.tsx
+++ b/front/src/applications/stdcmV2/components/StdcmVias.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import { Location } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
@@ -17,6 +17,8 @@ import StdcmCard from './StdcmCard';
import StdcmDefaultCard from './StdcmDefaultCard';
import StdcmInputVia from './StdcmInputVia';
import StdcmOperationalPoint from './StdcmOperationalPoint';
+import StdcmStopType from './StdcmStopType';
+import { StdcmStopTypes } from '../types';
import type { StdcmConfigCardProps } from '../types';
const StdcmVias = ({ disabled = false, setCurrentSimulationInputs }: StdcmConfigCardProps) => {
@@ -27,10 +29,17 @@ const StdcmVias = ({ disabled = false, setCurrentSimulationInputs }: StdcmConfig
useOsrdConfActions() as StdcmConfSliceActions;
const pathSteps = useSelector(getPathSteps);
+ const [stopType, setStopType] = useState(StdcmStopTypes.PASSAGE_TIME);
+
const intermediatePoints = useMemo(() => pathSteps.slice(1, -1), [pathSteps]);
const updatePathStepsList = (pathStep: PathStep | null, index: number) => {
- const newPathSteps = replaceElementAtIndex(pathSteps, index, pathStep);
+ if (!pathStep) return;
+ const updatedPathStep = {
+ ...pathStep,
+ };
+
+ const newPathSteps = replaceElementAtIndex(pathSteps, index, updatedPathStep);
dispatch(updatePathSteps({ pathSteps: newPathSteps }));
};
@@ -61,6 +70,14 @@ const StdcmVias = ({ disabled = false, setCurrentSimulationInputs }: StdcmConfig
}));
}, [pathSteps]);
+ // useEffect(() => {
+ // if (stopType === StdcmStopTypes.DRIVER_SWITCH) {
+ // setStopTypeTime('PT180S');
+ // } else if (stopType === StdcmStopTypes.SERVICE_STOP) {
+ // setStopTypeTime('PT60S');
+ // }
+ // }, [stopType]);
+
return (
{intermediatePoints.length > 0 &&
@@ -100,10 +117,14 @@ const StdcmVias = ({ disabled = false, setCurrentSimulationInputs }: StdcmConfig
/>
{pathStep && (
- updatePathStepStopTime(e, pathStepIndex)}
- />
+ <>
+
+ updatePathStepStopTime(e, pathStepIndex)}
+ />
+ >
)}
>
diff --git a/front/src/applications/stdcmV2/types.ts b/front/src/applications/stdcmV2/types.ts
index ca737de59d6..76eefeee4d3 100644
--- a/front/src/applications/stdcmV2/types.ts
+++ b/front/src/applications/stdcmV2/types.ts
@@ -46,3 +46,9 @@ export type StdcmConfigErrors = {
errorType: StdcmConfigErrorTypes;
errorDetails?: { originTime: string; destinationTime: string };
};
+
+export enum StdcmStopTypes {
+ PASSAGE_TIME = 'passageTime',
+ DRIVER_SWITCH = 'driverSwitch',
+ SERVICE_STOP = 'serviceStop',
+}
diff --git a/front/src/reducers/osrdconf/types.ts b/front/src/reducers/osrdconf/types.ts
index d0676b10dc7..3a1f1211ab3 100644
--- a/front/src/reducers/osrdconf/types.ts
+++ b/front/src/reducers/osrdconf/types.ts
@@ -2,7 +2,7 @@ import type { Feature, Position } from 'geojson';
import type { PowerRestriction } from 'applications/operationalStudies/types';
import type { AllowanceValue } from 'applications/stdcm/types';
-import type { ArrivalTimeTypes } from 'applications/stdcmV2/types';
+import type { ArrivalTimeTypes, StdcmStopTypes } from 'applications/stdcmV2/types';
import type { Comfort, Distribution, PathItemLocation } from 'common/api/osrdEditoastApi';
import type { InfraState } from 'reducers/infra';
@@ -61,6 +61,7 @@ export type PathStep = PathItemLocation & {
arrivalToleranceAfter?: number;
locked?: boolean;
stopFor?: string | null;
+ stopType?: StdcmStopTypes;
theoreticalMargin?: string;
onStopSignal?: boolean;
kp?: string;