"use client"; import { Input } from "@/components/ui/input"; import { Label } from "@radix-ui/react-label"; import { useEffect, useRef } from "react"; import { useFormState } from "react-dom"; import { toast } from "sonner"; import { ExclamationTriangleIcon } from "@/components/icons"; import { logout, verifyEmail, resendVerificationEmail as resendEmail } from "@/lib/auth/actions"; import { SubmitButton } from "@/components/submit-button"; export const VerifyCode = () => { const [verifyEmailState, verifyEmailAction] = useFormState(verifyEmail, null); const [resendState, resendAction] = useFormState(resendEmail, null); const codeFormRef = useRef(null); useEffect(() => { if (resendState?.success) { toast("Email sent!"); } if (resendState?.error) { toast(resendState.error, { icon: , }); } }, [resendState?.error, resendState?.success]); useEffect(() => { if (verifyEmailState?.error) { toast(verifyEmailState.error, { icon: , }); } }, [verifyEmailState?.error]); return (
Verify
Resend Code
want to use another email? Log out now.
); };