diff --git a/client/src/app/game/[code]/not-found.tsx b/client/src/app/game/[code]/not-found.tsx
new file mode 100644
index 0000000..d49494f
--- /dev/null
+++ b/client/src/app/game/[code]/not-found.tsx
@@ -0,0 +1,8 @@
+export default function NotFound() {
+ return (
+
+
Error
+
Game not found
+
+ );
+}
diff --git a/client/src/app/game/[code]/page.tsx b/client/src/app/game/[code]/page.tsx
index 134ae52..8345876 100644
--- a/client/src/app/game/[code]/page.tsx
+++ b/client/src/app/game/[code]/page.tsx
@@ -1,99 +1,12 @@
-"use client";
-// all of this in a client component for now to easily handle socket events
+import Game from "@/components/game/Game";
+import { getGame } from "@/lib/game";
+import { notFound } from "next/navigation";
-import { Chessboard } from "react-chessboard";
-import { IconCopy } from "@tabler/icons-react";
-import Image from "next/image";
+export default async function GamePage({ params }: { params: { code: string } }) {
+ const game = await getGame(params.code);
+ if (!game) {
+ notFound();
+ }
-const pgn = "1. e4 e5 2. f3 Nf6 3. d4 exd4 4. Qxd4 Nxe4 5. Qxe4+ Qe7 6. Qxe7+";
-
-export default function Game() {
- return (
-
-
- {/* overlay */}
-
-
- Waiting for opponent.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Invite friends:
-
-
- ches.su/game/123abc
-
-
-
-
-
- {pgn
- .split(/\d+\./)
- .filter((move) => move.trim() !== "")
- .map((moveSet, i) => {
- const moves = moveSet.trim().split(" ");
- return (
-
- | {i + 1}. |
- {moves[0]} |
- {moves[1]} |
-
- );
- })}
-
-
-
-
-
-
-
-
Spectators: nize, nize, nize
-
-
- );
+ return ;
}
diff --git a/client/src/components/game/Game.tsx b/client/src/components/game/Game.tsx
new file mode 100644
index 0000000..46602af
--- /dev/null
+++ b/client/src/components/game/Game.tsx
@@ -0,0 +1,109 @@
+"use client";
+// all of this in a client component for now to easily handle socket events
+
+import { Chessboard } from "react-chessboard";
+import { IconCopy } from "@tabler/icons-react";
+import { useState, useEffect } from "react";
+import Image from "next/image";
+import { Game } from "@chessu/types";
+
+import { io } from "socket.io-client";
+import { API_URL } from "@/config";
+
+const socket = io(API_URL, { withCredentials: true, autoConnect: true });
+
+const pgn = "1. e4 e5 2. f3 Nf6 3. d4 exd4 4. Qxd4 Nxe4 5. Qxe4+ Qe7 6. Qxe7+";
+
+export default function GameWrapper({ initialLobby }: { initialLobby: Game }) {
+ const [lobbyData, setLobbyData] = useState(initialLobby);
+ // TODO
+
+ return (
+
+
+ {/* overlay */}
+
+
+ Waiting for opponent.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Invite friends:
+
+
+ ches.su/game/{initialLobby.code}
+
+
+
+
+
+ {pgn
+ .split(/\d+\./)
+ .filter((move) => move.trim() !== "")
+ .map((moveSet, i) => {
+ const moves = moveSet.trim().split(" ");
+ return (
+
+ | {i + 1}. |
+ {moves[0]} |
+ {moves[1]} |
+
+ );
+ })}
+
+
+
+
+
+
+
+
Spectators: nize, nize, nize
+
+
+ );
+}