Commit 6328186 1 parent c399fdc commit 6328186 Copy full SHA for 6328186
File tree 1 file changed +12
-10
lines changed
front/src/applications/operationalStudies/components/ManageTrainSchedule/Allowances
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,18 @@ export function findAllowanceOverlap({
16
16
const after = allowances . findIndex (
17
17
( allowance ) => endPosition >= allowance . begin_position && endPosition <= allowance . end_position
18
18
) ;
19
- return [
20
- before !== currentAllowanceSelected &&
21
- // Could be BEFORE the first allowance
22
- ( beginPosition < allowances [ 0 ] . begin_position ? 0 : before ) ,
23
- after !== currentAllowanceSelected &&
24
- // Could be AFTER the last allowance
25
- ( endPosition > allowances [ allowances . length - 1 ] . end_position
26
- ? allowances . length - 1
27
- : after ) ,
28
- ] ;
19
+ return allowances . length > 0
20
+ ? [
21
+ before !== currentAllowanceSelected &&
22
+ // Could be BEFORE the first allowance
23
+ ( beginPosition < allowances [ 0 ] . begin_position ? 0 : before ) ,
24
+ after !== currentAllowanceSelected &&
25
+ // Could be AFTER the last allowance
26
+ ( endPosition > allowances [ allowances . length - 1 ] . end_position
27
+ ? allowances . length - 1
28
+ : after ) ,
29
+ ]
30
+ : [ - 1 , - 1 ] ;
29
31
}
30
32
31
33
export default function getAllowanceValue ( value ?: AllowanceValue ) {
You can’t perform that action at this time.
0 commit comments