import { useState, type FormEvent } from 'react'; interface Props { onAuthenticated: () => void; } export default function PasskeyGate({ onAuthenticated }: Props) { const [passkey, setPasskey] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); async function handleSubmit(e: FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const res = await fetch('/api/auth/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ passkey }), }); if (res.ok) { onAuthenticated(); } else { setError('Invalid passkey'); setPasskey(''); } } catch { setError('Connection error. Please try again.'); } finally { setLoading(false); } } return (
Enter passkey to continue