Leads Management Module¶
Overview¶
Leads is the primary contact-management surface. It combines the shared DataTable stack, advanced search/filter state, lead detail panels, bulk actions, and several count/summary helpers.
Main Building Blocks¶
- Page entrypoint:
src/pages/Leads.tsx - Column registry and presets:
src/components/leads/config/ - Lead-specific cell renderers and controls:
src/components/leads/ - Search/filter plumbing:
src/services/searchFilterService.ts,src/services/searchService.ts,src/pages/Leads/hooks/
Current Capabilities¶
- Lead/customer search across many server-backed filter dimensions
- Broadcast-oriented bulk workflows
- Vehicle, status, communication, financial, and campaign column groupings
- Eligible lead summary cards and area-code saturation views
- Detail panels that tie the Leads module back into Message Center and downstream workflow modules
Area-Code Summary Implementation¶
The old root note about summarize_lead_area_codes is reflected in the current implementation:
- useEligibleLeadsCounts.ts always calls summarize_lead_area_codes
- Area counts are normalized into the UI buckets 480, 602, 623, 520, 928, and Other
- The database layer includes phone_to_area_code(...)
- The refactor goal of sharing filter logic through lead_search_phones(...) exists in archived migrations and schema evolution history
Important Reality Check¶
- The older root doc described the
lead_search_phonesrefactor plan as future work; in this repo, that work has already been folded into the migration history and the current counts path assumes the summarized RPC is the source of truth - Lead summary counts are tightly coupled to backend RPC parameters; any filter changes should update both the table search contract and the summarize RPC contract together
Integration Points¶
- Broadcasts consume lead targeting and campaign-lead search flows
- Message Center uses lead identity, phone, opportunity, and thread relationships
- Jobs/work orders depend on lead, vehicle, and billing/opportunity records