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 (

Flights

Enter passkey to continue

setPasskey(e.target.value)} placeholder="Passkey" autoFocus className="w-full px-4 py-3 rounded-lg border border-gray-300 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#1a73e8] focus:border-transparent" /> {error && (

{error}

)}
); }