import { useMemo } from 'react'; import { cx } from '@/utils/cx'; import type { Lead } from '@/types/entities'; interface LeadFunnelProps { leads: Lead[]; } type FunnelStage = { label: string; count: number; color: string; }; export const LeadFunnel = ({ leads }: LeadFunnelProps) => { const stages = useMemo((): FunnelStage[] => { const total = leads.length; const contacted = leads.filter((lead) => lead.leadStatus === 'CONTACTED' || lead.leadStatus === 'QUALIFIED' || lead.leadStatus === 'NURTURING' || lead.leadStatus === 'APPOINTMENT_SET' || lead.leadStatus === 'CONVERTED', ).length; const appointmentSet = leads.filter((lead) => lead.leadStatus === 'APPOINTMENT_SET' || lead.leadStatus === 'CONVERTED', ).length; const converted = leads.filter((lead) => lead.leadStatus === 'CONVERTED', ).length; return [ { label: 'Generated', count: total, color: 'bg-brand-600' }, { label: 'Contacted', count: contacted, color: 'bg-brand-500' }, { label: 'Appointment Set', count: appointmentSet, color: 'bg-brand-400' }, { label: 'Converted', count: converted, color: 'bg-success-500' }, ]; }, [leads]); const maxCount = stages[0]?.count || 1; return (