import GenresSearch from "./GenresSearch";
import { searchGenres } from "@/server/repo";

export const metadata = { title: "ZXDB Genres" };

export const dynamic = "force-dynamic";

export default async function Page({ searchParams }: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
  const sp = await searchParams;
  const q = (Array.isArray(sp.q) ? sp.q[0] : sp.q) ?? "";
  const page = Math.max(1, Number(Array.isArray(sp.page) ? sp.page[0] : sp.page) || 1);
  const initial = await searchGenres({ q, page, pageSize: 20 });
  return <GenresSearch initial={initial} initialQ={q} />;
}
