1
1
import React , { useContext } from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
2
import nextId from 'react-id-generator' ;
4
3
import { FaLock } from 'react-icons/fa' ;
5
4
import InputSNCF from 'common/BootstrapSNCF/InputSNCF' ;
@@ -8,21 +7,41 @@ import { getInfraID } from 'reducers/osrdconf/selectors';
8
7
import { updateInfraID , deleteItinerary } from 'reducers/osrdconf' ;
9
8
import { useTranslation } from 'react-i18next' ;
10
9
import { ModalContext } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider' ;
10
+ import { Infra } from 'common/api/osrdEditoastApi' ;
11
+
12
+ type InfraSelectorModalBodyStandardProps = {
13
+ filter : string ;
14
+ setFilter : ( filterInput : string ) => void ;
15
+ infrasList : Infra [ ] ;
16
+ onlySelectionMode : boolean ;
17
+ onInfraChange ?: ( infraId : number ) => void ;
18
+ } ;
11
19
12
20
// Test coherence between actual & generated version, eg. if editoast is up to date with data
13
- export function editoastUpToDateIndicator ( v , genv ) {
14
- return < span className = { `ml-1 text-${ v === genv ? 'success' : 'danger' } ` } > ●</ span > ;
21
+ export function editoastUpToDateIndicator (
22
+ infraVersion : string ,
23
+ infraGeneratedVersion : string | null
24
+ ) {
25
+ return (
26
+ < span className = { `ml-1 text-${ infraVersion === infraGeneratedVersion ? 'success' : 'danger' } ` } >
27
+ ●
28
+ </ span >
29
+ ) ;
15
30
}
16
31
17
- export default function InfraSelectorModalBodyStandard ( props ) {
18
- const { infrasList, filter, setFilter, onlySelectionMode, onInfraChange } = props ;
19
-
32
+ export default function InfraSelectorModalBodyStandard ( {
33
+ filter = '' ,
34
+ setFilter,
35
+ infrasList,
36
+ onlySelectionMode = false ,
37
+ onInfraChange,
38
+ } : InfraSelectorModalBodyStandardProps ) {
20
39
const { t } = useTranslation ( [ 'translation' , 'infraManagement' ] ) ;
21
40
const dispatch = useDispatch ( ) ;
22
41
const infraID = useSelector ( getInfraID ) ;
23
42
const { closeModal } = useContext ( ModalContext ) ;
24
43
25
- function setInfraID ( id ) {
44
+ function setInfraID ( id : number ) {
26
45
dispatch ( updateInfraID ( id ) ) ;
27
46
if ( onInfraChange ) onInfraChange ( id ) ;
28
47
dispatch ( deleteItinerary ( ) ) ;
@@ -83,17 +102,3 @@ export default function InfraSelectorModalBodyStandard(props) {
83
102
</ >
84
103
) ;
85
104
}
86
-
87
- InfraSelectorModalBodyStandard . defaultProps = {
88
- filter : '' ,
89
- onlySelectionMode : false ,
90
- onInfraChange : undefined ,
91
- } ;
92
-
93
- InfraSelectorModalBodyStandard . propTypes = {
94
- filter : PropTypes . string ,
95
- infrasList : PropTypes . array . isRequired ,
96
- setFilter : PropTypes . func . isRequired ,
97
- onlySelectionMode : PropTypes . bool ,
98
- onInfraChange : PropTypes . func ,
99
- } ;
0 commit comments