'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 TotpChallengeVerifyProps = { onVerify: (payload: { code: string }) => Promise submitLabel: string } export default function TotpChallengeVerify({ onVerify, submitLabel, }: TotpChallengeVerifyProps) { const t = useT() const [code, setCode] = React.useState('') const [submitting, setSubmitting] = React.useState(false) const canSubmit = code.trim().length >= 6 && !submitting const handleSubmit = React.useCallback(async (event: React.FormEvent) => { event.preventDefault() if (!canSubmit) return setSubmitting(true) try { await onVerify({ code: code.trim() }) setCode('') } finally { setSubmitting(false) } }, [canSubmit, code, onVerify]) return (

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

{t( 'security.login.mfaChallenge.totp.description', 'Enter the code from your two-factor authentication app or browser extension below.', )}

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