import { zodResolver } from "@hookform/resolvers/zod"; import { Warning } from "@phosphor-icons/react"; import { twoFactorBackupSchema } from "@reactive-resume/dto"; import { usePasswordToggle } from "@reactive-resume/hooks"; import { Button, Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Input, } from "@reactive-resume/ui"; import { AxiosError } from "axios"; import { useRef } from "react"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import { z } from "zod"; import { toast } from "@/client/hooks/use-toast"; import { useBackupOtp } from "@/client/services/auth"; type FormValues = z.infer; export const BackupOtpPage = () => { const navigate = useNavigate(); const { backupOtp, loading } = useBackupOtp(); const formRef = useRef(null); usePasswordToggle(formRef); const form = useForm({ resolver: zodResolver(twoFactorBackupSchema), defaultValues: { code: "" }, }); const onSubmit = async (data: FormValues) => { try { await backupOtp(data); navigate("/dashboard"); } catch (error) { form.reset(); if (error instanceof AxiosError) { const message = error.response?.data.message || error.message; toast({ variant: "error", icon: , title: "An error occurred while trying to sign in", description: message, }); } } }; return (

Use your backup code

Enter one of the 10 backup codes you saved when you enabled two-factor authentication.
( Backup Code )} />
); };