@@ -5,24 +5,21 @@ import type { AllowanceValue } from 'applications/stdcm/types';
5
5
import InputGroupSNCF from 'common/BootstrapSNCF/InputGroupSNCF' ;
6
6
import type { InputGroupSNCFValue } from 'common/BootstrapSNCF/InputGroupSNCF' ;
7
7
import InputSNCF from 'common/BootstrapSNCF/InputSNCF' ;
8
- import { useOsrdConfActions , useOsrdConfSelectors } from 'common/osrdContext' ;
9
8
import { ALLOWANCE_UNITS_KEYS } from 'modules/stdcmAllowances/allowancesConsts' ;
10
- import type { StdcmConfSliceActions } from 'reducers/osrdconf/stdcmConf' ;
11
- import type { StdcmConfSelectors } from 'reducers/osrdconf/stdcmConf/selectors' ;
9
+ import {
10
+ updateGridMarginAfter ,
11
+ updateGridMarginBefore ,
12
+ updateStandardAllowance ,
13
+ } from 'reducers/osrdconf/stdcmConf' ;
14
+ import { getMargins } from 'reducers/osrdconf/stdcmConf/selectors' ;
12
15
import type { StandardAllowance } from 'reducers/osrdconf/types' ;
13
16
import { useAppDispatch } from 'store' ;
14
17
import { convertInputStringToNumber } from 'utils/strings' ;
15
18
16
19
const StdcmAllowances = ( { disabled = false } : { disabled ?: boolean } ) => {
17
20
const { t } = useTranslation ( 'allowances' ) ;
18
21
const dispatch = useAppDispatch ( ) ;
19
- const { getGridMarginBefore, getGridMarginAfter, getStandardStdcmAllowance } =
20
- useOsrdConfSelectors ( ) as StdcmConfSelectors ;
21
- const { updateGridMarginAfter, updateGridMarginBefore, updateStdcmStandardAllowance } =
22
- useOsrdConfActions ( ) as StdcmConfSliceActions ;
23
- const gridMarginBefore = useSelector ( getGridMarginBefore ) ;
24
- const gridMarginAfter = useSelector ( getGridMarginAfter ) ;
25
- const stdcmStandardAllowance = useSelector ( getStandardStdcmAllowance ) ;
22
+ const { gridMarginAfter, gridMarginBefore, standardAllowance } = useSelector ( getMargins ) ;
26
23
const standardAllowanceTypes = [
27
24
{
28
25
id : 'percentage' ,
@@ -40,7 +37,7 @@ const StdcmAllowances = ({ disabled = false }: { disabled?: boolean }) => {
40
37
value : newTypeValue . value === undefined ? undefined : Math . abs ( newTypeValue . value ) ,
41
38
} ;
42
39
43
- dispatch ( updateStdcmStandardAllowance ( processedType ) ) ;
40
+ dispatch ( updateStandardAllowance ( processedType ) ) ;
44
41
} ;
45
42
46
43
return (
@@ -93,8 +90,8 @@ const StdcmAllowances = ({ disabled = false }: { disabled?: boolean }) => {
93
90
options = { standardAllowanceTypes }
94
91
onChange = { onchangeType }
95
92
currentValue = { {
96
- unit : stdcmStandardAllowance ?. type || 'percentage' ,
97
- value : stdcmStandardAllowance ?. value ,
93
+ unit : standardAllowance ?. type || 'percentage' ,
94
+ value : standardAllowance ?. value ,
98
95
} }
99
96
disabled = { disabled }
100
97
/>
0 commit comments