import { apiGet } from "@/app/lib/clientApi"; export interface LeadDashboard { from: string; to: string; bucket: "DAY" | "MONTH"; captures: number; newLeads: number; wonInPeriod: number; medianDaysToWin: number | null; overdueFollowUps: number; funnel: { OPEN: number; CONTACTED: number; QUALIFIED: number; WON: number; LOST: number }; trend: { bucket: string; captures: number; wins: number }[]; events: { eventUuid: string; name: string; companyId: number; captures: number; newLeads: number; won: number }[]; salespeople: { userId: number | null; name: string | null; assigned: number; worked: number; won: number; lost: number; overdue: number }[]; interests: { interestId: number; name: string; captures: number; won: number }[]; } export interface LeadDashboardParams { from?: string; to?: string; companyId?: number; } export function getLeadDashboard({ from, to, companyId }: LeadDashboardParams): Promise { const qs = new URLSearchParams(); if (from) qs.set("from", from); if (to) qs.set("to", to); if (companyId) qs.set("companyId", String(companyId)); const s = qs.toString(); return apiGet(`/api/dashboard/leads${s ? `?${s}` : ""}`); }