({
hasEmailService,
isProduction,
isEmailVerificationEnabled,
}: {
hasEmailService: boolean
isProduction: boolean
isEmailVerificationEnabled: boolean
})
| 20 | const OTP_SLOTS = [0, 1, 2, 3, 4, 5] as const |
| 21 | |
| 22 | function VerificationForm({ |
| 23 | hasEmailService, |
| 24 | isProduction, |
| 25 | isEmailVerificationEnabled, |
| 26 | }: { |
| 27 | hasEmailService: boolean |
| 28 | isProduction: boolean |
| 29 | isEmailVerificationEnabled: boolean |
| 30 | }) { |
| 31 | const { |
| 32 | otp, |
| 33 | email, |
| 34 | status, |
| 35 | isResending, |
| 36 | errorMessage, |
| 37 | isOtpComplete, |
| 38 | verifyCode, |
| 39 | resendCode, |
| 40 | handleOtpChange, |
| 41 | } = useVerification({ hasEmailService, isProduction, isEmailVerificationEnabled }) |
| 42 | |
| 43 | const isVerified = status === 'verified' |
| 44 | const isLoading = status === 'verifying' || isResending |
| 45 | const isInvalidOtp = status === 'error' |
| 46 | |
| 47 | const [countdown, setCountdown] = useState(0) |
| 48 | const [isResendDisabled, setIsResendDisabled] = useState(false) |
| 49 | |
| 50 | useEffect(() => { |
| 51 | if (countdown > 0) { |
| 52 | const timer = setTimeout(() => setCountdown((c) => c - 1), 1000) |
| 53 | return () => clearTimeout(timer) |
| 54 | } |
| 55 | if (countdown === 0 && isResendDisabled) { |
| 56 | setIsResendDisabled(false) |
| 57 | } |
| 58 | }, [countdown, isResendDisabled]) |
| 59 | |
| 60 | const handleResend = () => { |
| 61 | resendCode() |
| 62 | setIsResendDisabled(true) |
| 63 | setCountdown(30) |
| 64 | } |
| 65 | |
| 66 | return ( |
| 67 | <div className='space-y-6'> |
| 68 | <AuthHeader |
| 69 | title={isVerified ? 'Email Verified' : 'Verify your email'} |
| 70 | description={ |
| 71 | isVerified |
| 72 | ? 'Your email has been verified. Redirecting to dashboard...' |
| 73 | : !isEmailVerificationEnabled |
| 74 | ? 'Email verification is disabled. Redirecting to dashboard...' |
| 75 | : hasEmailService |
| 76 | ? `A verification code has been sent to ${email || 'your email'}` |
| 77 | : !isProduction |
| 78 | ? 'Development mode: Check your console logs for the verification code' |
| 79 | : 'Error: Email verification is enabled but no email service is configured' |
nothing calls this directly
no test coverage detected