From bf3bc30a741aa4567571570718cc67287f07d42a Mon Sep 17 00:00:00 2001 From: Matevz Date: Sat, 4 Jan 2025 11:02:15 +0100 Subject: [PATCH] #PrivateLobbies - Adjusted FE to work with changes to the BE. --- src/app/_components/Lobby/SetUp/SetUp.tsx | 2 +- .../Lobby/_subcomponents/SetUpCard/SetUpCard.tsx | 11 ++++++----- .../CreateGameForm/CreateGameForm.tsx | 2 +- src/app/_contexts/Game.context.tsx | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/app/_components/Lobby/SetUp/SetUp.tsx b/src/app/_components/Lobby/SetUp/SetUp.tsx index 12f0819..e01363e 100644 --- a/src/app/_components/Lobby/SetUp/SetUp.tsx +++ b/src/app/_components/Lobby/SetUp/SetUp.tsx @@ -32,7 +32,7 @@ const SetUp: React.FC = ({ const mainCardStyle = { borderRadius: '1.1em', height: '100%', - maxHeight: lobbyState && lobbyState.privacy === 'Public' ? '72.5vh': '64.4vh', + maxHeight: lobbyState && lobbyState.isPrivate ? '64.4vh' : '72.5vh', width: '100%', display: 'flex', flexDirection: 'column', diff --git a/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx b/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx index 74af1e7..b8b6c52 100644 --- a/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx +++ b/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx @@ -87,7 +87,7 @@ const SetUpCard: React.FC = ({ minWidth: '9rem', }, initiativeCardStyle: { - height: lobbyState && lobbyState.privacy === 'Public' ? '15vh' : '23vh', + height: lobbyState && lobbyState.isPrivate ? '23vh' : '15vh', minHeight: '8.5rem', background: '#18325199', display: 'flex', @@ -181,9 +181,7 @@ const SetUpCard: React.FC = ({ ) : ( // Not both ready — show toggle-ready button - !connectedUser.deck ? ( - Please import a deck - ) : ( + connectedUser && connectedUser.deck ? ( + + ) : ( + Please import a deck ) )} )} - {lobbyState && lobbyState.privacy === 'Private' && ( + {lobbyState && lobbyState.isPrivate && ( <> diff --git a/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx b/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx index b40623f..31a7a27 100644 --- a/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx +++ b/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx @@ -61,7 +61,7 @@ const CreateGameForm: React.FC = ({ const payload = { user: user, deck: deckData, - privacy: privacy + isPrivate: privacy === 'Private', }; const response = await fetch('http://localhost:9500/api/create-lobby', { diff --git a/src/app/_contexts/Game.context.tsx b/src/app/_contexts/Game.context.tsx index a193741..d1ee4ad 100644 --- a/src/app/_contexts/Game.context.tsx +++ b/src/app/_contexts/Game.context.tsx @@ -37,10 +37,11 @@ export const GameProvider = ({ children }: { children: ReactNode }) => { // we get the lobbyId const storedUnknownUserId = localStorage.getItem('unknownUserId') || lobbyId+'-GuestId2'; setConnectedPlayer(user ? user.id || '' : storedUnknownUserId ? storedUnknownUserId : ''); + console.log(lobbyId); const newSocket = io('http://localhost:9500', { query: { user: JSON.stringify(user ? user : { id:storedUnknownUserId }), - lobbyId: lobbyId ? lobbyId : null + lobby: JSON.stringify({ lobbyId:lobbyId ? lobbyId : null }) }, });