-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathPacedTrainSettings.tsx
71 lines (67 loc) · 2.17 KB
/
PacedTrainSettings.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
69
70
71
import { ArrowBoth } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
import { updateTimeRangeDuration, updateCadence } from 'reducers/osrdconf/operationalStudiesConf';
import {
getTimeRangeDuration,
getCadence,
} from 'reducers/osrdconf/operationalStudiesConf/selectors';
import { useAppDispatch } from 'store';
const PacedTrainSettings = () => {
const timeRangeDuration = useSelector(getTimeRangeDuration);
const cadence = useSelector(getCadence);
const { t } = useTranslation(['operationalStudies/manageTrainSchedule']);
const dispatch = useAppDispatch();
return (
<div className="d-flex px-3 mt-2">
<span className="mr-3">
<InputSNCF
type="number"
label={
<>
<ArrowBoth className="input-icon" />
<small className="text-nowrap">{t('pacedTrains.timeRangeDuration')}</small>
</>
}
id="paced-train-time-range-duration"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(updateTimeRangeDuration(+e.target.value));
}}
value={timeRangeDuration}
noMargin
isInvalid={timeRangeDuration < 1}
errorMsg={timeRangeDuration < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
unit="min"
textRight
sm
/>
</span>
<span>
<InputSNCF
type="number"
label={
<>
<ArrowBoth className="input-icon" />
<small className="text-nowrap">{t('pacedTrains.cadence')}</small>
</>
}
id="paced-train-cadence"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(updateCadence(+e.target.value));
}}
value={cadence}
noMargin
isInvalid={cadence < 1}
errorMsg={cadence < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
unit="min"
textRight
sm
/>
</span>
</div>
);
};
export default PacedTrainSettings;