"use client"; import { BarChart3 } from "lucide-react"; import { useSessions } from "@/lib/hooks"; import { formatTokens } from "@/lib/utils"; export function StatsCard() { const { data } = useSessions(50); const items = data?.items || []; const total = data?.total || 0; const totalTokens = items.reduce((s, i) => s + i.input_tokens + i.output_tokens, 0); const totalCost = items.reduce((s, i) => s + (i.estimated_cost_usd || 0), 0); const platforms = new Set(items.map((i) => i.source)); const stats = [ { label: "Sessions", value: String(total) }, { label: "Tokens (recent)", value: formatTokens(totalTokens) }, { label: "Platforms", value: String(platforms.size) }, ...(totalCost > 0 ? [{ label: "Est. Cost", value: "$" + totalCost.toFixed(2) }] : []), ]; return (
Stats
{stats.map((s) => (
{s.value}
{s.label}
))}
); }