@@ -13,12 +13,12 @@ import type {
13
13
PostInfraByInfraIdPathPropertiesApiArg ,
14
14
} from 'common/api/osrdEditoastApi' ;
15
15
import { osrdEditoastApi } from 'common/api/osrdEditoastApi' ;
16
+ import { useOsrdConfSelectors } from 'common/osrdContext' ;
16
17
import {
17
18
formatSuggestedOperationalPoints ,
18
19
getPathfindingQuery ,
19
20
matchPathStepAndOp ,
20
21
} from 'modules/pathfinding/utils' ;
21
- import { useStoreDataForRollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector/useStoreDataForRollingStockSelector' ;
22
22
import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types' ;
23
23
import { setFailure , setWarning } from 'reducers/main' ;
24
24
import { replaceItinerary , updatePathSteps } from 'reducers/osrdconf/operationalStudiesConf' ;
@@ -51,11 +51,14 @@ const usePathfinding = (
51
51
const pathSteps = useSelector ( getPathSteps ) ;
52
52
const powerRestrictions = useSelector ( getPowerRestrictions ) ;
53
53
const { infra, reloadCount, setIsInfraError } = useInfraStatus ( ) ;
54
- const { rollingStock } = useStoreDataForRollingStockSelector ( ) ;
54
+ const { getRollingStockID } = useOsrdConfSelectors ( ) ;
55
+ const rollingStockId = useSelector ( getRollingStockID ) ;
55
56
56
57
const [ pathfindingState , setPathfindingState ] =
57
58
useState < PathfindingState > ( initialPathfindingState ) ;
58
59
60
+ const [ getRollingStockById ] =
61
+ osrdEditoastApi . endpoints . getRollingStockByRollingStockId . useLazyQuery ( ) ;
59
62
const [ postPathfindingBlocks ] =
60
63
osrdEditoastApi . endpoints . postInfraByInfraIdPathfindingBlocks . useLazyQuery ( ) ;
61
64
const [ postPathProperties ] =
@@ -186,6 +189,10 @@ const usePathfinding = (
186
189
}
187
190
188
191
setIsRunning ( ) ;
192
+
193
+ const rollingStock = rollingStockId
194
+ ? await getRollingStockById ( { rollingStockId } ) . unwrap ( )
195
+ : undefined ;
189
196
const pathfindingInput = getPathfindingQuery ( {
190
197
infraId,
191
198
rollingStock,
@@ -257,7 +264,7 @@ const usePathfinding = (
257
264
}
258
265
}
259
266
} ,
260
- [ rollingStock , infra ]
267
+ [ rollingStockId , infra ]
261
268
) ;
262
269
263
270
useEffect ( ( ) => {
0 commit comments