import type { ComponentType } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "../ui/card.js"; import { Skeleton } from "../ui/skeleton.js"; export interface MetricCardProps { title: string; value: string | number | null; icon?: ComponentType<{ className?: string }>; description?: string; loading?: boolean; error?: string; } /** A compact, data-source-agnostic dashboard metric. */ export function MetricCard({ title, value, icon: Icon, description, loading, error, }: MetricCardProps) { return ( {title} {Icon && } {loading ? ( ) : error ? (

{error}

) : ( <>
{typeof value === "number" ? value.toLocaleString() : (value ?? "-")}
{description && (

{description}

)} )}
); }