'use client' import { Suspense, useEffect, useState } from 'react' import { cn, InputOTP, InputOTPGroup, InputOTPSlot } from '@sim/emcn' import { AuthFormMessage, AuthHeader, AuthNavPrompt, AuthSubmitButton, AuthTextLink, } from '@/app/(auth)/components' import { useVerification } from '@/app/(auth)/verify/use-verification' interface VerifyContentProps { hasEmailService: boolean isProduction: boolean isEmailVerificationEnabled: boolean } const OTP_SLOTS = [0, 1, 2, 3, 4, 5] as const function VerificationForm({ hasEmailService, isProduction, isEmailVerificationEnabled, }: { hasEmailService: boolean isProduction: boolean isEmailVerificationEnabled: boolean }) { const { otp, email, status, isResending, errorMessage, isOtpComplete, verifyCode, resendCode, handleOtpChange, } = useVerification({ hasEmailService, isProduction, isEmailVerificationEnabled }) const isVerified = status === 'verified' const isLoading = status === 'verifying' || isResending const isInvalidOtp = status === 'error' const [countdown, setCountdown] = useState(0) const [isResendDisabled, setIsResendDisabled] = useState(false) useEffect(() => { if (countdown > 0) { const timer = setTimeout(() => setCountdown((c) => c - 1), 1000) return () => clearTimeout(timer) } if (countdown === 0 && isResendDisabled) { setIsResendDisabled(false) } }, [countdown, isResendDisabled]) const handleResend = () => { resendCode() setIsResendDisabled(true) setCountdown(30) } return (
Enter the 6-digit code to verify your account. {hasEmailService ? " If you don't see it in your inbox, check your spam folder." : ''}
{errorMessage}
Didn't receive a code?{' '}
{countdown > 0 ? (
Resend in {countdown}s
) : (