door knock and referral attribution

This commit is contained in:
Satyam-Rastogi
2026-05-14 12:15:46 +05:30
parent 8157608ff0
commit 5aff14323c
4 changed files with 287 additions and 1 deletions
+12 -1
View File
@@ -69,6 +69,9 @@ const SECTIONS = [
const INITIAL_FORM = {
// Job Details
leadSource: '',
canvasserId: '',
canvasserName: '',
referralNote: '',
leadType: '',
workType: '',
tradeType: '',
@@ -156,7 +159,14 @@ export default function CreateLeadPage() {
}, [progress]);
const updateField = (field, value) => {
setFormData(prev => ({ ...prev, [field]: value }));
setFormData(prev => {
const next = { ...prev, [field]: value };
if (field === 'leadSource') {
if (value !== 'Door Knock') { next.canvasserId = ''; next.canvasserName = ''; }
if (value !== 'Referral') { next.referralNote = ''; }
}
return next;
});
};
const toggleSection = (id) => {
@@ -173,6 +183,7 @@ export default function CreateLeadPage() {
if (!formData.address) missingFields.push('Street Address');
if (!formData.city) missingFields.push('City');
if (!formData.leadSource) missingFields.push('Lead Source');
if (formData.leadSource === 'Door Knock' && !formData.canvasserId) missingFields.push('Canvasser');
if (missingFields.length > 0) {
setValidationError(`Required: ${missingFields.join(', ')}`);