diff --git a/front/src/applications/stdcm/components/StdcmResults/StdcmDebugResults.tsx b/front/src/applications/stdcm/components/StdcmResults/StdcmDebugResults.tsx
index bff44b102ee..8fef170c4e2 100644
--- a/front/src/applications/stdcm/components/StdcmResults/StdcmDebugResults.tsx
+++ b/front/src/applications/stdcm/components/StdcmResults/StdcmDebugResults.tsx
@@ -4,8 +4,9 @@ import { useSelector } from 'react-redux';
import { STDCM_TRAIN_ID } from 'applications/stdcm/consts';
import useProjectedTrainsForStdcm from 'applications/stdcm/hooks/useProjectedTrainsForStdcm';
-import type { StdcmResultsOutput } from 'applications/stdcm/types';
-import { osrdEditoastApi, type TrackRange } from 'common/api/osrdEditoastApi';
+import type { StdcmSimulationOutputs } from 'applications/stdcm/types';
+import { hasResults } from 'applications/stdcm/utils/simulationOutputUtils';
+import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors } from 'common/osrdContext';
import ResizableSection from 'common/ResizableSection';
import i18n from 'i18n';
@@ -20,16 +21,13 @@ const HANDLE_TAB_RESIZE_HEIGHT = 20;
const MANCHETTE_HEIGHT_DIFF = 100;
type StdcmDebugResultsProps = {
- pathTrackRanges: TrackRange[];
- simulationOutputs: StdcmResultsOutput;
+ simulationOutputs?: StdcmSimulationOutputs;
};
-const StdcmDebugResults = ({
- pathTrackRanges,
- simulationOutputs: { pathProperties, results, speedSpaceChartData },
-}: StdcmDebugResultsProps) => {
+const StdcmDebugResults = ({ simulationOutputs }: StdcmDebugResultsProps) => {
const { getWorkScheduleGroupId } = useOsrdConfSelectors() as StdcmConfSelectors;
const workScheduleGroupId = useSelector(getWorkScheduleGroupId);
+ const successfulSimulation = hasResults(simulationOutputs) ? simulationOutputs : undefined;
const [speedSpaceChartContainerHeight, setSpeedSpaceChartContainerHeight] =
useState(SPEED_SPACE_CHART_HEIGHT);
@@ -39,18 +37,21 @@ const StdcmDebugResults = ({
MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT
);
- const projectedData = useProjectedTrainsForStdcm(results);
+ const projectedData = useProjectedTrainsForStdcm(successfulSimulation?.results);
const { data: workSchedules } = osrdEditoastApi.endpoints.postWorkSchedulesProjectPath.useQuery(
{
body: {
- path_track_ranges: pathTrackRanges,
+ path_track_ranges: successfulSimulation?.results.path.track_section_ranges || [],
work_schedule_group_id: workScheduleGroupId!,
},
},
- { skip: !workScheduleGroupId }
+ { skip: !workScheduleGroupId || !successfulSimulation }
);
+ if (!successfulSimulation) return null;
+ const { pathProperties, results, speedSpaceChartData } = successfulSimulation;
+
return (
<>
{projectedData &&
diff --git a/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx b/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx
index a297470a435..f6bbc7498a8 100644
--- a/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx
+++ b/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx
@@ -12,7 +12,6 @@ import {
getOperationalPointsWithTimes,
} from 'applications/stdcm/utils/formatSimulationReportSheet';
import { hasConflicts, hasResults } from 'applications/stdcm/utils/simulationOutputUtils';
-import { type TrackRange } from 'common/api/osrdEditoastApi';
import NewMap from 'modules/trainschedule/components/ManageTrainSchedule/NewMap';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';
@@ -33,7 +32,6 @@ type StcdmResultsProps = {
selectedSimulationIndex: number;
showStatusBanner: boolean;
simulationsList: StdcmSimulation[];
- pathTrackRanges?: TrackRange[];
};
const StcdmResults = ({
@@ -48,7 +46,6 @@ const StcdmResults = ({
selectedSimulationIndex,
showStatusBanner,
simulationsList,
- pathTrackRanges,
}: StcdmResultsProps) => {
const { t } = useTranslation('stdcm', { keyPrefix: 'simulation.results' });
const { stdcmName } = useDeploymentSettings();
@@ -188,9 +185,7 @@ const StcdmResults = ({
/>
- {isDebugMode && pathTrackRanges && hasSimulationResults && (
-
- )}
+ {isDebugMode && }
>
);
};
diff --git a/front/src/applications/stdcm/views/StdcmView.tsx b/front/src/applications/stdcm/views/StdcmView.tsx
index 10f0dab53f3..5212df86d59 100644
--- a/front/src/applications/stdcm/views/StdcmView.tsx
+++ b/front/src/applications/stdcm/views/StdcmView.tsx
@@ -241,7 +241,6 @@ const StdcmView = () => {
selectedSimulationIndex={selectedSimulationIndex}
showStatusBanner={showStatusBanner}
simulationsList={simulationsList}
- pathTrackRanges={stdcmResults?.stdcmResponse.path.track_section_ranges}
/>
)}