Skip to content

Commit bb1612a

Browse files
committed
fixup! front: fetch pathSteps coordinates if pathfinding failed when editing a train
1 parent 1c93b1c commit bb1612a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

front/src/applications/operationalStudies/hooks/useSetupItineraryForTrainUpdate.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@ const useSetupItineraryForTrainUpdate = (
9292
const tracks = await getTrackSectionsByIds(trackSectionIds);
9393

9494
// get operational points
95-
let ops: SearchResultItemOperationalPoint[] = [];
9695
const searchPayload = buildOpSearchQuery(infraId, [trainSchedule]);
97-
98-
if (searchPayload) {
99-
ops = (await postSearch({
100-
searchPayload,
101-
pageSize: 1000,
102-
}).unwrap()) as SearchResultItemOperationalPoint[];
103-
}
96+
const ops = searchPayload
97+
? ((await postSearch({
98+
searchPayload,
99+
pageSize: 1000,
100+
}).unwrap()) as SearchResultItemOperationalPoint[])
101+
: [];
104102

105103
// match path steps with track sections or operational points
106104
const pathStepsWithCoordinates = trainSchedule.path.map((step, index) => {
@@ -116,15 +114,13 @@ const useSetupItineraryForTrainUpdate = (
116114
let op: SearchResultItemOperationalPoint | undefined;
117115
if ('uic' in step) {
118116
op = ops.find((o) => o.uic === step.uic);
119-
name = `${op?.name} - ${step.uic}`;
120117
} else if ('trigram' in step) {
121118
op = ops.find((o) => o.trigram === step.trigram);
122-
name = `${op?.name} - ${step.trigram}`;
123119
} else {
124120
op = ops.find((o) => o.obj_id === step.operational_point);
125-
name = `${op?.name} - ${step.operational_point}`;
126121
}
127122
coordinates = op?.geographic.coordinates;
123+
name = `${op?.name}`;
128124
}
129125

130126
return {
@@ -134,7 +130,6 @@ const useSetupItineraryForTrainUpdate = (
134130
};
135131
});
136132

137-
// update le store
138133
dispatch(updatePathSteps(pathStepsWithCoordinates));
139134
};
140135

0 commit comments

Comments
 (0)