import { useVisa } from '../providers/VisaProvider'
import { VerifyOtp } from '../components/VerifyOtp'

export function VerifyUpdateAccount() {
  const { updateAccount, emailToVerify } = useVisa()

  const handleResend = async () => {
    if (!emailToVerify) return { success: false }
    return updateAccount({ email: emailToVerify }, '/account/update/verify')
  }

  return (
    <VerifyOtp
      type="email_change"
      redirectTo="/"
      onResend={handleResend}
    />
  )
}
