"use client"; interface StatData { label: string; value: string; change: string; isPositive: boolean; } interface StatsCardsProps { stats?: StatData[]; cols?: 4 | 5; } const COLS_CLASS: Record = { 4: "grid grid-cols-2 md:grid-cols-4 gap-4", 5: "grid grid-cols-2 md:grid-cols-5 gap-4", }; export default function StatsCards({ stats = [], cols }: StatsCardsProps) { if (!stats || stats.length === 0) return null; const gridClass = COLS_CLASS[cols ?? stats.length] ?? COLS_CLASS[4]; return (
{stats.map((stat, index) => (
{/* Label */}
{stat.label}
{/* Value */}
{stat.value}
{/* Change indicator */} {stat.change ? (
{stat.change}
) : (
)}
))}
); }