import { Sticky } from "@/lib/sticky";
import { prisma } from "@/prisma/prismaClient";

export default async function GameSystem(
  { params: { id } }: { params: { id: string } },
) {
  if (!id) throw "HOW DID YOU GET HERE?";

  const gameSystem = await prisma.gameSystem.findFirst({
    where: {
      id,
    },
    select: {
      id: true,
      name: true,
      schemas: {
        select: {
          name: true,
          id: true,
          publications: {
            select: {
              name: true,
              id: true,
            },
          },
        },
      },
    },
  });

  return (
    <>
      <section className="heading">
        <h2 className="strapline">Game System</h2>
        <h1>{gameSystem?.name}</h1>
      </section>
      <section>
        <ul>
          {gameSystem?.schemas.map((schema) => (
            <li key={schema.id}>{schema.name}</li>
          ))}
        </ul>
      </section>
      <Sticky sidedness={-1}>
        <h1>HELLO!</h1>
      </Sticky>
    </>
  );
}
