'use client'; import React, { useState } from 'react'; import { motion } from 'framer-motion'; interface LobbyProps { onCreateRoom: (playerName: string) => void; onJoinRoom: (roomId: string, playerName: string) => void; onStartAI: (playerName: string) => void; roomId: string | null; } export function Lobby({ onCreateRoom, onJoinRoom, onStartAI, roomId }: LobbyProps) { const [playerName, setPlayerName] = useState(''); const [joinRoomId, setJoinRoomId] = useState(''); const [mode, setMode] = useState<'menu' | 'create' | 'join' | 'ai'>('menu'); const handleCreate = () => { if (!playerName.trim()) return; onCreateRoom(playerName); }; const handleJoin = () => { if (!playerName.trim() || !joinRoomId.trim()) return; onJoinRoom(joinRoomId.toUpperCase(), playerName); }; const handleAI = () => { if (!playerName.trim()) return; onStartAI(playerName); }; if (mode === 'menu') { return (
Dominoes

Online Multiplayer Game

setPlayerName(e.target.value)} className="w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:border-blue-500 focus:outline-none transition-colors" maxLength={20} />
Create Room setMode('join')} disabled={!playerName.trim()} className="w-full bg-gradient-to-r from-purple-500 to-purple-600 text-white py-3 rounded-lg font-semibold shadow-lg hover:shadow-xl transition-shadow disabled:opacity-50 disabled:cursor-not-allowed" > Join Room Play vs AI

Built with Next.js, Canvas & Socket.IO

); } if (mode === 'join') { return (

Join Room

setJoinRoomId(e.target.value.toUpperCase())} className="w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none transition-colors uppercase" maxLength={6} />
Join Game setMode('menu')} className="w-full bg-gray-300 text-gray-700 py-3 rounded-lg font-semibold hover:bg-gray-400 transition-colors" > Back
); } return null; }