import Link from "next/link"; import { listAllSeries } from "@/lib/db/queries"; import { createSeriesAction } from "@/app/actions/entities"; import { Film, Plus, ArrowDownAZ, Hash } from "lucide-react"; import { cn } from "@/lib/utils"; export const dynamic = "force-dynamic"; export default async function SeriesIndexPage({ searchParams, }: { searchParams: Promise>; }) { const sp = await searchParams; const sort: "az" | "count" = sp.sort === "count" ? "count" : "az"; const raw = listAllSeries(); const items = sort === "count" ? [...raw].sort((a, b) => b.count - a.count || a.name.localeCompare(b.name)) : [...raw].sort((a, b) => a.name.localeCompare(b.name)); return (

Series

{items.length} total

A-Z Count
{items.length === 0 ? (

No series yet. Create one above or add from any cover.

) : (
{items.map((s) => ( {s.name} {s.count} ))}
)}
); }