'use client'; import { useState } from 'react'; import { Mail, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; export default function PortalLoginPage() { const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [submitted, setSubmitted] = useState(false); const [error, setError] = useState(''); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const res = await fetch('/api/portal/auth/request', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email }), }); if (!res.ok) { const data = await res.json().catch(() => ({})); setError((data as any).error ?? 'Something went wrong. Please try again.'); return; } setSubmitted(true); } catch { setError('Unable to connect. Please check your connection and try again.'); } finally { setLoading(false); } } if (submitted) { return (

Check your email

If {email} is associated with a client account, you will receive a sign-in link shortly. The link expires in 24 hours.

); } return (

Client Portal

Enter your email to receive a sign-in link

setEmail(e.target.value)} required autoFocus disabled={loading} />
{error && (

{error}

)}

This portal is for existing clients only.

); }