diff --git a/front/src/applications/stdcm/hooks/useStdcmResults.ts b/front/src/applications/stdcm/hooks/useStdcmResults.ts index 43703a708cc..88da2cc54b5 100644 --- a/front/src/applications/stdcm/hooks/useStdcmResults.ts +++ b/front/src/applications/stdcm/hooks/useStdcmResults.ts @@ -80,11 +80,18 @@ const useStdcmResults = ( dispatch ); const operationalPointsWithMetadata = operational_points.map((op) => { - let metadata; const associatedTrackSection = trackSections[op.part.track]; - if (associatedTrackSection) { - metadata = associatedTrackSection.properties?.extensions?.sncf; - } + const sncf = associatedTrackSection?.properties?.extensions?.sncf; + + const metadata = + sncf && Object.values(sncf).every((value) => value !== undefined) + ? { + lineCode: sncf.line_code!, + lineName: sncf.line_name!, + trackName: sncf.track_name!, + trackNumber: sncf.track_number!, + } + : undefined; return { ...op, @@ -92,7 +99,6 @@ const useStdcmResults = ( }; }); - // Add unique IDs to operationalPointsWithMetadata const operationalPointsWithUniqueIds = operationalPointsWithMetadata.map((op, index) => ({ ...op, id: `${op.id}-${op.position}-${index}`, diff --git a/front/src/applications/stdcm/utils/formatSimulationReportSheet.ts b/front/src/applications/stdcm/utils/formatSimulationReportSheet.ts index fc8e21134bb..033cc95d050 100644 --- a/front/src/applications/stdcm/utils/formatSimulationReportSheet.ts +++ b/front/src/applications/stdcm/utils/formatSimulationReportSheet.ts @@ -144,7 +144,7 @@ export function getOperationalPointsWithTimes( duration: durationInSeconds, departureTime, stopEndTime, - trackName: op.metadata?.track_name, + trackName: op.metadata?.trackName, }; }); diff --git a/front/src/modules/pathfinding/utils.ts b/front/src/modules/pathfinding/utils.ts index c90e731088c..2504f793759 100644 --- a/front/src/modules/pathfinding/utils.ts +++ b/front/src/modules/pathfinding/utils.ts @@ -16,7 +16,11 @@ import { getPointCoordinates } from 'utils/geometry'; import getStepLocation from './helpers/getStepLocation'; export const formatSuggestedOperationalPoints = ( - operationalPoints: NonNullable>, + operationalPoints: Array< + NonNullable>[number] & { + metadata?: NonNullable; + } + >, geometry: GeoJsonLineString, pathLength: number ): SuggestedOP[] =>