"use client"; import { UseFormReturn } from "react-hook-form"; import { Button } from "@app/components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@app/components/ui/form"; import { InputOTP, InputOTPGroup, InputOTPSlot } from "./ui/input-otp"; import { Alert, AlertDescription } from "@app/components/ui/alert"; import { useTranslations } from "next-intl"; import { REGEXP_ONLY_DIGITS } from "input-otp"; const MFA_OTP_INPUT_ID = "mfa-otp-code"; type MfaInputFormProps = { form: UseFormReturn<{ code: string }>; onSubmit: (values: { code: string }) => void | Promise; onBack: () => void; error?: string | null; loading?: boolean; formId?: string; username?: string; }; export default function MfaInputForm({ form, onSubmit, onBack, error, loading = false, formId = "mfaForm", username }: MfaInputFormProps) { const t = useTranslations(); return (

{t("otpAuth")}

{t("otpAuthDescription")}

{username ? ( ) : null} ( {t("otpAuth")}
{ field.onChange(value); if (value.length === 6) { form.handleSubmit( onSubmit )(); } }} >
)} /> {error && ( {error} )}
); }