Commit 941a060 1 parent 956d9d4 commit 941a060 Copy full SHA for 941a060
File tree 2 files changed +13
-6
lines changed
src/app/simulation/etapes
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,12 @@ const schemaNon = z.object({
35
35
return { message : context . defaultError } ;
36
36
} ,
37
37
} ) ,
38
+ espacesExterieursCommuns : z . undefined ( ) ,
38
39
} ) ;
39
40
40
41
export const Step5 = ( ) => {
41
42
const [ radioState , setRadioState ] = useState < ( typeof OuiNonLabels ) [ number ] | undefined > ( ) ;
42
- const { store } = usePacoupaSessionStorage ( ) ;
43
+ const { store, setStore } = usePacoupaSessionStorage ( ) ;
43
44
44
45
useEffect ( ( ) => {
45
46
setRadioState ( ( store . possedeEspacesExterieursCommuns as ( typeof OuiNonLabels ) [ number ] ) ?? "Oui" ) ;
@@ -52,8 +53,11 @@ export const Step5 = () => {
52
53
el . checked = false ;
53
54
} ,
54
55
) ;
56
+ setStore ( { ...store , espacesExterieursCommuns : undefined } ) ;
55
57
}
56
- } , [ radioState ] ) ;
58
+ // Doesn't depend on store and make a recursive call if present.
59
+ // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ } , [ radioState , setStore ] ) ;
57
61
58
62
return (
59
63
< >
Original file line number Diff line number Diff line change @@ -35,25 +35,28 @@ const schemaNon = z.object({
35
35
return { message : context . defaultError } ;
36
36
} ,
37
37
} ) ,
38
+ espacesExterieursPersonnels : z . undefined ( ) ,
38
39
} ) ;
39
40
40
41
export const Step6 = ( ) => {
41
42
const [ radioState , setRadioState ] = useState < ( typeof OuiNonLabels ) [ number ] | undefined > ( ) ;
42
- const { store } = usePacoupaSessionStorage ( ) ;
43
+ const { store, setStore } = usePacoupaSessionStorage ( ) ;
43
44
44
45
useEffect ( ( ) => {
45
- setRadioState ( ( store . possedeEspacesExterieursPersonnels as ( typeof OuiNonLabels ) [ number ] ) ?? "Oui" ) ;
46
+ setRadioState ( ( store . possedeEspacesExterieursCommuns as ( typeof OuiNonLabels ) [ number ] ) ?? "Oui" ) ;
46
47
} , [ store ] ) ;
47
-
48
48
useEffect ( ( ) => {
49
49
if ( radioState === "Non" ) {
50
50
( document . getElementsByName ( "espacesExterieursPersonnels" ) as NodeListOf < HTMLInputElement > ) . forEach (
51
51
( el : HTMLInputElement ) => {
52
52
el . checked = false ;
53
53
} ,
54
54
) ;
55
+ setStore ( { ...store , espacesExterieursPersonnels : undefined } ) ;
55
56
}
56
- } , [ radioState ] ) ;
57
+ // Doesn't depend on store and make a recursive call if present.
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ } , [ radioState , setStore ] ) ;
57
60
58
61
return (
59
62
< >
You can’t perform that action at this time.
0 commit comments