);
}
const propertyTypes = [
{ value: '', label: 'Select property type' },
{ value: 'residential', label: 'Residential' },
{ value: 'commercial', label: 'Commercial' },
{ value: 'vacant-land', label: 'Vacant Land' },
{ value: 'investment', label: 'Investment Property' },
{ value: 'new-construction', label: 'New Construction' },
{ value: 'other', label: 'Other' },
];
const friendlyRequired = {
firstName: 'Please share your first name so we know who we\u2019re working with.',
lastName: 'Please share your last name so we know who we\u2019re working with.',
email: 'Please enter an email address so we can reach you.',
phone: 'Please enter a phone number so we can reach you.',
company: 'Please let us know your company name.',
sellerName: 'Please enter the seller\u2019s name.',
buyerName: 'Please enter the buyer\u2019s name.',
propertyType: 'Please choose the property type.',
propertyAddress: 'Please enter the property address so we know where to begin.',
city: 'Please enter the property city.',
zip: 'Please enter the property ZIP code.',
salesPrice: 'Please enter the sales price.',
};
const DENSITY = {
relaxed: { cardPad: 'var(--space-8) var(--space-7)', sectionGap: 'var(--space-7)', rowGap: 24, headingMb: 'var(--space-6)' },
efficient: { cardPad: 'var(--space-6) var(--space-6)', sectionGap: 'var(--space-5)', rowGap: 14, headingMb: 'var(--space-4)' },
};
function OrderForm({ onSubmitted, structure, densityKey }) {
const density = DENSITY[densityKey];
const [data, setData] = React.useState({
firstName: '', lastName: '', email: '', phone: '', company: '',
sellerName: '', buyerName: '', propertyType: '', propertyAddress: '', city: '', zip: '',
salesPrice: '', lender: '', loanAmount: '', contractLink: '', comments: '', smsOptIn: '',
});
const [files, setFiles] = React.useState([]);
const [errors, setErrors] = React.useState({});
const [submitting, setSubmitting] = React.useState(false);
const [submitError, setSubmitError] = React.useState('');
const fieldRefs = React.useRef({});
const set = (k) => (e) => setData((d) => ({ ...d, [k]: e.target.value }));
const setMoney = (k) => (e) => setData((d) => ({ ...d, [k]: liveCurrency(e.target.value) }));
const validate = () => {
const next = {};
Object.keys(friendlyRequired).forEach((k) => { if (!String(data[k]).trim()) next[k] = friendlyRequired[k]; });
setErrors(next);
return next;
};
const handleSubmit = (e) => {
e.preventDefault();
const next = validate();
const firstKey = Object.keys(friendlyRequired).find((k) => next[k]);
if (firstKey) {
fieldRefs.current[firstKey]?.scrollIntoView({ behavior: 'smooth', block: 'center' });
return;
}
setSubmitting(true);
setSubmitError('');
const form = new FormData();
form.append('form_type', 'order-title');
Object.entries(data).forEach(([k, v]) => form.append(k, v));
files.forEach((f) => form.append('files[]', f));
fetch('submit-form.php', { method: 'POST', body: form })
.then((r) => r.json())
.then((res) => { setSubmitting(false); if (res.success) { onSubmitted({ ...data, files }); } else { setSubmitError(res.message || 'Something went wrong. Please try again.'); } })
.catch(() => { setSubmitting(false); setSubmitError('Something went wrong. Please try again or reach us by phone.'); });
};
const reg = (k) => (el) => { fieldRefs.current[k] = el; };
const sections = (
By opting in, you agree to receive text messages from Acorn Title related to your transaction. Message and data rates may apply. Message frequency varies. Reply STOP to opt out or HELP for help at any time.
We've received your request and a member of our team will begin reviewing your order immediately. You can expect someone from our office to reach out shortly to confirm the details and guide you through the next steps.
Opening a transaction with Acorn is simple. Submit the information below, upload your contract, and our team will begin working on your file right away. We'll confirm your order promptly and guide you through every step of the closing process.