@@ -28,11 +28,7 @@ export const useTwoFactorAuth = () => {
2828 const [ qrCodeSvg , setQrCodeSvg ] = useState < string | null > ( null ) ;
2929 const [ manualSetupKey , setManualSetupKey ] = useState < string | null > ( null ) ;
3030 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 [ ] > ( [ ] ) ;
3632
3733 const hasSetupData = useMemo < boolean > ( ( ) => qrCodeSvg !== null && manualSetupKey !== null , [ qrCodeSvg , manualSetupKey ] ) ;
3834
@@ -42,7 +38,7 @@ export const useTwoFactorAuth = () => {
4238
4339 setQrCodeSvg ( svg ) ;
4440 } catch {
45- setErrors ( ( prev ) => ( { ...prev , qrCode : 'Failed to fetch QR code' } ) ) ;
41+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch QR code' ] ) ;
4642 setQrCodeSvg ( null ) ;
4743 }
4844 } , [ ] ) ;
@@ -53,13 +49,13 @@ export const useTwoFactorAuth = () => {
5349
5450 setManualSetupKey ( key ) ;
5551 } catch {
56- setErrors ( ( prev ) => ( { ...prev , setupKey : 'Failed to fetch a setup key' } ) ) ;
52+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch setup key' ] ) ;
5753 setManualSetupKey ( null ) ;
5854 }
5955 } , [ ] ) ;
6056
6157 const clearErrors = useCallback ( ( ) : void => {
62- setErrors ( { } ) ;
58+ setErrors ( [ ] ) ;
6359 } , [ ] ) ;
6460
6561 const clearSetupData = useCallback ( ( ) : void => {
@@ -74,7 +70,7 @@ export const useTwoFactorAuth = () => {
7470
7571 setRecoveryCodesList ( codes ) ;
7672 } catch {
77- setErrors ( ( prev ) => ( { ...prev , recoveryCodes : 'Failed to fetch recovery codes' } ) ) ;
73+ setErrors ( ( prev ) => [ ...prev , 'Failed to fetch recovery codes' ] ) ;
7874 setRecoveryCodesList ( [ ] ) ;
7975 }
8076 } , [ ] ) ;
0 commit comments