@@ -28,11 +28,7 @@ export const useTwoFactorAuth = () => {
28
28
const [ qrCodeSvg , setQrCodeSvg ] = useState < string | null > ( null ) ;
29
29
const [ manualSetupKey , setManualSetupKey ] = useState < string | null > ( null ) ;
30
30
const [ recoveryCodesList , setRecoveryCodesList ] = useState < string [ ] > ( [ ] ) ;
31
- const [ errors , setErrors ] = useState < {
32
- qrCode ?: string ;
33
- setupKey ?: string ;
34
- recoveryCodes ?: string ;
35
- } > ( { } ) ;
31
+ const [ errors , setErrors ] = useState < string [ ] > ( [ ] ) ;
36
32
37
33
const hasSetupData = useMemo < boolean > ( ( ) => qrCodeSvg !== null && manualSetupKey !== null , [ qrCodeSvg , manualSetupKey ] ) ;
38
34
@@ -42,7 +38,7 @@ export const useTwoFactorAuth = () => {
42
38
43
39
setQrCodeSvg ( svg ) ;
44
40
} catch {
45
- setErrors ( ( prev ) => ( { ...prev , qrCode : 'Failed to fetch QR code' } ) ) ;
41
+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch QR code' ] ) ;
46
42
setQrCodeSvg ( null ) ;
47
43
}
48
44
} , [ ] ) ;
@@ -53,13 +49,13 @@ export const useTwoFactorAuth = () => {
53
49
54
50
setManualSetupKey ( key ) ;
55
51
} catch {
56
- setErrors ( ( prev ) => ( { ...prev , setupKey : 'Failed to fetch a setup key' } ) ) ;
52
+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch setup key' ] ) ;
57
53
setManualSetupKey ( null ) ;
58
54
}
59
55
} , [ ] ) ;
60
56
61
57
const clearErrors = useCallback ( ( ) : void => {
62
- setErrors ( { } ) ;
58
+ setErrors ( [ ] ) ;
63
59
} , [ ] ) ;
64
60
65
61
const clearSetupData = useCallback ( ( ) : void => {
@@ -74,7 +70,7 @@ export const useTwoFactorAuth = () => {
74
70
75
71
setRecoveryCodesList ( codes ) ;
76
72
} catch {
77
- setErrors ( ( prev ) => ( { ...prev , recoveryCodes : 'Failed to fetch recovery codes' } ) ) ;
73
+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch recovery codes' ] ) ;
78
74
setRecoveryCodesList ( [ ] ) ;
79
75
}
80
76
} , [ ] ) ;
0 commit comments