'use client';
import React from 'react';
import { motion } from 'framer-motion';
import { Player } from '@/lib/types';
interface WaitingRoomProps {
roomId: string;
players: Player[];
currentPlayerId: string | null;
onReady: () => void;
onLeave: () => void;
}
export function WaitingRoom({ roomId, players, currentPlayerId, onReady, onLeave }: WaitingRoomProps) {
const currentPlayer = players.find(p => p.id === currentPlayerId);
const isReady = currentPlayer?.isReady || false;
const canStart = players.length >= 2 && players.every(p => p.isReady);
return (
Waiting Room
{roomId}
Share this code with your friends
Players ({players.length}/4)
{players.length < 2 && (
⚠️ Minimum 2 players required to start
)}
{players.map((player) => (
{player.name.charAt(0).toUpperCase()}
{player.name}
{player.id === currentPlayerId && (
You
)}
{player.isReady && (
✓
)}
))}
{/* Empty slots */}
{Array.from({ length: 4 - players.length }).map((_, i) => (
))}
{!isReady ? (
Ready to Play
) : (
{canStart ? 'Starting game...' : players.length < 2 ? 'Waiting for at least 1 more player...' : 'Waiting for other players...'}
)}
Leave Room
Game Rules
- • 2-4 players can play (minimum 2 required)
- • Match numbers on tiles to place them on the board
- • Draw from the boneyard if you can't play
- • First player to use all tiles wins!
- • Game ends when someone runs out or no one can move
);
}