From bef5b0e62d138685f911285b1d665cf0494ef923 Mon Sep 17 00:00:00 2001 From: jbock Date: Fri, 4 Oct 2024 21:21:59 +0200 Subject: [PATCH] show timesetting --- .../client/src/feature/lobby/OpenGames.jsx | 30 ++++++++----------- .../client/src/feature/lobby/lobbyState.js | 7 +++-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/client/src/feature/lobby/OpenGames.jsx b/src/main/client/src/feature/lobby/OpenGames.jsx index a5b3697..03a5627 100644 --- a/src/main/client/src/feature/lobby/OpenGames.jsx +++ b/src/main/client/src/feature/lobby/OpenGames.jsx @@ -35,7 +35,7 @@ import { stopPropagation, } from "src/util.js" import { - getAcceptDialog, + getAcceptData, setAcceptDialogOpen, } from "./lobbyState.js" import { @@ -44,7 +44,7 @@ import { export function OpenGames({lobbyState, setLobbyState}) { let [openGames, setOpenGames] = useState([]) - let acceptDialog = getAcceptDialog(lobbyState) + let acceptableGame = getAcceptData(lobbyState) let stompClient = useContext(StompContext) let navigate = useNavigate() let auth = useAuthStore(state => state.auth) @@ -84,14 +84,11 @@ export function OpenGames({lobbyState, setLobbyState}) { }), [auth, navigate]) return (
-
+
{openGames.map((game) => ( { - if (acceptDialog) { - return - } setLobbyState(setAcceptDialogOpen(lobbyState, acceptDialogRef.current, acceptableGame)) stopPropagation(event) }} @@ -99,7 +96,7 @@ export function OpenGames({lobbyState, setLobbyState}) { ))}
@@ -116,11 +113,6 @@ function OpenGame({game, onClick}) { "*:py-3", !disabled && "cursor-pointer *:hover:bg-sky-200 *:hover:text-black", ) - let dimClasses = twJoin( - "pl-1", - "pr-3", - "rounded-r-lg", - ) return (
{ @@ -136,15 +128,17 @@ function OpenGame({game, onClick}) { className={classes} key={game.id}>
{game.user}
-
+
{game.dim}x{game.dim}
+
+ {game.timesetting}s +
) } -function AcceptDialog({onAccept, acceptDialog, acceptDialogRef}) { - let acceptableGame = acceptDialog?.data +function AcceptDialog({onAccept, acceptableGame, acceptDialogRef}) { let [isFlip, setFlip] = useState(false) let [handi, setHandi] = useState(1) let auth = useAuthStore(state => state.auth) @@ -161,18 +155,18 @@ function AcceptDialog({onAccept, acceptDialog, acceptDialogRef}) { left: Math.trunc(acceptableGame?.rect.right || 0) + 16, }} className={twJoin( - !acceptDialog && "hidden", + !acceptableGame && "hidden", "absolute bg-sky-200 px-4 py-3 rounded-lg z-8 flex flex-col", )}>
diff --git a/src/main/client/src/feature/lobby/lobbyState.js b/src/main/client/src/feature/lobby/lobbyState.js index 35a9ee8..002c348 100644 --- a/src/main/client/src/feature/lobby/lobbyState.js +++ b/src/main/client/src/feature/lobby/lobbyState.js @@ -28,12 +28,15 @@ export function setNewGameOpen(state, el) { return setOpen(state, el, "newgame") } -export function getAcceptDialog({stack}) { +export function getAcceptData({stack}) { + if (!stack.length) { + return undefined + } let result = stack.filter(obj => obj.kind === "accept") if (!result.length) { return undefined } - return result[0] + return result[0].data } export function setAcceptDialogOpen(state, el, data) {