"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.
avatar
nize
vs
avatar
notnize
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]}
chatbox
Spectators: nize, nize, nize
); }