'use client' import * as React from 'react' import { Loader2 } from 'lucide-react' import { useT } from '@open-mercato/shared/lib/i18n/context' import { Button } from '@open-mercato/ui/primitives/button' import { Input } from '@open-mercato/ui/primitives/input' import { Label } from '@open-mercato/ui/primitives/label' type RecoveryCodeChallengeVerifyProps = { onVerify: (payload: { code: string }) => Promise submitLabel: string } export default function RecoveryCodeChallengeVerify({ onVerify, submitLabel, }: RecoveryCodeChallengeVerifyProps) { const t = useT() const [code, setCode] = React.useState('') const [submitting, setSubmitting] = React.useState(false) const normalizedCode = code.trim() const canSubmit = normalizedCode.length > 0 && !submitting const handleSubmit = React.useCallback(async (event: React.FormEvent) => { event.preventDefault() if (!canSubmit) return setSubmitting(true) try { await onVerify({ code: normalizedCode }) setCode('') } finally { setSubmitting(false) } }, [canSubmit, normalizedCode, onVerify]) return (

{t('security.login.mfaChallenge.recovery.title', 'Two-factor authentication')}

{t( 'security.login.mfaChallenge.recovery.description', 'Enter one of your recovery codes to complete sign in.', )}

setCode(event.target.value)} placeholder={t('security.login.mfaChallenge.recovery.placeholder', 'XXXXXX-XXXXXX')} autoComplete="one-time-code" className="h-10 border-slate-700 bg-slate-950 text-slate-100 placeholder:text-slate-500" />
) }