import { Calendar, Clock, PawPrint, CreditCard, Star, ChevronRight, AlertTriangle } from "lucide-react"; import { PETS, UPCOMING_APPOINTMENTS, PAST_APPOINTMENTS, INVOICES, LOYALTY, BUSINESS_NAME } from "../mockData.js"; interface Props { onNavigate: (section: "appointments" | "pets" | "billing" | "reports") => void; readOnly: boolean; } function daysUntil(dateStr: string): number { const now = new Date(); now.setHours(0, 0, 0, 0); const target = new Date(dateStr); target.setHours(0, 0, 0, 0); return Math.ceil((target.getTime() - now.getTime()) / (1000 * 60 * 60 * 24)); } function formatDate(dateStr: string): string { return new Date(dateStr).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" }); } export function Dashboard({ onNavigate, readOnly }: Props) { const nextAppt = UPCOMING_APPOINTMENTS[0]; const outstanding = INVOICES.filter(i => i.status === "outstanding").reduce((sum, i) => sum + i.amount, 0); const recentEvents = [ ...PAST_APPOINTMENTS.slice(0, 3).map(a => ({ id: a.id, date: a.date, text: `${a.petName} — ${a.services.join(", ")}`, type: "appointment" as const, })), ...INVOICES.filter(i => i.status === "paid").slice(0, 2).map(i => ({ id: i.id, date: i.date, text: `Invoice paid — $${i.amount}`, type: "payment" as const, })), ].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()).slice(0, 5); return (
{/* Welcome */}

Welcome back, Sarah

Here's what's happening at {BUSINESS_NAME}

{/* Next Appointment */} {nextAppt && (
Next Appointment
{nextAppt.status}

{nextAppt.petName} with {nextAppt.groomerName}

{nextAppt.services.join(", ")} {nextAppt.addOns.length > 0 && ` + ${nextAppt.addOns.join(", ")}`}

{formatDate(nextAppt.date)} {nextAppt.time}
{daysUntil(nextAppt.date)}
days away
{!readOnly && (
)}
)} {/* Pet Cards & Loyalty */}
{/* Pet Cards */} {PETS.map(pet => { const expiringVax = pet.vaccinations.filter(v => v.status !== "valid"); return ( ); })} {/* Loyalty Card */}
Loyalty Rewards

{LOYALTY.points} pts

{LOYALTY.nextRewardAt - LOYALTY.points} pts to {LOYALTY.rewardName}

{/* Outstanding Balance & Recent Activity */}
{/* Outstanding Balance */} {outstanding > 0 && (
Outstanding Balance

${outstanding.toFixed(2)}

{!readOnly && ( )}
)} {/* Recent Activity */}

Recent Activity

{recentEvents.map(evt => (
{evt.text} {formatDate(evt.date)}
))}
); }