import type { BangAggregatesDto } from "../server/queries"; type Props = { aggregates: BangAggregatesDto; }; export function BangStatsWidget({ aggregates }: Props) { const recentMonths = aggregates.monthlyCounts.slice(-6); return (
{recentMonths.length > 0 ? (

Recent months

{recentMonths.map((row) => (
{formatMonth(row.month)} {row.count}
))}
) : (

No bangs recorded yet.

)}
); } function StatBlock({ label, value }: { label: string; value: string }) { return (
{label}
{value}
); } function formatMonth(monthKey: string): string { const [year, month] = monthKey.split("-").map(Number); return new Date(year!, month! - 1, 1).toLocaleDateString(undefined, { month: "short", year: "numeric", }); }