Skip to content

Commit cda6a09

Browse files
author
Alice K.
committed
front: handle adding destination via map to single path step train
Signed-off-by: Alice K. <alice.khoudli@gmail.com>
1 parent c38d369 commit cda6a09

File tree

1 file changed

+8
-2
lines changed
  • front/src/modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap

1 file changed

+8
-2
lines changed

front/src/modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap/setPointIti.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ export function setPointIti(
2121
newPathSteps = replaceElementAtIndex(pathSteps, 0, pathStep);
2222
break;
2323
case 'destination':
24-
newPathSteps = replaceElementAtIndex(pathSteps, -1, pathStep);
24+
if (pathSteps.length === 1) {
25+
newPathSteps = addElementAtIndex(pathSteps, pathSteps.length, pathStep);
26+
} else {
27+
newPathSteps = replaceElementAtIndex(pathSteps, pathSteps.length - 1, pathStep);
28+
}
2529
break;
2630
default:
27-
if (pathProperties) {
31+
if (pathSteps.length === 1) {
32+
newPathSteps = addElementAtIndex(pathSteps, pathSteps.length, pathStep);
33+
} else if (pathProperties) {
2834
newPathSteps = insertViaFromMap(pathSteps, pathStep, pathProperties);
2935
} else {
3036
newPathSteps = addElementAtIndex(pathSteps, pathSteps.length - 1, pathStep);

0 commit comments

Comments
 (0)