@@ -19,15 +19,15 @@ import { useSwitchTypes } from 'applications/editor/tools/switchEdition/types';
19
19
import type { switchProps } from 'applications/editor/tools/switchProps' ;
20
20
import type { CommonToolState } from 'applications/editor/tools/types' ;
21
21
import { centerMapOnObject , selectEntities } from 'applications/editor/tools/utils' ;
22
- import type { ObjectType } from 'common/api/osrdEditoastApi' ;
22
+ import { osrdEditoastApi , type ObjectType } from 'common/api/osrdEditoastApi' ;
23
23
import { useModal } from 'common/BootstrapSNCF/ModalSNCF' ;
24
24
import { LoaderState } from 'common/Loaders' ;
25
25
import MapButtons from 'common/Map/Buttons/MapButtons' ;
26
26
import MapSearch from 'common/Map/Search/MapSearch' ;
27
27
import { useInfraID , useOsrdActions } from 'common/osrdContext' ;
28
28
import Tipped from 'common/Tipped' ;
29
29
import type { EditorSliceActions } from 'reducers/editor' ;
30
- import { getEditorState , getInfraLockStatus } from 'reducers/editor/selectors' ;
30
+ import { getEditorState } from 'reducers/editor/selectors' ;
31
31
import { loadDataModel , updateTotalsIssue } from 'reducers/editor/thunkActions' ;
32
32
import { setFailure } from 'reducers/main' ;
33
33
import { getIsLoading } from 'reducers/main/mainSelector' ;
@@ -49,7 +49,6 @@ const Editor = () => {
49
49
const { urlInfra } = useParams ( ) ;
50
50
const infraID = useInfraID ( ) ;
51
51
const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
52
- const isLocked = useSelector ( getInfraLockStatus ) ;
53
52
const isLoading = useSelector ( getIsLoading ) ;
54
53
const editorState = useSelector ( getEditorState ) ;
55
54
const switchTypes = useSwitchTypes ( infraID ) ;
@@ -65,6 +64,17 @@ const Editor = () => {
65
64
} , [ setRenderingFingerprint ] ) ;
66
65
67
66
const [ isFormSubmited , setIsFormSubmited ] = useState ( false ) ;
67
+ const [ getInfraById , { data : infra } ] = osrdEditoastApi . endpoints . getInfraById . useLazyQuery ( { } ) ;
68
+
69
+ /**
70
+ * When infra id changes
71
+ * => fetch it
72
+ */
73
+ useEffect ( ( ) => {
74
+ if ( infraID ) {
75
+ getInfraById ( { id : infraID } ) ;
76
+ }
77
+ } , [ infraID , getInfraById ] ) ;
68
78
69
79
const switchTool = useCallback (
70
80
( { toolType, toolState } : switchProps ) => {
@@ -147,7 +157,6 @@ const Editor = () => {
147
157
dispatch,
148
158
editorState,
149
159
infraID,
150
- isInfraLocked : isLocked ,
151
160
isLoading,
152
161
isFormSubmited,
153
162
setIsFormSubmited,
@@ -166,7 +175,6 @@ const Editor = () => {
166
175
switchTypes ,
167
176
viewport ,
168
177
isLoading ,
169
- isLocked ,
170
178
isFormSubmited ,
171
179
setIsFormSubmited ,
172
180
]
@@ -387,7 +395,7 @@ const Editor = () => {
387
395
} ) }
388
396
</ div >
389
397
< div >
390
- { isLocked && (
398
+ { infra ?. locked && (
391
399
< div className = "infra-locked bg-yellow" > { t ( 'Editor.infra-errors.infra-locked' ) } </ div >
392
400
) }
393
401
{ toolAndState . tool . leftPanelComponent && (
0 commit comments