added update from code pull new changes now

This commit is contained in:
Ace
2026-06-19 10:19:57 +02:00
parent e5726fdbb2
commit 571af27f50
3 changed files with 237 additions and 6 deletions
+36
View File
@@ -38,6 +38,40 @@ export function getDashboardStats(period: string): DashboardStats {
]
}
const monthlyBreakdown = groupLeadsByInterval(filtered, period).map(m => ({
label: m.label,
total: m.leads,
open: 0,
contacted: 0,
pending: 0,
closed: m.closed,
ignored: 0,
}))
const trendVal = (current: number, prev: number) => ({
pct: prev > 0 ? Math.round(((current - prev) / prev) * 100) : current > 0 ? 100 : 0,
up: current >= prev,
})
const prevFiltered = filterLeadsByPeriod(leads, period === "7days" ? "30days" : "7days")
const prevTotal = prevFiltered.length
const prevOpen = prevFiltered.filter((l) => l.status === "open").length
const prevContacted = prevFiltered.filter((l) => l.status === "contacted").length
const prevPending = prevFiltered.filter((l) => l.status === "pending").length
const prevClosed = prevFiltered.filter((l) => l.status === "closed").length
const prevIgnored = prevFiltered.filter((l) => l.status === "ignored").length
const prevConversion = prevTotal > 0 ? Math.round((prevClosed / prevTotal) * 100) : 0
const trends = {
totalLeads: trendVal(totalLeads, prevTotal),
openLeads: trendVal(openLeads, prevOpen),
contactedLeads: trendVal(contactedLeads, prevContacted),
pendingLeads: trendVal(pendingLeads, prevPending),
closedLeads: trendVal(closedLeads, prevClosed),
ignoredLeads: trendVal(ignoredLeads, prevIgnored),
conversionRate: trendVal(conversionRate, prevConversion),
}
return {
totalLeads,
openLeads,
@@ -46,9 +80,11 @@ export function getDashboardStats(period: string): DashboardStats {
closedLeads,
ignoredLeads,
conversionRate,
monthlyBreakdown,
leadsPerMonth: groupLeadsByInterval(filtered, period),
recentLeads: filtered.slice(0, 10),
statusDistribution: getStatusDistribution(),
periodLabel: label,
trends,
}
}