@@ -19,12 +19,12 @@ 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
- import { useInfraID , useOsrdActions } from 'common/osrdContext' ;
27
+ import { useInfraActions , useInfraID , useOsrdActions } from 'common/osrdContext' ;
28
28
import Tipped from 'common/Tipped' ;
29
29
import type { EditorSliceActions } from 'reducers/editor' ;
30
30
import { getEditorState , getInfraLockStatus } from 'reducers/editor/selectors' ;
@@ -49,8 +49,8 @@ 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 ) ;
53
+ const isLocked = useSelector ( getInfraLockStatus ) ;
54
54
const editorState = useSelector ( getEditorState ) ;
55
55
const switchTypes = useSwitchTypes ( infraID ) ;
56
56
/* eslint-disable @typescript-eslint/no-explicit-any */
@@ -65,6 +65,8 @@ const Editor = () => {
65
65
} , [ setRenderingFingerprint ] ) ;
66
66
67
67
const [ isFormSubmited , setIsFormSubmited ] = useState ( false ) ;
68
+ const [ getInfraById , { data : infra } ] = osrdEditoastApi . endpoints . getInfraById . useLazyQuery ( { } ) ;
69
+ const { updateInfra } = useInfraActions ( ) ;
68
70
69
71
const switchTool = useCallback (
70
72
( { toolType, toolState } : switchProps ) => {
@@ -312,6 +314,18 @@ const Editor = () => {
312
314
}
313
315
} , [ toolAndState . state . entity ?. properties . id ] ) ;
314
316
317
+ useEffect ( ( ) => {
318
+ if ( infraID ) {
319
+ getInfraById ( { id : infraID } ) ;
320
+ }
321
+ } , [ infraID , getInfraById ] ) ;
322
+
323
+ useEffect ( ( ) => {
324
+ if ( infra ) {
325
+ dispatch ( updateInfra ( infra ) ) ;
326
+ }
327
+ } , [ infra ] ) ;
328
+
315
329
return (
316
330
< EditorContext . Provider value = { extendedContext as EditorContextType < unknown > } >
317
331
< main
0 commit comments