@@ -37,7 +37,7 @@ const useStdcmPathfinding = (infra?: InfraWithState) => {
37
37
} , [ pathSteps ] ) ;
38
38
39
39
const pathfindingPayload = useMemo ( ( ) => {
40
- if ( infra ?. state !== 'CACHED' || ! rollingStock || pathStepsLocations . length < 2 ) {
40
+ if ( infra ?. state !== 'CACHED' || pathStepsLocations . length < 2 ) {
41
41
return null ;
42
42
}
43
43
return getPathfindingQuery ( {
@@ -47,28 +47,27 @@ const useStdcmPathfinding = (infra?: InfraWithState) => {
47
47
} ) ;
48
48
} , [ pathStepsLocations , rollingStock , infra ] ) ;
49
49
50
- const { pathfinding, isFetching } =
50
+ const { data : pathfinding , isFetching } =
51
51
osrdEditoastApi . endpoints . postInfraByInfraIdPathfindingBlocks . useQuery ( pathfindingPayload ! , {
52
52
skip : ! pathfindingPayload ,
53
- selectFromResult : ( response ) => {
54
- const pathProperties = usePathProperties (
55
- infra ?. id ,
56
- response ?. data ?. status === 'success' ? response . data : undefined ,
57
- [ 'geometry' ]
58
- ) ;
59
- return {
60
- ...response ,
61
- pathfinding : response . data
62
- ? {
63
- status : response . data . status ,
64
- geometry : pathProperties ?. geometry ?? undefined ,
65
- }
66
- : null ,
67
- } ;
68
- } ,
69
53
} ) ;
70
54
71
- return { isPathfindingLoading : isFetching , pathfinding } ;
55
+ const pathProperties = usePathProperties (
56
+ infra ?. id ,
57
+ pathfinding ?. status === 'success' ? pathfinding : undefined ,
58
+ [ 'geometry' ]
59
+ ) ;
60
+
61
+ const pathfindingResult = useMemo ( ( ) => {
62
+ return pathfinding
63
+ ? {
64
+ status : pathfinding . status ,
65
+ geometry : pathProperties ?. geometry ?? undefined ,
66
+ }
67
+ : null ;
68
+ } , [ pathfinding ] ) ;
69
+
70
+ return { isPathfindingLoading : isFetching , pathfinding : pathfindingResult } ;
72
71
} ;
73
72
74
73
export default useStdcmPathfinding ;
0 commit comments