"use client"; import { IconCheck, IconLibrary, IconMovie, IconPlayerPlay, } from "@tabler/icons-react"; import { motion } from "motion/react"; import { useEffect, useState } from "react"; interface Stats { moviesThisMonth: number; episodesThisWeek: number; librarySize: number; completed: number; } const statDefs = [ { key: "moviesThisMonth" as const, label: "Movies This Month", icon: IconMovie, }, { key: "episodesThisWeek" as const, label: "Episodes This Week", icon: IconPlayerPlay, }, { key: "librarySize" as const, label: "In Library", icon: IconLibrary, }, { key: "completed" as const, label: "Completed", icon: IconCheck, }, ]; export function StatsSummary() { const [stats, setStats] = useState(null); useEffect(() => { fetch("/api/feed/stats") .then((r) => r.json()) .then((data) => setStats(data)) .catch(() => {}); }, []); if (!stats) return null; return (
{statDefs.map((def, i) => { const Icon = def.icon; const value = stats[def.key]; return (
{def.label}
{value}
); })}
); }