export default function GamePage()

in app/(authenticated-pages)/game/[gameId]/page.tsx [28:54]


export default function GamePage() {
  const {game, gameId, isShowingQuestion, currentQuestion, error: errorMessage} = useGame();
  const gameRef = doc(db, 'games', gameId);

  if (errorMessage) {
    return (
      <ReturnToHomepagePanel>
        <h2>{errorMessage}</h2>
      </ReturnToHomepagePanel>
    );
  }

  return (
    <>
      {(game.state === gameStates.GAME_OVER) && (<>
        <ReturnToHomepagePanel>
          <h2>Game Over</h2>
        </ReturnToHomepagePanel>
        <Scoreboard />
      </>)}
      {gameRef && <>
        {isShowingQuestion && (<QuestionPanel game={game} gameRef={gameRef} currentQuestion={currentQuestion} />)}
        {game.state === gameStates.NOT_STARTED && (<Lobby game={game} gameId={gameId} />)}
      </>}
    </>
  );
}