@@ -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,13 @@ const Editor = () => {
65
65
} , [ setRenderingFingerprint ] ) ;
66
66
67
67
const [ isFormSubmited , setIsFormSubmited ] = useState ( false ) ;
68
+ const { data : infra } = osrdEditoastApi . endpoints . getInfraById . useQuery (
69
+ { id : infraID as number } ,
70
+ {
71
+ skip : ! infraID ,
72
+ }
73
+ ) ;
74
+ const { updateInfra } = useInfraActions ( ) ;
68
75
69
76
const switchTool = useCallback (
70
77
( { toolType, toolState } : switchProps ) => {
@@ -312,6 +319,12 @@ const Editor = () => {
312
319
}
313
320
} , [ toolAndState . state . entity ?. properties . id ] ) ;
314
321
322
+ useEffect ( ( ) => {
323
+ if ( infra ) {
324
+ dispatch ( updateInfra ( infra ) ) ;
325
+ }
326
+ } , [ infra ] ) ;
327
+
315
328
return (
316
329
< EditorContext . Provider value = { extendedContext as EditorContextType < unknown > } >
317
330
< main
0 commit comments