Skip to content

Commit

Permalink
front: optimize invalid path step for track section and operational p…
Browse files Browse the repository at this point in the history
…oint

Signed-off-by: Achraf Mohyeddine <[email protected]>
  • Loading branch information
achrafmohye committed Jan 23, 2025
1 parent b7050a2 commit 37a6c2f
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ const useSetupItineraryForTrainUpdate = (trainIdToEdit: number) => {
{ error_type: 'invalid_path_items' }
>['items'] = []
) => {
const invalidIdentifiers = invalidPathItems
.map((item) => {
if ('trigram' in item.path_item) {
return item.path_item.trigram;
}
if ('uic' in item.path_item) {
return item.path_item.uic;
}
return null;
})
.filter((value): value is string | number => value !== null);
// get track sections
const trackSectionIds: string[] = [];
trainSchedule.path.forEach((step) => {
if ('track' in step) {
Expand All @@ -116,7 +104,6 @@ const useSetupItineraryForTrainUpdate = (trainIdToEdit: number) => {
let coordinates: Position | undefined;
let name: string | undefined;
let uic: number | undefined;
let isInvalid: boolean | undefined;

if ('track' in step) {
const track = tracks[step.track];
Expand All @@ -128,11 +115,9 @@ const useSetupItineraryForTrainUpdate = (trainIdToEdit: number) => {
if ('uic' in step) {
op = ops.find((o) => o.uic === step.uic);
uic = step.uic;
isInvalid = invalidIdentifiers.includes(step.uic);
} else if ('trigram' in step) {
op = ops.find((o) => o.trigram === step.trigram);
isInvalid = invalidIdentifiers.includes(step.trigram);
} else {
} else if ('operational_point' in step) {
op = ops.find((o) => o.obj_id === step.operational_point);
}
coordinates = op?.geographic.coordinates;
Expand All @@ -143,7 +128,7 @@ const useSetupItineraryForTrainUpdate = (trainIdToEdit: number) => {
...computeBasePathStep(trainSchedule, index),
coordinates,
name,
isInvalid,
isInvalid: invalidPathItems.some((item) => item.index === index),
};
});

Expand Down

0 comments on commit 37a6c2f

Please sign in to comment.