import React from 'react'; import { Player } from '../types'; import { motion, AnimatePresence } from 'framer-motion'; import { Sparkles, User, X } from 'lucide-react'; import { PlayerAvatar } from './PlayerAvatar'; interface LobbyProps { quizTitle: string; players: Player[]; gamePin: string | null; role: 'HOST' | 'CLIENT'; onStart: () => void; onEndGame?: () => void; currentPlayerId?: string | null; hostParticipates?: boolean; } export const Lobby: React.FC = ({ quizTitle, players, gamePin, role, onStart, onEndGame, currentPlayerId, hostParticipates = false }) => { const isHost = role === 'HOST'; const hostPlayer = players.find(p => p.id === 'host'); const realPlayers = players.filter(p => p.id !== 'host'); const currentPlayer = currentPlayerId ? players.find(p => p.id === currentPlayerId) : null; return (
Game PIN
{gamePin}
{quizTitle}
Live Lobby
{realPlayers.length} Players
{isHost ? ( <>
{realPlayers.length === 0 && !hostParticipates && (
Waiting for players to join...
)} {hostParticipates && hostPlayer && ( {hostPlayer.name} HOST )} {realPlayers.map((player) => ( {player.name} ))}
{onEndGame && ( )} ) : (
{currentPlayer ? ( ) : ( )}

{currentPlayer?.name || "You're in!"}

Waiting for the host to start...

)}
); };