Skip to content

Commit

Permalink
#PrivateLobbies
Browse files Browse the repository at this point in the history
- Adjusted FE to work with changes to the BE.
  • Loading branch information
CheBato committed Jan 4, 2025
1 parent 345491c commit bf3bc30
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/_components/Lobby/SetUp/SetUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 6 additions & 5 deletions src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const SetUpCard: React.FC<ISetUpProps> = ({
minWidth: '9rem',
},
initiativeCardStyle: {
height: lobbyState && lobbyState.privacy === 'Public' ? '15vh' : '23vh',
height: lobbyState && lobbyState.isPrivate ? '23vh' : '15vh',
minHeight: '8.5rem',
background: '#18325199',
display: 'flex',
Expand Down Expand Up @@ -181,9 +181,7 @@ const SetUpCard: React.FC<ISetUpProps> = ({
</>
) : (
// Not both ready — show toggle-ready button
!connectedUser.deck ? (
<Typography>Please import a deck</Typography>
) : (
connectedUser && connectedUser.deck ? (
<CardActions sx={styles.buttonsContainerStyle}>
<Box sx={styles.readyImg} />
<Button
Expand All @@ -193,12 +191,15 @@ const SetUpCard: React.FC<ISetUpProps> = ({
{readyStatus ? 'Unready' : 'Ready'}
</Button>
</CardActions>

) : (
<Typography>Please import a deck</Typography>
)
)}
</>
)}

{lobbyState && lobbyState.privacy === 'Private' && (
{lobbyState && lobbyState.isPrivate && (
<>
<Box sx={styles.labelTextStyle}>
<Link href="https://www.swudb.com/" target="_blank" sx={{ color: 'lightblue' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const CreateGameForm: React.FC<ICreateGameFormProps> = ({
const payload = {
user: user,
deck: deckData,
privacy: privacy
isPrivate: privacy === 'Private',
};
const response = await fetch('http://localhost:9500/api/create-lobby',
{
Expand Down
3 changes: 2 additions & 1 deletion src/app/_contexts/Game.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
},
});

Expand Down

0 comments on commit bf3bc30

Please sign in to comment.