Tenant Leads (Global)
1. Purpose & Context (The âWhyâ)
-
Goal: Centralized management of all contacts/leads across the tenantâs account, regardless of which workspace they belong to.
-
Feature References:
- Lead Management (Segmentation)
-
User Journey: Import leads â Segment them â Assign to Campaigns.
2. UI Patterns & Components (The âHowâ)
-
Core Components:
-
DataTable: High-performance table for large datasets. Needs âSelect Allâ, âBulk Actionsâ. -
FilterBuilder: Complex filtering UI (e.g., âIndustry IS Tech AND Status IS NOT Bouncedâ). -
SlideOver: For quick view of Lead Details without leaving the table.
-
-
Analytics Patterns: N/A.
-
Layout: Global Context.
3. Route Specifications
| Route | Access | Purpose | State/Data Requirements |
|---|---|---|---|
/dashboard/leads | Tenant | All Leads | Server Component. Heavy data view. Server-side pagination/sorting. Bulk Actions: âAdd to Campaignâ, âDeleteâ, âExportâ. |
/dashboard/leads/[id] | Tenant | Lead Profile | Client Component (or Page). Shows timeline of interactions (Emails sent, Replies, Opens). Editable fields. |
/dashboard/leads/segments | Tenant | Segments | List of saved dynamic segments. |
/dashboard/leads/lists | Tenant | Static Lists | List of static uploaded lists. Upload CSV modal. |
4. Detailed View Descriptions
/dashboard/leads - Global Leads Database
User Story: âAs a sales manager, I want to see all my leads in one place with filtering and bulk actions, so I can efficiently manage my entire contact database.â
What Youâll Find:
-
Header Actions:
-
âImport Leadsâ Button: Opens modal with CSV upload (drag-and-drop).
-
â Exportâ Button: Downloads filtered view as CSV.
-
Search Bar: Search by name, email, company.
-
-
Filter Panel (Left Sidebar or Collapsible):
-
Quick Filters: All Leads, Recently Added, Engaged, Bounced.
-
Advanced Filter Builder:
-
Add conditions: âIndustryâ, âStatusâ, âLast Contact Dateâ, etc.
-
Logic: AND/OR operators.
-
Save as Segment button.
-
-
-
Data Table (see Analytics UI Patterns):
-
Columns: Name, Email, Company, Status, Last Contact, Tags, Actions.
-
Status Icons: Active, Sent, Opened, Replied, Bounced.
-
Checkbox Column: Select for bulk actions.
-
Pagination: Server-side, 50 leads/page.
-
-
Bulk Actions Bar (appears when rows selected):
- âAdd to Campaignâ, âAdd Tagâ, âExport Selectionâ, âDeleteâ.
-
Empty State: âImport your first leadsâ with sample CSV download link.
User Journey Context: Central hub for lead management. High-frequency access.
Related Documentation:
Technical Integration:
-
Virtualized Scrolling: For tables with 10,000+ leads.
-
Server-side Pagination: Fetches only visible page from database.
-
Export Job: Large exports (>1000 leads) run via background job, email download link.
/dashboard/leads/[id] - Lead Profile
User Story: âAs a salesperson, I want to see a leadâs complete interaction history, so I can personalize my outreach and avoid redundant messaging.â
What Youâll Find:
-
Lead Header:
-
Name (editable inline).
-
Company (editable).
-
Tags: Pill-style tags with â+â to add new.
-
Status Dropdown: Active, Interested, Not Interested, Bounced.
-
-
Contact Information Section:
- Email (primary), Phone, LinkedIn URL (all editable).
-
Activity Timeline (Vertical, Chronological):
-
Icons for each event type:
-
Email Sent (from Campaign X).
-
Email Opened (timestamp).
-
Link Clicked (which link).
-
Replied (shows reply preview).
-
-
âView Full Emailâ expandable.
-
-
Custom Fields Section:
-
User-defined fields (e.g., âIndustryâ, âCompany Sizeâ).
-
â+ Add Fieldâ Button.
-
-
Actions Panel (Right Sidebar):
-
âAdd to Campaignâ Button.
-
âSend One-off Emailâ Button (quick compose).
-
âDelete Leadâ (with confirmation).
-
User Journey Context: Detailed view for high-value leads. Accessed before personalized outreach.
Related Documentation:
Technical Integration:
-
Real-time Activity: Subscribes to lead activity events via WebSocket.
-
Optimistic Updates: Field edits reflected immediately, synced asynchronously.
/dashboard/leads/segments - Dynamic Segments
User Story: âAs a marketer, I want to create reusable segments based on lead behavior, so I can target specific groups with tailored campaigns.â
What Youâll Find:
-
Segment List:
-
Card Layout: Each segment shows Name, Lead Count, Last Updated.
-
âCreate Segmentâ Button (top-right).
-
-
Create Segment Modal:
-
Segment Name: Input field.
-
Filter Builder (same as Lead List advanced filters):
- Example: âOpened email in last 30 days AND Industry = SaaSâ.
-
Live Preview: Shows lead count matching criteria.
-
Save Button.
-
-
Segment Card Actions:
-
View Leads: Redirects to
/dashboard/leads?segment=[id]. -
Edit: Modify filter criteria.
-
Use in Campaign: Quick action to create campaign with this segment.
-
User Journey Context: Advanced feature for power users. Enables sophisticated targeting.
Related Documentation:
Technical Integration:
-
Dynamic Queries: Segments stored as JSON filter definitions, executed on query.
-
Caching: Segment lead counts cached for 5 minutes.
/dashboard/leads/lists - Static Lists
User Story: âAs a user, I want to upload a CSV of leads for a specific campaign, so I can quickly target an external list.â
What Youâll Find:
-
List Cards:
-
Name, Lead Count, Upload Date.
-
âUpload New Listâ Button.
-
-
Upload Modal:
-
Drag-and-drop CSV: Shows file name and size.
-
Column Mapping:
-
âMap CSV columns to lead fields (Email, First Name, etc.).â
-
Auto-detection for common headers.
-
-
Preview: First 5 rows with mapped fields.
-
âImportâ Button: Starts background job for large lists.
-
Migration Tools:
- âImporting from Mailchimp/ActiveCampaign?â
- âUse Migration Wizardâ Link: Redirects to specialized migration flow.
-
-
List Actions:
-
View Leads: See all leads in this list.
-
Export: Download as CSV.
-
Delete: Remove list (with confirmation).
-
User Journey Context: One-time or periodic imports. Must handle large files gracefully.
Related Documentation:
Technical Integration:
-
Background Processing: Imports >1000 leads run via background queue system.
-
Duplicate Detection: Checks for existing emails, shows merge options.
-
Error Handling: Invalid rows logged, user gets summary email.
5. Related API Endpoints
| Route | Related API | Description |
|---|---|---|
/leads | Leads API | GET /api/v1/tenant/leads (List with filters), POST (Create). |
/leads/[id] | Leads API | GET /api/v1/tenant/leads/{id} (Details & Activity). |
/leads/segments | Leads API | GET /api/v1/tenant/leads/segments. |
/leads/import | Leads API | POST /api/v1/tenant/leads/import (Bulk Import). |
Related Documentation
Planning & Strategy
-
Lead Management README - Feature area overview with MVP status
-
Lead Management Roadmap - Detailed timeline and quarterly breakdown
-
Product Roadmap - Overall product timeline
-
Executive Roadmap - Strategic feature delivery
Feature Documentation
-
Leads Management - Core contact database
-
Contact Segmentation - Dynamic and static segmentation
-
Import/Export - Bulk contact operations
-
Lead Scoring - Behavioral and demographic scoring
Implementation Tasks
- Epic 7: Leads Management - Internal task reference for implementation breakdown
Related Features
-
Campaign Management - Use segments in campaigns
-
Inbox Management - Reply management linked to contacts
-
Integrations - CRM integrations (Post-MVP)
6. Data Strategy
-
Fetching Method:
-
Leads Table: Server Component with searchParams. Returns
dataarray +totalCount. -
Lead Profile: Server Component.
-
-
Caching:
-
Leads List: No caching (highly dynamic).
-
Segments: Cached for 5 minutes.
-
-
Pagination:
- Cursor-based pagination preferred for performance with >1M rows.
-
Optimistic Updates:
- âAdd Tagâ and âChange Statusâ update UI immediately.
7. Edge Cases & Error Handling
-
Import Failures:
-
Invalid CSV: Show row-by-row error report.
-
Threshold Exceeded: If import > Plan Limit, block and show upgrade modal.
-
-
Bulk Action Failures: If 5/100 updates fail, show â95 succeeded, 5 failedâ with retry option.
-
Empty Search: âNo leads found matching âxyzâ. Clear filters?â
8. Component Architecture
Page Components
-
LeadsDataGrid(Client Wrapper)-
Props:
initialData: Lead[],columns: ColumnDef[] -
Features: TanStack Table, server-side sorting/filtering hooks, row selection.
-
-
SegmentBuilder(Client)-
Complex query builder UI (AND/OR logic).
-
Output: JSON logic object for API.
-
-
LeadProfileDrawer(Client)-
Slide-over panel for lead details.
-
Sub-components:
LeadTimeline,LeadProperties,NotesWidget.
-
Shared Components
-
FilterBar: Reused in Campaigns and Logs. -
TagInput: Async select for adding/creating tags.