From eb34ec4cb3db9b766dfec5f1510025d16402476f Mon Sep 17 00:00:00 2001 From: Satyam-Rastogi Date: Fri, 15 May 2026 14:30:37 +0530 Subject: [PATCH] responsive new lead forms --- src/components/leads/LeadPropertySection.jsx | 2 +- src/pages/CreateLeadPage.jsx | 35 +++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/components/leads/LeadPropertySection.jsx b/src/components/leads/LeadPropertySection.jsx index 0228e0f..7fcdbb9 100644 --- a/src/components/leads/LeadPropertySection.jsx +++ b/src/components/leads/LeadPropertySection.jsx @@ -198,7 +198,7 @@ export default function LeadPropertySection({ formData, updateField, isQuickCapt {/* Photo thumbnails */} {(formData.propertyPhotos || []).length > 0 && ( -
+
{(formData.propertyPhotos || []).map(photo => ( { - setOpenSections(prev => ({ ...prev, [id]: !prev[id] })); + setOpenSections(prev => { + const isOpening = !prev[id]; + const next = Object.keys(prev).reduce((acc, key) => { + acc[key] = false; + return acc; + }, {}); + next[id] = isOpening; + return next; + }); }; const handleSave = () => { @@ -187,13 +195,16 @@ export default function CreateLeadPage() { if (missingFields.length > 0) { setValidationError(`Required: ${missingFields.join(', ')}`); - // Open the first incomplete section + // Open the first incomplete section (close others for accordion behavior) + const openOnly = (id) => setOpenSections(prev => + Object.keys(prev).reduce((acc, key) => ({ ...acc, [key]: key === id }), {}) + ); if (!formData.firstName || !formData.lastName || !formData.phones.some(p => p.number.replace(/\D/g, '').length >= 10)) { - setOpenSections(prev => ({ ...prev, contact: true })); + openOnly('contact'); } else if (!formData.address || !formData.city) { - setOpenSections(prev => ({ ...prev, property: true })); + openOnly('property'); } else { - setOpenSections(prev => ({ ...prev, job: true })); + openOnly('job'); } toast.error(`Missing required fields: ${missingFields.join(', ')}`); return; @@ -288,7 +299,7 @@ export default function CreateLeadPage() { {/* ---------------------------------------------------------------- Page content ---------------------------------------------------------------- */} -
+
{/* --- Page Header --- */}
@@ -301,13 +312,13 @@ export default function CreateLeadPage() { Leads -
+
{/* Title */} -
-

+
+

New Lead

-

+

{isQuickCapture ? 'Essential fields only — fastest capture at the door.' : 'Full lead profile with insurance and assignment details.'} @@ -315,7 +326,7 @@ export default function CreateLeadPage() {

{/* Quick / Full Form toggle */} -