Users with BO_DASHBOARD get period presets, capture and win tiles, the status funnel, a captures/wins trend and breakdowns by event, salesperson and interest; everyone else keeps the welcome. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
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<LeadDashboard> {
|
|
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<LeadDashboard>(`/api/dashboard/leads${s ? `?${s}` : ""}`);
|
|
}
|