fix(data): seed leads list so the Leads page is populated on load
This commit is contained in:
+56
-1
@@ -5947,6 +5947,61 @@ const MOCK_NOTIFICATIONS = [
|
||||
},
|
||||
];
|
||||
|
||||
// --- SEED HELPERS ---
|
||||
|
||||
/**
|
||||
* Maps MOCK_STORM_ATTRIBUTION_LEADS into the shape LeadsListPage expects.
|
||||
* Field coverage:
|
||||
* id, firstName, lastName, address, city, state,
|
||||
* urgency, status, leadSource, stormSource (truthy obj),
|
||||
* phones[{ number, isPrimary }],
|
||||
* canvasserName, createdByName, createdAt
|
||||
*/
|
||||
function seedLeadsFromAttribution() {
|
||||
const canvassers = [
|
||||
'Cody Tatum',
|
||||
'Hannah Reyes',
|
||||
'Travis Boone',
|
||||
'Shelby Greer',
|
||||
'Dalton Pruitt',
|
||||
];
|
||||
const creators = [
|
||||
'Hannah Reyes',
|
||||
'Travis Boone',
|
||||
'Cody Tatum',
|
||||
'Shelby Greer',
|
||||
'Dalton Pruitt',
|
||||
];
|
||||
// Deterministic assignment based on SAL index so output is stable.
|
||||
return MOCK_STORM_ATTRIBUTION_LEADS.map((sal, idx) => {
|
||||
const canvasserName = canvassers[idx % canvassers.length];
|
||||
const createdByName = creators[(idx + 2) % creators.length];
|
||||
// Build a realistic phone number from the index
|
||||
const areaCode = idx % 2 === 0 ? '469' : '972';
|
||||
const mid = String(500 + idx).padStart(3, '0');
|
||||
const last = String(1000 + idx * 37).padStart(4, '0').slice(-4);
|
||||
const phoneNumber = `(${areaCode}) ${mid}-${last}`;
|
||||
|
||||
return {
|
||||
id: sal.id,
|
||||
firstName: sal.firstName,
|
||||
lastName: sal.lastName,
|
||||
address: sal.address,
|
||||
city: sal.city,
|
||||
state: sal.state,
|
||||
urgency: sal.urgency,
|
||||
status: sal.status,
|
||||
leadSource: sal.leadSource,
|
||||
stormSource: sal.stormSource, // truthy object — renders Storm Zone badge
|
||||
createdAt: sal.createdAt,
|
||||
canvasserName,
|
||||
createdByName,
|
||||
phones: [{ number: phoneNumber, isPrimary: true }],
|
||||
isQuickCapture: false,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// --- CONTEXT SETUP ---
|
||||
|
||||
const MockStoreContext = createContext();
|
||||
@@ -5965,7 +6020,7 @@ export const MockStoreProvider = ({ children }) => {
|
||||
const [projects, setProjects] = useState(MOCK_PROJECTS);
|
||||
const [orders, setOrders] = useState(MOCK_ORDERS);
|
||||
const [vendorInvoices, setVendorInvoices] = useState(MOCK_VENDOR_INVOICES);
|
||||
const [leads, setLeads] = useState([]);
|
||||
const [leads, setLeads] = useState(() => seedLeadsFromAttribution());
|
||||
const [dispatchLeads, setDispatchLeads] = useState(DISPATCH_LEADS_INITIAL);
|
||||
const [templates, setTemplates] = useState(MASTER_TEMPLATES_INITIAL);
|
||||
const [estimates, setEstimates] = useState(MOCK_ESTIMATES_INITIAL);
|
||||
|
||||
Reference in New Issue
Block a user