@@ -18,20 +18,17 @@ const breadcrumbs: BreadcrumbItem[] = [
1818] ;
1919
2020interface TwoFactorProps {
21- enabled : boolean ;
2221 confirmed : boolean ;
23- qrCode : boolean ;
2422 recoveryCodes : string [ ] ;
2523}
2624
27- export default function TwoFactor ( { enabled : initialEnabled , confirmed : initialConfirmed , qrCode, recoveryCodes } : TwoFactorProps ) {
28- const [ enabled , setEnabled ] = useState ( initialEnabled ) ;
25+ export default function TwoFactor ( { confirmed : initialConfirmed , recoveryCodes } : TwoFactorProps ) {
2926 const [ confirmed , setConfirmed ] = useState ( initialConfirmed ) ;
3027 const [ showModal , setShowModal ] = useState ( false ) ;
3128 const [ verifyStep , setVerifyStep ] = useState ( false ) ;
3229 const [ qrCodeSvg , setQrCodeSvg ] = useState ( '' ) ;
3330 const [ secretKey , setSecretKey ] = useState ( '' ) ;
34- const [ showingRecoveryCodes , setShowingRecoveryCodes ] = useState ( initialEnabled ) ;
31+ const [ showingRecoveryCodes , setShowingRecoveryCodes ] = useState ( false ) ;
3532 const [ recoveryCodesList , setRecoveryCodesList ] = useState ( recoveryCodes ) ;
3633 const [ copied , setCopied ] = useState ( false ) ;
3734
@@ -51,7 +48,6 @@ export default function TwoFactor({ enabled: initialEnabled, confirmed: initialC
5148 preserveScroll : true ,
5249 onSuccess : async ( ) => {
5350 // Only set enabled to true, but not confirmed yet
54- setEnabled ( true ) ;
5551 const response = await fetch ( route ( 'two-factor.qr-code' ) ) ;
5652 const data = await response . json ( ) ;
5753 setQrCodeSvg ( data . svg ) ;
@@ -117,7 +113,6 @@ export default function TwoFactor({ enabled: initialEnabled, confirmed: initialC
117113 destroy ( route ( 'two-factor.disable' ) , {
118114 preserveScroll : true ,
119115 onSuccess : ( ) => {
120- setEnabled ( false ) ;
121116 setConfirmed ( false ) ;
122117 setShowingRecoveryCodes ( false ) ;
123118 setQrCodeSvg ( '' ) ;
@@ -319,18 +314,22 @@ export default function TwoFactor({ enabled: initialEnabled, confirmed: initialC
319314 </ Button >
320315 ) }
321316 </ div >
322- { showingRecoveryCodes && (
323- < div className = "relative" >
324- < div className = "grid max-w-xl gap-1 px-4 py-4 font-mono text-sm bg-stone-200 dark:bg-stone-900 dark:text-stone-100" >
325- { recoveryCodesList . map ( ( code , index ) => (
326- < div key = { index } > { code } </ div >
327- ) ) }
328- </ div >
329- < p className = "px-4 py-3 text-xs select-none text-stone-500 dark:text-stone-400" >
330- You have { recoveryCodesList . length } recovery codes left. Each can be used once to access your account and will be removed after use. If you need more, click < span className = "font-bold" > Regenerate Codes</ span > above.
331- </ p >
317+ < div
318+ className = "relative overflow-hidden transition-all duration-300"
319+ style = { {
320+ height : showingRecoveryCodes ? 'auto' : '0' ,
321+ opacity : showingRecoveryCodes ? 1 : 0 ,
322+ } }
323+ >
324+ < div className = "grid max-w-xl gap-1 px-4 py-4 font-mono text-sm bg-stone-200 dark:bg-stone-900 dark:text-stone-100" >
325+ { recoveryCodesList . map ( ( code , index ) => (
326+ < div key = { index } > { code } </ div >
327+ ) ) }
332328 </ div >
333- ) }
329+ < p className = "px-4 py-3 text-xs select-none text-stone-500 dark:text-stone-400" >
330+ You have { recoveryCodesList . length } recovery codes left. Each can be used once to access your account and will be removed after use. If you need more, click < span className = "font-bold" > Regenerate Codes</ span > above.
331+ </ p >
332+ </ div >
334333 </ div >
335334 </ div >
336335 < div className = "inline relative" >
0 commit comments