"use client"; import { useQuery } from "convex/react"; import type { FunctionReturnType } from "convex/server"; import { ArrowRight, Building2, MapPin } from "lucide-react"; import Link from "next/link"; import { api } from "@/convex/_generated/api"; import { groupLeadFunnelCards, type LeadFunnelCard, type LeadFunnelStageId, } from "@/lib/dashboard-model"; import { cn } from "@/lib/utils"; type LeadFunnelQueryResult = FunctionReturnType; const stageActionHref: Record = { missing_contact: "/dashboard/leads", audit_ready: "/dashboard/audits", review_open: "/dashboard/outreach", contacted: "/dashboard/outreach", follow_up: "/dashboard/outreach", deferred: "/dashboard/leads", }; export function LeadFunnelBoard() { const leads: LeadFunnelQueryResult | undefined = useQuery( api.leads.listFunnel, { limit: 100 }, ); if (leads === undefined) { return ; } const groups = groupLeadFunnelCards(leads); const totalCards = groups.reduce((total, group) => total + group.cards.length, 0); if (totalCards === 0) { return (

Lead-Funnel

Noch keine Leads im Arbeitsfluss

Sobald Kampagnen Leads erzeugen oder importieren, erscheinen sie hier nach Kontaktlage, Audit-Stand und Review-Bedarf sortiert.

); } return (

Lead-Funnel

{totalCards} Leads nach Kontaktlage, Audit-Stand und nächster manueller Aktion.

Kein automatischer Versand

{groups.map((group) => (

{group.stage.title}

{group.cards.length}

{group.stage.description}

{group.cards.length > 0 ? ( group.cards.map((card) => ( )) ) : (

Keine Leads in dieser Spalte.

)}
))}
); } function LeadFunnelCardView({ card }: { card: LeadFunnelCard }) { return (

{card.company}

{card.niche}

{card.priorityLabel}

{card.location}

{card.contactStatusLabel} {card.contactDetail}
{card.nextAction}
); } function LeadFunnelSkeleton() { return (
{Array.from({ length: 6 }, (_, index) => (
))}
); }