WIP jordan

This commit is contained in:
Jordan Weingarten
2026-04-16 11:11:44 -05:00
parent ff2d7b18b5
commit 67482f6629
163 changed files with 50627 additions and 728 deletions

View File

@@ -0,0 +1,46 @@
/**
* Quick lead capture list — persisted in localStorage.
* Used by the Quick Lead form and dashboard widget.
*/
import { useLocalStorageRef } from '~/utils/useLocalStorageRef'
export interface QuickLead {
id: string
name: string
phone: string
email: string
product: string
source: string
priority: 'normal' | 'high' | 'urgent'
note: string
agent: string
createdAt: string
}
const KEY = 'policy-ui-quick-leads-v1'
export function useQuickLeads() {
const leads = useLocalStorageRef<QuickLead[]>(KEY, () => [])
function addLead(entry: Omit<QuickLead, 'id' | 'createdAt'>) {
const lead: QuickLead = {
id: crypto.randomUUID?.() ?? String(Date.now()),
createdAt: new Date().toISOString(),
...entry,
}
leads.value = [lead, ...leads.value]
return lead
}
function removeLead(id: string) {
leads.value = leads.value.filter((l) => l.id !== id)
}
/** Leads from the last N days */
function recentLeads(days: number) {
const cutoff = Date.now() - days * 86_400_000
return leads.value.filter((l) => new Date(l.createdAt).getTime() >= cutoff)
}
return { leads, addLead, removeLead, recentLeads }
}