'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import { crmService, CrmLead } from '@/services/api/crmService'; import { Phone, Mail, ArrowRight, MessageSquare, Clock, Sparkles, LayoutGrid, List } from 'lucide-react'; import { toast } from 'sonner'; export default function ContactedLeadsPage() { const router = useRouter(); const [leads, setLeads] = useState([]); const [loading, setLoading] = useState(true); const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid'); useEffect(() => { loadLeads(); }, []); const loadLeads = async () => { try { setLoading(true); const data = await crmService.getLeads('CONTACTED'); setLeads(data || []); } catch (err) { setLeads([]); } finally { setLoading(false); } }; const handleAdvanceToQualified = async (lead: CrmLead) => { try { await crmService.updateLeadStatus(lead.lead_id, 'QUALIFIED'); toast.success(`Moved lead "${lead.title || lead.phone}" to Qualified stage!`); router.push('/crm-leads/qualified'); } catch (err) { toast.error('Failed to update lead status'); } }; return (
Stage 2 of 5

2. Contacted Leads

Leads where staff have initiated outreach via Call or WhatsApp Web

{loading ? (
Loading Contacted Leads...
) : leads.length === 0 ? (

No contacted leads currently in this stage

Move new inquiries here after reaching out on WhatsApp or phone call.

) : viewMode === 'grid' ? (
{leads.map((lead) => { const cleanPhone = lead.phone ? lead.phone.replace(/[^0-9]/g, '') : ''; return (

{lead.title || lead.first_name || 'Contacted Inquiry'}

CONTACTED
{lead.phone && (
{lead.phone} {cleanPhone && ( )}
)} {lead.email && (
{lead.email}
)}
Source: {lead.source} {new Date(lead.created_at).toLocaleDateString()}
Verify details & budget
); })}
) : (
{leads.map((lead) => { const cleanPhone = lead.phone ? lead.phone.replace(/[^0-9]/g, '') : ''; return ( ); })}
Inquiry Title / Customer Phone / OpenWA Chat Email Address Source Contacted Date Action
{lead.title || lead.first_name || 'Contacted Inquiry'}
{lead.phone || '—'} {cleanPhone && ( )}
{lead.email || '—'} {lead.source} {new Date(lead.created_at).toLocaleDateString()}
)}
); }