2024-09-08 06:43:39 -06:00

38 lines
1.1 KiB
TypeScript

import { prisma } from "@/prisma/prismaClient";
import CreateGameSystem from "./create";
import { GameSystemsClient } from "./client";
import Link from "next/link";
import { setCurrentGameSystem } from "@/actions/GameSystems/client";
import { auth } from "@/auth";
export default async function GameSystems() {
const session = await auth();
session?.user?.id && (await setCurrentGameSystem(session.user.id));
const existingGameSystems = await prisma.gameSystem.findMany({
orderBy: {
created: "asc",
},
});
return (
<GameSystemsClient>
<section className="heading">
<h2 className="strapline">Tabletop Commander</h2>
<h1>Game Systems</h1>
</section>
<section className="mb-6">
<CreateGameSystem />
</section>
<section className="">
<ul>
{existingGameSystems.map((g) => (
<li key={g.id} className="odd:bg-black/20 p-2 text-lg">
<Link href={`/game-systems/${g.id}`}>{g.name}</Link>
</li>
))}
</ul>
</section>
</GameSystemsClient>
);
}