'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 (
{!isVerified && isEmailVerificationEnabled && (

Enter the 6-digit code to verify your account. {hasEmailService ? " If you don't see it in your inbox, check your spam folder." : ''}

{OTP_SLOTS.map((index) => ( ))}
{errorMessage && (

{errorMessage}

)}
Verify Email {hasEmailService && (

Didn't receive a code?{' '} {countdown > 0 ? ( Resend in {countdown}s ) : ( Resend )}

)} { if (typeof window !== 'undefined') { sessionStorage.removeItem('verificationEmail') sessionStorage.removeItem('inviteRedirectUrl') sessionStorage.removeItem('isInviteFlow') } }} />
)}
) } function VerificationFormFallback() { return (
) } export function VerifyContent({ hasEmailService, isProduction, isEmailVerificationEnabled, }: VerifyContentProps) { return ( }> ) }