-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathTimesStopsOutput.tsx
68 lines (63 loc) · 2.03 KB
/
TimesStopsOutput.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import cx from 'classnames';
import type {
PathPropertiesFormatted,
SimulationResponseSuccess,
} from 'applications/operationalStudies/types';
import type { PathfindingResultSuccess, TrainScheduleResult } from 'common/api/osrdEditoastApi';
import { Loader } from 'common/Loaders/Loader';
import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainSchedule/types';
import { NO_BREAK_SPACE } from 'utils/strings';
import useOutputTableData from './hooks/useOutputTableData';
import TimesStops from './TimesStops';
import { TableType, type TimeStopsRow } from './types';
type TimesStopsOutputProps = {
simulatedTrain: SimulationResponseSuccess;
pathProperties: PathPropertiesFormatted;
operationalPoints: OperationalPointWithTimeAndSpeed[];
selectedTrainSchedule: TrainScheduleResult;
path?: PathfindingResultSuccess;
dataIsLoading: boolean;
};
const TimesStopsOutput = ({
simulatedTrain,
pathProperties,
operationalPoints,
selectedTrainSchedule,
path,
dataIsLoading,
}: TimesStopsOutputProps) => {
const enrichedOperationalPoints = useOutputTableData(
simulatedTrain,
pathProperties,
operationalPoints,
selectedTrainSchedule,
path
);
if (dataIsLoading) {
return (
<div style={{ height: '600px' }}>
<Loader />
</div>
);
}
return (
<TimesStops
rows={enrichedOperationalPoints}
tableType={TableType.Output}
cellClassName={({ rowData: rowData_, columnId }) => {
const rowData = rowData_ as TimeStopsRow;
const arrivalScheduleNotRespected = rowData.arrival?.time
? rowData.calculatedArrival !== rowData.arrival.time
: false;
const negativeDiffMargins = Number(rowData.diffMargins?.split(NO_BREAK_SPACE)[0]) < 0;
return cx({
'warning-schedule': arrivalScheduleNotRespected,
'warning-margin': negativeDiffMargins,
'secondary-code-column': columnId === 'ch',
});
}}
headerRowHeight={40}
/>
);
};
export default TimesStopsOutput;