type StatItem = { value: string; label: string }; export type Props = { /** JSON-encoded StatItem[] (max 3) */ stats: string; }; const GRID_CLASS: Record = { 1: "grid-cols-1", 2: "grid-cols-1 sm:grid-cols-2", 3: "grid-cols-1 sm:grid-cols-3", }; export default function StatGroup({ stats }: Props) { let items: StatItem[] = []; try { const parsed = JSON.parse(stats ?? "[]"); if (Array.isArray(parsed)) items = parsed; } catch { /* ignore */ } const clamped = items.slice(0, 3); const gridCols = GRID_CLASS[clamped.length] ?? GRID_CLASS[3]; return (
{clamped.map((stat, i) => (
{stat.value}
{stat.label}
))}
); }