game system nav context
sse endpoint
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// import { setCurrentGameSystem } from "@/actions/GameSystems/client";
|
||||
import { setCurrentGameSystem } from "@/actions/GameSystems/client";
|
||||
import { auth } from "@/auth";
|
||||
import { prisma } from "@/prisma/prismaClient";
|
||||
import Link from "next/link";
|
||||
|
||||
@@ -32,6 +35,10 @@ export default async function GameSystem({
|
||||
// },
|
||||
});
|
||||
|
||||
const session = await auth();
|
||||
|
||||
session?.user?.id && (await setCurrentGameSystem(session.user.id, id));
|
||||
|
||||
return (
|
||||
<>
|
||||
<section className="heading">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { deleteAllGameSystems } from "@/actions/GameSystems/deleteAll";
|
||||
import { deleteAllGameSystems } from "@/actions/GameSystems/devactions";
|
||||
import { DevTool } from "@/components/devtools/DevTool";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { FC, PropsWithChildren } from "react";
|
||||
|
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { createGameSystem } from "@/actions/GameSystems/create";
|
||||
import { createGameSystem } from "@/actions/GameSystems";
|
||||
import { useToast } from "@/components/toast";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
|
@@ -2,8 +2,12 @@ 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",
|
||||
|
@@ -1,13 +1,6 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Roboto } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import {
|
||||
BookOpenIcon,
|
||||
CircleStackIcon,
|
||||
Cog8ToothIcon,
|
||||
PuzzlePieceIcon,
|
||||
QuestionMarkCircleIcon,
|
||||
} from "@heroicons/react/24/solid";
|
||||
import Link from "next/link";
|
||||
import { DevToolboxContextProvider } from "@/components/devtools/context";
|
||||
import { RecoilRootClient } from "@/components/recoilRoot";
|
||||
@@ -15,6 +8,10 @@ import { JotaiProvider } from "@/components/jotaiProvider";
|
||||
import { Toaster } from "@/components/toast";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import { User } from "@/components/user/index";
|
||||
import { getCurrentGameSystem } from "@/actions/GameSystems";
|
||||
import { Nav } from "@/components/nav";
|
||||
import { SSE } from "@/components/sse";
|
||||
import { auth } from "@/auth";
|
||||
|
||||
const roboto = Roboto({ subsets: ["latin"], weight: "400" });
|
||||
|
||||
@@ -23,38 +20,12 @@ export const metadata: Metadata = {
|
||||
description: "Rules and tools for tabletop games!",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
const navItems = [
|
||||
{
|
||||
to: "/game-systems",
|
||||
icon: PuzzlePieceIcon,
|
||||
text: "Game Systems",
|
||||
},
|
||||
{
|
||||
to: "/schemas",
|
||||
icon: CircleStackIcon,
|
||||
text: "Schemas",
|
||||
},
|
||||
{
|
||||
to: "/publications",
|
||||
icon: BookOpenIcon,
|
||||
text: "Publications",
|
||||
},
|
||||
{
|
||||
to: "/settings",
|
||||
icon: Cog8ToothIcon,
|
||||
text: "Settings",
|
||||
},
|
||||
{
|
||||
to: "/help",
|
||||
icon: QuestionMarkCircleIcon,
|
||||
text: "How do?",
|
||||
},
|
||||
];
|
||||
const currentGame = await getCurrentGameSystem();
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
@@ -65,19 +36,7 @@ export default function RootLayout({
|
||||
<h1 className="text-lg font-bold pb-6 border-b dark:border-dark-500 border-primary-600">
|
||||
<Link href="/">Tabletop Commander</Link>
|
||||
</h1>
|
||||
<ul className="my-6 flex flex-col gap-6">
|
||||
{navItems.map((n) => (
|
||||
<li key={"nav-item" + n.text}>
|
||||
<Link
|
||||
href={n.to}
|
||||
className="flex items-center gap-2 group hover:text-purple-300 transition-colors"
|
||||
>
|
||||
<n.icon className="w-6 h-6 group-hover:fill-purple-300 transition-colors" />
|
||||
{n.text}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Nav game={currentGame ?? undefined} />
|
||||
<div className="mt-auto">
|
||||
<User />
|
||||
</div>
|
||||
@@ -96,6 +55,7 @@ export default function RootLayout({
|
||||
<div id="root-portal"></div>
|
||||
</body>
|
||||
</SessionProvider>
|
||||
<SSE />
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user