"use client"; import { trpc } from "~/lib/trpc/client.js"; import type { WidgetProps } from "~/components/dashboard/widget-registry.js"; import { formatMoney } from "~/lib/format.js"; import { InfoTooltip } from "~/components/ui/InfoTooltip.js"; import { AnimatedNumber } from "~/components/ui/AnimatedNumber.js"; import { ProgressRing } from "~/components/ui/ProgressRing.js"; import { FadeIn } from "~/components/ui/FadeIn.js"; const ACCENT_COLORS = { green: "var(--color-green-500, #22c55e)", amber: "var(--color-amber-500, #f59e0b)", red: "var(--color-red-500, #ef4444)", } as const; function StatCard({ label, value, suffix, sub, info, accentColor, delay = 0, ring, }: { label: string; value: number; suffix?: string; sub?: string; info?: React.ReactNode; accentColor?: "green" | "amber" | "red"; delay?: number; ring?: { value: number; color: string }; }) { const accentBorder = accentColor === "red" ? "border-l-red-500" : accentColor === "amber" ? "border-l-amber-500" : accentColor === "green" ? "border-l-green-500" : ""; return ( {label} {info && } {ring ? ( ) : ( )} {sub && {sub}} ); } // eslint-disable-next-line @typescript-eslint/no-unused-vars export function StatCardsWidget(_props: Partial = {}) { const { data, isLoading } = trpc.dashboard.getOverview.useQuery(undefined, { staleTime: 60_000, placeholderData: (prev) => prev, }); if (isLoading || !data) { return ( {[...Array(4)].map((_, i) => ( ))} ); } const budgetPct = data.budgetSummary.avgUtilizationPercent; const budgetAccent: "red" | "amber" | "green" = budgetPct > 90 ? "red" : budgetPct >= 70 ? "amber" : "green"; return ( ); }