Skip to content

Commit

Permalink
fixup! front: fetch pathSteps coordinates if pathfinding failed when …
Browse files Browse the repository at this point in the history
…editing a train
  • Loading branch information
clarani committed Dec 6, 2024
1 parent 1c93b1c commit bb1612a
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ const useSetupItineraryForTrainUpdate = (
const tracks = await getTrackSectionsByIds(trackSectionIds);

// get operational points
let ops: SearchResultItemOperationalPoint[] = [];
const searchPayload = buildOpSearchQuery(infraId, [trainSchedule]);

if (searchPayload) {
ops = (await postSearch({
searchPayload,
pageSize: 1000,
}).unwrap()) as SearchResultItemOperationalPoint[];
}
const ops = searchPayload
? ((await postSearch({
searchPayload,
pageSize: 1000,
}).unwrap()) as SearchResultItemOperationalPoint[])
: [];

// match path steps with track sections or operational points
const pathStepsWithCoordinates = trainSchedule.path.map((step, index) => {
Expand All @@ -116,15 +114,13 @@ const useSetupItineraryForTrainUpdate = (
let op: SearchResultItemOperationalPoint | undefined;
if ('uic' in step) {
op = ops.find((o) => o.uic === step.uic);
name = `${op?.name} - ${step.uic}`;
} else if ('trigram' in step) {
op = ops.find((o) => o.trigram === step.trigram);
name = `${op?.name} - ${step.trigram}`;
} else {
op = ops.find((o) => o.obj_id === step.operational_point);
name = `${op?.name} - ${step.operational_point}`;
}
coordinates = op?.geographic.coordinates;
name = `${op?.name}`;
}

return {
Expand All @@ -134,7 +130,6 @@ const useSetupItineraryForTrainUpdate = (
};
});

// update le store
dispatch(updatePathSteps(pathStepsWithCoordinates));
};

Expand Down

0 comments on commit bb1612a

Please sign in to comment.