@@ -10,10 +10,7 @@ interface TwoFactorRecoveryCodesProps {
10
10
fetchRecoveryCodes : ( ) => Promise < void > ;
11
11
}
12
12
13
- export default function TwoFactorRecoveryCodes ( {
14
- recoveryCodesList,
15
- fetchRecoveryCodes,
16
- } : TwoFactorRecoveryCodesProps ) {
13
+ export default function TwoFactorRecoveryCodes ( { recoveryCodesList, fetchRecoveryCodes } : TwoFactorRecoveryCodesProps ) {
17
14
const [ isCodesVisible , setIsCodesVisible ] = useState < boolean > ( false ) ;
18
15
const codesSectionRef = useRef < HTMLDivElement | null > ( null ) ;
19
16
@@ -28,7 +25,7 @@ export default function TwoFactorRecoveryCodes({
28
25
setTimeout ( ( ) => {
29
26
codesSectionRef . current ?. scrollIntoView ( {
30
27
behavior : 'smooth' ,
31
- block : 'nearest'
28
+ block : 'nearest' ,
32
29
} ) ;
33
30
} ) ;
34
31
}
@@ -50,34 +47,21 @@ export default function TwoFactorRecoveryCodes({
50
47
2FA Recovery Codes
51
48
</ CardTitle >
52
49
< CardDescription >
53
- Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager.
50
+ Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager.
54
51
</ CardDescription >
55
52
</ CardHeader >
56
53
< CardContent >
57
54
< div className = "flex flex-col gap-3 select-none sm:flex-row sm:items-center sm:justify-between" >
58
- < Button
59
- onClick = { toggleCodesVisibility }
60
- className = "w-fit"
61
- aria-expanded = { isCodesVisible }
62
- aria-controls = "recovery-codes-section"
63
- >
55
+ < Button onClick = { toggleCodesVisibility } className = "w-fit" aria-expanded = { isCodesVisible } aria-controls = "recovery-codes-section" >
64
56
< IconComponent className = "size-4" aria-hidden = "true" />
65
57
{ isCodesVisible ? 'Hide' : 'View' } Recovery Codes
66
58
</ Button >
67
59
68
60
{ isCodesVisible && (
69
61
< Form { ...regenerateRecoveryCodes . form ( ) } options = { { preserveScroll : true } } onSuccess = { fetchRecoveryCodes } >
70
62
{ ( { processing } ) => (
71
- < Button
72
- variant = "secondary"
73
- type = "submit"
74
- disabled = { processing }
75
- aria-describedby = "regenerate-warning"
76
- >
77
- < RefreshCw
78
- className = { `mr-2 size-4 ${ processing ? 'animate-spin' : '' } ` }
79
- aria-hidden = "true"
80
- />
63
+ < Button variant = "secondary" type = "submit" disabled = { processing } aria-describedby = "regenerate-warning" >
64
+ < RefreshCw className = { `mr-2 size-4 ${ processing ? 'animate-spin' : '' } ` } aria-hidden = "true" />
81
65
{ processing ? 'Regenerating...' : 'Regenerate Codes' }
82
66
</ Button >
83
67
) }
@@ -86,9 +70,7 @@ export default function TwoFactorRecoveryCodes({
86
70
</ div >
87
71
< div
88
72
id = "recovery-codes-section"
89
- className = { `relative overflow-hidden transition-all duration-300 ${
90
- isCodesVisible ? 'h-auto opacity-100' : 'h-0 opacity-0'
91
- } `}
73
+ className = { `relative overflow-hidden transition-all duration-300 ${ isCodesVisible ? 'h-auto opacity-100' : 'h-0 opacity-0' } ` }
92
74
aria-hidden = { ! isCodesVisible }
93
75
>
94
76
< div className = "mt-3 space-y-3" >
@@ -101,11 +83,7 @@ export default function TwoFactorRecoveryCodes({
101
83
{ ! recoveryCodesList . length ? (
102
84
< div className = "space-y-2" aria-label = "Loading recovery codes" >
103
85
{ Array . from ( { length : 8 } , ( _ , index ) => (
104
- < div
105
- key = { index }
106
- className = "h-4 animate-pulse rounded bg-muted-foreground/20"
107
- aria-hidden = "true"
108
- />
86
+ < div key = { index } className = "h-4 animate-pulse rounded bg-muted-foreground/20" aria-hidden = "true" />
109
87
) ) }
110
88
</ div >
111
89
) : (
@@ -118,8 +96,8 @@ export default function TwoFactorRecoveryCodes({
118
96
</ div >
119
97
< div className = "text-xs text-muted-foreground select-none" >
120
98
< p id = "regenerate-warning" >
121
- Each recovery code can be used once to access your account and will be removed after use.
122
- If you need more, click < span className = "font-bold" > Regenerate Codes</ span > above.
99
+ Each recovery code can be used once to access your account and will be removed after use. If you need more, click { ' ' }
100
+ < span className = "font-bold" > Regenerate Codes</ span > above.
123
101
</ p >
124
102
</ div >
125
103
</ div >
0 commit comments