@@ -10,6 +10,7 @@ import infraLogo from 'assets/pictures/components/tracks.svg';
10
10
import { Spinner } from 'common/Loaders' ;
11
11
import { useOsrdConfSelectors } from 'common/osrdContext' ;
12
12
import { usePathfinding } from 'modules/pathfinding/hooks/usePathfinding' ;
13
+ import { isPathStepInvalid } from 'modules/pathfinding/utils' ;
13
14
import { useStoreDataForRollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector/useStoreDataForRollingStockSelector' ;
14
15
import { conditionalStringConcat , formatKmValue } from 'utils/strings' ;
15
16
@@ -23,7 +24,9 @@ type PathfindingProps = {
23
24
const Pathfinding = ( { pathProperties, setPathProperties } : PathfindingProps ) => {
24
25
const { t } = useTranslation ( [ 'operationalStudies/manageTrainSchedule' ] ) ;
25
26
26
- const { getOrigin, getDestination } = useOsrdConfSelectors ( ) ;
27
+ const { getOrigin, getDestination, getPathSteps } = useOsrdConfSelectors ( ) ;
28
+ const pathSteps = useSelector ( getPathSteps ) ;
29
+ const hasInvalidPathStep = pathSteps . some ( ( pathStep ) => isPathStepInvalid ( pathStep ) ) ;
27
30
const origin = useSelector ( getOrigin , isEqual ) ;
28
31
const destination = useSelector ( getDestination , isEqual ) ;
29
32
const { rollingStock } = useStoreDataForRollingStockSelector ( ) ;
@@ -61,7 +64,8 @@ const Pathfinding = ({ pathProperties, setPathProperties }: PathfindingProps) =>
61
64
! pathfindingState . running &&
62
65
pathfindingState . done &&
63
66
origin &&
64
- destination && (
67
+ destination &&
68
+ ! hasInvalidPathStep && (
65
69
< div className = "content pathfinding-done" >
66
70
< span className = "lead" data-testid = "result-pathfinding-done" >
67
71
< CheckCircle />
@@ -83,7 +87,7 @@ const Pathfinding = ({ pathProperties, setPathProperties }: PathfindingProps) =>
83
87
</ div >
84
88
) : (
85
89
< >
86
- { pathfindingState . error && (
90
+ { ( pathfindingState . error || hasInvalidPathStep ) && (
87
91
< div
88
92
className = { cx ( 'content pathfinding-error' , {
89
93
'mt-2' : infra && infra . state !== 'CACHED' ,
@@ -93,7 +97,9 @@ const Pathfinding = ({ pathProperties, setPathProperties }: PathfindingProps) =>
93
97
< Stop />
94
98
</ span >
95
99
< span className = "flex-grow-1" >
96
- { t ( 'pathfindingError' , { errorMessage : t ( pathfindingState . error ) } ) }
100
+ { hasInvalidPathStep
101
+ ? t ( 'InvalidTrainScheduleStep' )
102
+ : t ( 'pathfindingError' , { errorMessage : t ( pathfindingState . error ) } ) }
97
103
</ span >
98
104
</ div >
99
105
) }
0 commit comments