import { Activity, AlertTriangle, CalendarDays, ChevronRight, PoundSterling, TimerReset } from "lucide-react"; import { Area, AreaChart, CartesianGrid, Cell, Pie, PieChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import { MATERIAL_ACCENTS } from "../../data/accents"; import type { QuickAddItem } from "../../data/quickAdds"; import { currency, humanDateTime, spendFor } from "../../lib/metrics"; import { limitStatusMessage } from "../../lib/userLimits"; import { AppCard } from "../AppCard"; import { ChartTooltip } from "../ChartTooltip"; import { DailyLimitsCard } from "../DailyLimitsCard"; import { EmptyState } from "../EmptyState"; import { GreetingPanel } from "../GreetingPanel"; import { InsightCard } from "../InsightCard"; import { LegalFootnote } from "../LegalFootnote"; import { MetricTile } from "../MetricTiles"; import { QuickAddPanel } from "../QuickAddPanel"; import { Skeleton } from "../Skeleton"; import { TodayPanel } from "../TodayPanel"; import type { Dashboard, Insight } from "../../lib/dashboard"; import type { AuthUser, LimitCheckResult, RedBullEntry, UserLimits } from "../../types"; type OverviewViewProps = { summary: Dashboard; entries: RedBullEntry[]; insights: Insight[]; quickAdds: QuickAddItem[]; recentEntries: RedBullEntry[]; chartData: Array<{ label: string; spend: number; cans: number; caffeine: number; sugar: number }>; flavourData: Array<{ name: string; value: number; spend: number; accent: string }>; user: AuthUser; userLimits: UserLimits; limitCheck: LimitCheckResult; loading: boolean; onQuickAdd: (item: QuickAddItem) => void; onAdd: () => void; onScan: () => void; onOpenLogbook: () => void; onOpenSettings: () => void; }; export function OverviewView({ summary, entries, insights, quickAdds, recentEntries, chartData, flavourData, user, userLimits, limitCheck, loading, onQuickAdd, onAdd, onScan, onOpenLogbook, onOpenSettings, }: OverviewViewProps) { const todaySpendRaw = limitCheck.todaySpend; const showSkeleton = loading && entries.length === 0; const spendLimitDetail = userLimits.dailySpendLimit != null ? `${currency.format(todaySpendRaw)} of ${currency.format(userLimits.dailySpendLimit)} today` : `${summary.monthSpend} this month`; const chartTotalSpend = chartData.reduce((total, point) => total + point.spend, 0); const chartTotalCans = chartData.reduce((total, point) => total + point.cans, 0); const spendChartLabel = `Spend over the last ${chartData.length} logged days, total ${currency.format(chartTotalSpend)} across ${chartTotalCans} cans`; const flavourChartLabel = flavourData.length ? `Cans by flavour across ${flavourData.length} flavours. Most logged: ${flavourData[0].name}` : ""; return (
{limitCheck.violations.length ? (
) : null}
{showSkeleton ? ( Array.from({ length: 4 }, (_, index) => ) ) : ( <> )}
{showSkeleton ? ( ) : chartData.length ? (
} />
) : ( )}
{showSkeleton ? (
{Array.from({ length: 5 }, (_, index) => ( ))}
) : recentEntries.length ? (
{recentEntries.map((entry) => ( ))}
) : ( )}
{insights.map((insight) => ( ))}
{flavourData.length ? (
{flavourData.map((entry) => ( ))} } />
) : ( )}
); } function MiniEntry({ entry }: { entry: RedBullEntry }) { return (

{entry.flavour}

{humanDateTime(entry.dateTime)}

{currency.format(spendFor(entry))}

); }