import { getLeadsNeedingFollowUp } from "@/lib/lead-service"; import Link from "next/link"; const MAX_ROWS = 4; function initials(name: string): string { const parts = name.trim().split(/\s+/).filter(Boolean); if (parts.length === 0) return "?"; if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase(); return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); } function relativeDays(date: Date | string | null | undefined): string | null { if (!date) return "Mai contattato"; const d = date instanceof Date ? date : new Date(date); const diffMs = Date.now() - d.getTime(); const days = Math.floor(diffMs / (1000 * 60 * 60 * 24)); if (days <= 0) return "Contattato oggi"; if (days === 1) return "Contattato ieri"; return `Contattato ${days} giorni fa`; } export async function FollowUpWidget() { const leads = await getLeadsNeedingFollowUp(7); if (leads.length === 0) { return (

Follow-up

Tutti i lead sono aggiornati โœ“

); } const visible = leads.slice(0, MAX_ROWS); return (
{/* Header */}

Follow-up

{leads.length}
Vedi tutti โ†’
{/* Lead rows */} {leads.length > MAX_ROWS && ( Vedi tutti i {leads.length} lead )}
); }