// Contact page — CRO-optimized lead form // ← Paste your Apps Script Web App URL here after deploying (see README / setup instructions) const WEBHOOK_URL = 'https://script.google.com/macros/s/AKfycbwvjYBBewj_rHSLQk0R3Sw9F559_EbvaqobuZbOa-w03_UjoLm_Ld4Z0yv9UXdH_8Jm/exec'; const { useState: useStateC } = React; const DIAL_CODES = [ { code: '+91', label: 'IN +91', country: 'India', min: 10, max: 10 }, { code: '+1', label: 'US +1', country: 'USA/Canada', min: 10, max: 10 }, { code: '+44', label: 'UK +44', country: 'UK', min: 10, max: 10 }, { code: '+971', label: 'AE +971', country: 'UAE', min: 9, max: 9 }, { code: '+61', label: 'AU +61', country: 'Australia', min: 9, max: 9 }, { code: '+65', label: 'SG +65', country: 'Singapore', min: 8, max: 8 }, { code: '+974', label: 'QA +974', country: 'Qatar', min: 8, max: 8 }, { code: '+965', label: 'KW +965', country: 'Kuwait', min: 8, max: 8 }, { code: '+968', label: 'OM +968', country: 'Oman', min: 8, max: 8 }, { code: '+973', label: 'BH +973', country: 'Bahrain', min: 8, max: 8 }, ]; const TYPO_TLDS = ['ocm','cmo','con','cpm','nte','ogr','coim','comn','cob','gmai','gamil','yahooo','gnail']; function validatePhone(digits, dialInfo) { if (!digits) return 'Phone number is required'; if (digits.length !== dialInfo.min) return `Enter a valid ${dialInfo.min}-digit mobile number`; if (dialInfo.code === '+91' && !/^[6-9]/.test(digits)) return 'Indian mobile numbers must start with 6, 7, 8 or 9'; // Reject all same digit: 9999999999 if (/^(.)\1+$/.test(digits)) return 'Enter a real mobile number'; // Reject sequential ascending / descending: 1234567890, 9876543210 const d = digits.split('').map(Number); const asc = d.every((n, i) => i === 0 || n === (d[i-1] + 1) % 10); const desc = d.every((n, i) => i === 0 || n === (d[i-1] - 1 + 10) % 10); if (asc || desc) return 'Enter a real mobile number'; return null; } function validateEmail(v) { const s = v.trim().toLowerCase(); if (!s) return 'Email is required'; const atIdx = s.lastIndexOf('@'); if (atIdx < 1) return 'Enter a valid email address'; const local = s.slice(0, atIdx); const domain = s.slice(atIdx + 1); if (!domain.includes('.')) return 'Enter a valid email address'; const parts = domain.split('.'); const tld = parts[parts.length - 1]; const host = parts[parts.length - 2] || ''; if (!/^[a-z]{2,10}$/.test(tld)) return 'Enter a valid email address'; if (host.length < 2) return 'Enter a valid email address'; if (local.length < 2 || /^(.)\1+$/.test(local)) return 'Enter a valid email address'; if (TYPO_TLDS.includes(tld)) { const fix = ['ocm','cmo','cob','comn','coim'].includes(tld) ? 'com' : tld === 'nte' ? 'net' : ['ogr','org'].includes(tld) ? 'org' : 'com'; return `Did you mean .${fix}? Please check your email`; } return null; } const ContactHero = () => (
Begin · A Conversation

Start with a
single question.

Tell us what you're imagining — a home, an investment, a brand collaboration — and we'll bring the rest.

); const Field = ({ label, error, ...rest }) => ( ); const ContactForm = () => { const [intent, setIntent] = useStateC('Investor'); const [dialCode, setDialCode] = useStateC('+91'); const [phone, setPhone] = useStateC(''); const [errors, setErrors] = useStateC({}); const [submitting, setSubmitting] = useStateC(false); const [done, setDone] = useStateC(false); const [err, setErr] = useStateC(null); const dialInfo = DIAL_CODES.find(d => d.code === dialCode) || DIAL_CODES[0]; const handlePhoneInput = (e) => { const digits = e.target.value.replace(/\D/g, '').slice(0, dialInfo.max); setPhone(digits); if (errors.phone) setErrors(prev => ({ ...prev, phone: null })); }; const handleDialChange = (e) => { setDialCode(e.target.value); setPhone(''); setErrors(prev => ({ ...prev, phone: null })); }; const handlePhoneBlur = () => { const phoneErr = validatePhone(phone, dialInfo); setErrors(prev => ({ ...prev, phone: phoneErr })); }; const handleEmailBlur = (e) => { const emailErr = validateEmail(e.target.value); setErrors(prev => ({ ...prev, email: emailErr })); }; const handleEmailChange = () => { if (errors.email) setErrors(prev => ({ ...prev, email: null })); }; const submit = async (e) => { e.preventDefault(); if (submitting) return; const fd = new FormData(e.currentTarget); const newErrors = {}; const phoneErr = validatePhone(phone, dialInfo); if (phoneErr) newErrors.phone = phoneErr; const emailErr = validateEmail(fd.get('email') || ''); if (emailErr) newErrors.email = emailErr; if (Object.keys(newErrors).length > 0) { setErrors(newErrors); return; } setSubmitting(true); setErr(null); setErrors({}); const payload = Object.fromEntries(fd.entries()); payload.phone = `${dialCode} ${phone}`; payload.intent = intent; payload.source = 'amgrealty.in'; payload.submitted_at = new Date().toISOString(); try { await fetch(WEBHOOK_URL, { method: 'POST', mode: 'no-cors', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'lead_submit', ...payload }); setDone(true); } catch (ex) { setErr('Could not send. Please try again or call us directly.'); } finally { setSubmitting(false); } }; if (done) { return (

Thank you.

A member of our team will be in touch within one working day.

); } return (
{['Investor', 'Residence', 'Brand Partner', 'Press'].map((t) => ( ))}
{/* Phone — country code selector + digits-only input */}
Phone
{phone.length}/{dialInfo.min}
{errors.phone && {errors.phone}}