import { useState } from 'preact/hooks'; import { submitLead } from './api'; export const Contact = () => { const [name, setName] = useState(''); const [phone, setPhone] = useState(''); const [interest, setInterest] = useState(''); const [message, setMessage] = useState(''); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const handleSubmit = async () => { if (!name.trim() || !phone.trim()) return; setLoading(true); setError(''); try { await submitLead({ name: name.trim(), phone: phone.trim(), interest: interest.trim() || undefined, message: message.trim() || undefined, captchaToken: 'dev-bypass', }); setSuccess(true); } catch { setError('Submission failed. Please try again.'); } finally { setLoading(false); } }; if (success) { return (
🙏
Thank you!
An agent will call you shortly on {phone}.
We typically respond within 30 minutes during business hours.
); } return (
Get in touch
Leave your details and we'll call you back.
{error &&
{error}
}
setName(e.target.value)} />
setPhone(e.target.value)} />