diff --git a/src/app/GameBoard/page.tsx b/src/app/GameBoard/page.tsx index d189ed1f..a844905e 100644 --- a/src/app/GameBoard/page.tsx +++ b/src/app/GameBoard/page.tsx @@ -50,9 +50,10 @@ const GameBoard = () => { const winners = gameState?.winner ? gameState.winner : undefined; // const winners = ['order66'] // we set tabs + // ['endGame','keyboardShortcuts','cardSleeves','gameOptions'] const preferenceTabs = winners - ? ['endGame','keyboardShortcuts','cardSleeves','gameOptions'] - :['currentGame','keyboardShortcuts','cardSleeves','gameOptions'] + ? ['endGame'] + :['currentGame'] if (!gameState || !connectedPlayer) { return null; @@ -118,6 +119,7 @@ const GameBoard = () => { @@ -129,6 +131,7 @@ const GameBoard = () => { { KARABAST void; } export interface IPlayerCardTrayProps { diff --git a/src/app/_components/Gameboard/_subcomponents/Overlays/ChatDrawer/ChatDrawer.tsx b/src/app/_components/Gameboard/_subcomponents/Overlays/ChatDrawer/ChatDrawer.tsx index 4befcb81..222513a0 100644 --- a/src/app/_components/Gameboard/_subcomponents/Overlays/ChatDrawer/ChatDrawer.tsx +++ b/src/app/_components/Gameboard/_subcomponents/Overlays/ChatDrawer/ChatDrawer.tsx @@ -3,8 +3,9 @@ import { Drawer, Box, Typography } from '@mui/material'; import Chat from '@/app/_components/_sharedcomponents/Chat/Chat'; import { IChatDrawerProps } from '@/app/_components/Gameboard/GameboardTypes'; import { useGame } from '@/app/_contexts/Game.context'; +import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -const ChatDrawer: React.FC = ({ sidebarOpen }) => { +const ChatDrawer: React.FC = ({ sidebarOpen, toggleSidebar }) => { const { gameState, sendGameMessage } = useGame(); const [chatMessage, setChatMessage] = useState('') @@ -43,10 +44,11 @@ const ChatDrawer: React.FC = ({ sidebarOpen }) => { variant="persistent" sx={styles.drawerStyle} > + - + {/* ROUND - + */} {/* Use the ChatComponent here */} diff --git a/src/app/_components/HomePage/HomePageTypes.ts b/src/app/_components/HomePage/HomePageTypes.ts index 1470caad..638e67ab 100644 --- a/src/app/_components/HomePage/HomePageTypes.ts +++ b/src/app/_components/HomePage/HomePageTypes.ts @@ -1,4 +1,5 @@ import { ICardData } from '@/app/_components/_sharedcomponents/Cards/CardTypes'; +import { SwuGameFormat } from '@/app/_constants/constants'; export interface IHexagonProps { backgroundColor: string; @@ -17,8 +18,14 @@ export interface IPublicGameInProgressProps { }; } -export interface IPublicGamesProps { - format: string; +export interface ILobby { + id: string; + name: string; + format: SwuGameFormat; +} + +export interface IJoinableGameProps { + lobby: ILobby; } export type IArticle = { diff --git a/src/app/_components/HomePage/PublicGames/PublicGames.tsx b/src/app/_components/HomePage/PublicGames/PublicGames.tsx index 4156ef60..e2138dcc 100644 --- a/src/app/_components/HomePage/PublicGames/PublicGames.tsx +++ b/src/app/_components/HomePage/PublicGames/PublicGames.tsx @@ -1,10 +1,29 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Card, CardContent, Typography, Divider } from '@mui/material'; import JoinableGame from '../_subcomponents/JoinableGame/JoinableGame'; import GamesInProgress from '../_subcomponents/GamesInProgress/GamesInProgress'; -import { IPublicGamesProps } from '../HomePageTypes'; +import { ILobby } from '../HomePageTypes'; +import { SwuGameFormat } from '@/app/_constants/constants'; -const PublicGames: React.FC = ({ format }) => { +const PublicGames: React.FC = () => { + const [lobbies, setLobbies] = useState([]); + useEffect(() => { + // Fetch unfilled lobbies from the server + const fetchLobbies = async () => { + try { + const response = await fetch(`${process.env.NEXT_PUBLIC_ROOT_URL}/api/available-lobbies`); + if (!response.ok) { + throw new Error(`Error fetching lobbies: ${response.statusText}`); + } + const data: ILobby[] = await response.json(); + setLobbies(data); + console.log(data) + } catch (error) { + console.error('Error fetching lobbies:', error); + } + }; + fetchLobbies(); + }, []); const styles = { publicGamesWrapper: { height: '100%', @@ -24,13 +43,16 @@ const PublicGames: React.FC = ({ format }) => { Public Games - {format} + Premier - - - Request-Undo {format} - + { lobbies.filter((lobby) => lobby.format === SwuGameFormat.Premier).map((lobby) => ( + + ))} + Next Set Preview + { lobbies.filter((lobby) => lobby.format === SwuGameFormat.NextSetPreview).map((lobby) => ( + + ))} diff --git a/src/app/_components/HomePage/_subcomponents/JoinableGame/JoinableGame.tsx b/src/app/_components/HomePage/_subcomponents/JoinableGame/JoinableGame.tsx index 4326fad2..4916b649 100644 --- a/src/app/_components/HomePage/_subcomponents/JoinableGame/JoinableGame.tsx +++ b/src/app/_components/HomePage/_subcomponents/JoinableGame/JoinableGame.tsx @@ -1,35 +1,12 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { Box, Button, Typography } from '@mui/material'; import { useRouter } from 'next/navigation'; import { useUser } from '@/app/_contexts/User.context'; -interface ILobby { - id: string; - name: string; -} +import { IJoinableGameProps } from '../../HomePageTypes'; -const JoinableGame: React.FC = () => { - // const randomGameId = Math.floor(Math.random() * 10000); +const JoinableGame: React.FC = ({ lobby }) => { const router = useRouter(); const { user } = useUser(); - const [lobbies, setLobbies] = useState([]); - useEffect(() => { - // Fetch unfilled lobbies from the server - const fetchLobbies = async () => { - try { - const response = await fetch(`${process.env.NEXT_PUBLIC_ROOT_URL}/api/available-lobbies`); - if (!response.ok) { - throw new Error(`Error fetching lobbies: ${response.statusText}`); - } - const data: ILobby[] = await response.json(); - setLobbies(data); - } catch (error) { - console.error('Error fetching lobbies:', error); - } - }; - - fetchLobbies(); - }, []); - const joinLobby = async (lobbyId: string) => { // we need to set the user try { @@ -76,12 +53,10 @@ const JoinableGame: React.FC = () => { return ( <> - {lobbies.map((lobby) => ( - - {lobby.name} - - - ))} + + {lobby.name} + + ); }; diff --git a/src/app/_components/_sharedcomponents/ControlHub/ControlHub.tsx b/src/app/_components/_sharedcomponents/ControlHub/ControlHub.tsx index 578a97f8..39b526bc 100644 --- a/src/app/_components/_sharedcomponents/ControlHub/ControlHub.tsx +++ b/src/app/_components/_sharedcomponents/ControlHub/ControlHub.tsx @@ -151,7 +151,7 @@ const ControlHub: React.FC = ({ diff --git a/src/app/_components/_sharedcomponents/Preferences/Preferences.types.ts b/src/app/_components/_sharedcomponents/Preferences/Preferences.types.ts index 7d34a75e..3f983fc1 100644 --- a/src/app/_components/_sharedcomponents/Preferences/Preferences.types.ts +++ b/src/app/_components/_sharedcomponents/Preferences/Preferences.types.ts @@ -27,6 +27,7 @@ export type IBlockedUser = { export interface IPreferenceProps { isPreferenceOpen: boolean, + sidebarOpen: boolean, tabs: string[], preferenceToggle?: () => void, variant?: 'gameBoard' | 'homePage' diff --git a/src/app/_components/_sharedcomponents/Preferences/PreferencesComponent.tsx b/src/app/_components/_sharedcomponents/Preferences/PreferencesComponent.tsx index 715e8c9f..ab2da7c9 100644 --- a/src/app/_components/_sharedcomponents/Preferences/PreferencesComponent.tsx +++ b/src/app/_components/_sharedcomponents/Preferences/PreferencesComponent.tsx @@ -6,6 +6,7 @@ import { IPreferenceProps } from '@/app/_components/_sharedcomponents/Preference const PreferencesComponent: React.FC = ({ isPreferenceOpen, + sidebarOpen, preferenceToggle, tabs = [], title, @@ -17,10 +18,11 @@ const PreferencesComponent: React.FC = ({ containerStyle:{ display: isPreferenceOpen && variant ==='gameBoard' ? 'block' : 'none', position: 'absolute', - width: '100%', + width: sidebarOpen ? 'calc(100% - 280px)' : '100%', height: '100%', backgroundColor: 'rgba(0, 0, 0, 0.5)', - zIndex: 9, + zIndex: 999, + padding: '2rem', }, overlayStyle:{ display: isPreferenceOpen ? 'block' : 'none', @@ -34,17 +36,13 @@ const PreferencesComponent: React.FC = ({ borderRadius:'15px', ...(variant === 'homePage' ? { - width: '95vw', + width: '100%', justifySelf:'center', height: '81vh', } : { borderColor: '#30434B', - height: '90vh', - transform: 'translate(-50%, -50%)', - top: '50%', - left: '50%', - position: 'absolute', - width: '90vw', + height: '100%', + width: '100%', }) }, headerBox:{ @@ -68,19 +66,19 @@ const PreferencesComponent: React.FC = ({ return ( <> - - - {title && ( - - {title} - {subtitle} + + {title && ( + + {title} + {subtitle} + + )} + {variant === 'gameBoard' && ( + + )} + + - )} - {variant === 'gameBoard' && ( - - )} - - diff --git a/src/app/page.tsx b/src/app/page.tsx index 00bf54cd..f411e074 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -40,7 +40,7 @@ const Home: React.FC = () => { - +