Skip to content

Commit

Permalink
front: fix deleted trainrun
Browse files Browse the repository at this point in the history
  - when deleting trainrun skips getTrainrunSectionsByTrainrunId function
  • Loading branch information
Uriel-Sautron committed Sep 2, 2024
1 parent 2e42e63 commit 7bbb177
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,20 @@ const handleTrainrunOperation = async ({
addDeletedTrainIds: (trainIds: number[]) => void;
}) => {
const { nodes } = netzgrafikDto;
const trainrunSectionsByTrainrunId = getTrainrunSectionsByTrainrunId(netzgrafikDto, trainrun.id);

switch (type) {
case 'create': {
const trainrunSectionsByTrainrunId = getTrainrunSectionsByTrainrunId(
netzgrafikDto,
trainrun.id
);
const newTrainSchedules = await dispatch(
osrdEditoastApi.endpoints.postV2TimetableByIdTrainSchedule.initiate({
id: timeTableId,
body: [
{
...DEFAULT_PAYLOAD,
...createTrainSchedulePayload(trainrunSectionsByTrainrunId, nodes, trainrun),
...createTrainSchedulePayload(trainrunSectionsByTrainrunId!, nodes, trainrun),
},
],
})
Expand All @@ -177,6 +181,10 @@ const handleTrainrunOperation = async ({
break;
}
case 'update': {
const trainrunSectionsByTrainrunId = getTrainrunSectionsByTrainrunId(
netzgrafikDto,
trainrun.id
);
const trainrunIdToUpdate = createdTrainrun.get(trainrun.id) || trainrun.id;
const trainSchedule = await dispatch(
osrdEditoastApi.endpoints.getV2TrainScheduleById.initiate({
Expand All @@ -188,7 +196,7 @@ const handleTrainrunOperation = async ({
id: trainrunIdToUpdate,
trainScheduleForm: {
...trainSchedule,
...createTrainSchedulePayload(trainrunSectionsByTrainrunId, nodes, trainrun),
...createTrainSchedulePayload(trainrunSectionsByTrainrunId!, nodes, trainrun),
// TODO: convert NGE times to OSRD schedule
schedule: [],
},
Expand Down

0 comments on commit 7bbb177

Please sign in to comment.