Skip to content

Commit

Permalink
front: fix typing
Browse files Browse the repository at this point in the history
Signed-off-by: Achraf Mohyeddine <[email protected]>
  • Loading branch information
achrafmohye committed Dec 10, 2024
1 parent 95d9784 commit 1bb87f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
16 changes: 11 additions & 5 deletions front/src/applications/stdcm/hooks/useStdcmResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,25 @@ 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,
metadata,
};
});

// Add unique IDs to operationalPointsWithMetadata
const operationalPointsWithUniqueIds = operationalPointsWithMetadata.map((op, index) => ({
...op,
id: `${op.id}-${op.position}-${index}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function getOperationalPointsWithTimes(
duration: durationInSeconds,
departureTime,
stopEndTime,
trackName: op.metadata?.track_name,
trackName: op.metadata?.trackName,
};
});

Expand Down
6 changes: 5 additions & 1 deletion front/src/modules/pathfinding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { getPointCoordinates } from 'utils/geometry';
import getStepLocation from './helpers/getStepLocation';

export const formatSuggestedOperationalPoints = (
operationalPoints: NonNullable<Required<PathProperties['operational_points']>>,
operationalPoints: Array<
NonNullable<Required<PathProperties['operational_points']>>[number] & {
metadata?: NonNullable<SuggestedOP['metadata']>;
}
>,
geometry: GeoJsonLineString,
pathLength: number
): SuggestedOP[] =>
Expand Down

0 comments on commit 1bb87f2

Please sign in to comment.