Skip to content

Commit

Permalink
front: fix workSchedules projection
Browse files Browse the repository at this point in the history
  • Loading branch information
clarani committed Nov 8, 2024
1 parent 28880ae commit 21290bd
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useMemo, useState } from 'react';

import { useSelector } from 'react-redux';

Expand Down Expand Up @@ -33,14 +33,29 @@ const StdcmDebugResults = ({

const spaceTimeData = useProjectedTrainsForStdcm(results);

const { data: workSchedules } = osrdEditoastApi.endpoints.postWorkSchedulesProjectPath.useQuery(
{
body: {
path_track_ranges: pathTrackRanges,
work_schedule_group_id: workScheduleGroupId!,
const { data: rawWorkSchedules } =
osrdEditoastApi.endpoints.postWorkSchedulesProjectPath.useQuery(
{
body: {
path_track_ranges: pathTrackRanges,
work_schedule_group_id: workScheduleGroupId!,
},
},
},
{ skip: !workScheduleGroupId }
{ skip: !workScheduleGroupId }
);

// The workSchedules are returned without timezone (bug in editoast)
// To fix it temporarily, we manually add the timezone to start_date_time and end_date_time
const workSchedules = useMemo(
() =>
rawWorkSchedules?.map((ws) => {
return {
...ws,
start_date_time: `${ws.start_date_time}Z`,
end_date_time: `${ws.end_date_time}Z`,
};
}),
[rawWorkSchedules]
);

return (
Expand Down

0 comments on commit 21290bd

Please sign in to comment.