"use client"; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { formatBytes } from "@/lib/format"; import { deleteFromLibrary, listLibrary, type LibraryEntryMeta } from "@/lib/pinball/tableLibrary"; import { setPendingTable } from "@/lib/pinball/tableSelectionStore"; export default function TableLibrary() { const router = useRouter(); const [entries, setEntries] = useState(null); useEffect(() => { listLibrary() .then(setEntries) .catch((err) => { console.error("Failed to read table library:", err); setEntries([]); }); }, []); if (!entries || entries.length === 0) return null; const handlePlay = (id: string) => { setPendingTable({ kind: "library", id }); router.push("/play"); }; const handleDelete = async (id: string) => { await deleteFromLibrary(id); setEntries((prev) => prev?.filter((entry) => entry.id !== id) ?? null); }; return (

Your Library

); }