Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions front/src/modules/timesStops/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
PathItemLocation,
ReceptionSignal,
TrackReference,
TrackSection,
} from 'common/api/osrdEditoastApi';
import type { TimeString } from 'common/types';
import { matchPathStepAndOp } from 'modules/pathfinding/utils';
Expand Down Expand Up @@ -351,9 +352,13 @@ export function receptionSignalToSignalBooleans(receptionSignal?: ReceptionSigna
return { shortSlipDistance: false, onStopSignal: false };
}

export const getTrackReferenceLabel = (trackReference?: TrackReference | null) => {
export const getTrackReferenceLabel = (
trackSections: Record<string, TrackSection>,
trackReference?: TrackReference | null
) => {
if (!trackReference) return undefined;
return 'track_id' in trackReference ? trackReference.track_id : trackReference.track_name;
if ('track_name' in trackReference) return trackReference.track_name;
return trackSections[trackReference.track_id]?.extensions?.sncf?.track_name ?? '?';
};

export const getOperationalPointName = (
Expand Down
9 changes: 7 additions & 2 deletions front/src/modules/timesStops/hooks/useOutputTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const useOutputTableData = (

const trackIds = useMemo(() => {
const path = selectedTrain?.path || [];
const trackIdsInPathSteps = path.flatMap((step) => ('track' in step ? [step.track] : []));
const trackIdsInPathSteps = path.flatMap((step) => [
...('track' in step ? [step.track] : []),
...('track_reference' in step && step.track_reference && 'track_id' in step.track_reference
? [step.track_reference.track_id]
: []),
]);
const trackIdsOnPath = (operationalPointsOnPath || []).map((op) => op.part.track);
return [...trackIdsInPathSteps, ...trackIdsOnPath];
}, [selectedTrain?.path, operationalPointsOnPath]);
Expand Down Expand Up @@ -80,7 +85,7 @@ const useOutputTableData = (
const trackName =
'track' in pathStep
? trackSections[pathStep.track]?.extensions?.sncf?.track_name
: getTrackReferenceLabel(pathStep.track_reference);
: getTrackReferenceLabel(trackSections, pathStep.track_reference);

const schedule = scheduleByAt[pathStep.id];
const computedArrival = simulatedPathItemTimes
Expand Down