// page-contact.jsx — "Get in touch" const PORTAL = 'https://peacefulheartsdpc.atlas.md'; // Auto-format a US phone as you type: (555) 123-4567 (matches the enroll form). const formatPhone = (v) => { let d = (v || '').replace(/\D/g, ''); if (d.length > 10 && d[0] === '1') d = d.slice(1); d = d.slice(0, 10); if (d.length < 4) return d; if (d.length < 7) return `(${d.slice(0, 3)}) ${d.slice(3)}`; return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}`; }; function ContactForm() { const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [phone, setPhone] = useState(''); const [message, setMessage] = useState(''); const [company, setCompany] = useState(''); // honeypot const [status, setStatus] = useState('idle'); // idle | sending | sent | error const [errMsg, setErrMsg] = useState(''); const submit = async (e) => { e.preventDefault(); if (!name.trim() || !email.trim() || !message.trim()) { setErrMsg('Please fill in your name, email, and message.'); setStatus('error'); return; } if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) { setErrMsg('Please enter a valid email address.'); setStatus('error'); return; } setStatus('sending'); setErrMsg(''); try { const res = await fetch('api/send.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ type: 'contact', name: name.trim(), email: email.trim(), phone: phone.trim(), message: message.trim(), company }), }); const data = await res.json().catch(() => ({})); if (res.ok && data.ok) { setStatus('sent'); } else { setErrMsg(data.error || 'Something went wrong sending your message. Please try again.'); setStatus('error'); } } catch (err) { setErrMsg('We couldn’t reach the server. Please email info@peacefulheartsdirect.com.'); setStatus('error'); } }; if (status === 'sent') { return (
We’ll be in touch within one business day.
The fastest way to reach your provider is the secure patient portal.
Open patient portal ↗Share your details and Azra will reach out personally. No commitment to start.
Become a member