import { Link, useLocation } from "wouter" import { AnimatePresence, motion } from "framer-motion" import { LogOut } from "lucide-react" import { Button } from "@workspace/ui/components/button" import { Tooltip, TooltipContent, TooltipTrigger, } from "@workspace/ui/components/tooltip" import { useRoomStore } from "@/store/room" import { LobbyView } from "@/components/lobby-view" import { QuizView } from "@/components/quiz-view" import { BlindtestView } from "@/components/blindtest-view" import { GameEndView } from "@/components/game-end-view" import { PlayerCards } from "@/components/player-cards" import { RoomCode } from "@/components/room-code" import { Boom } from "@/components/boom" import { RoundTransition } from "@/components/round-transition" import { PseudoScreen } from "@/components/pseudo-screen" export function RoomPage({ code }: { code: string }) { const [, navigate] = useLocation() const snapshot = useRoomStore((s) => s.snapshot) const roomCode = useRoomStore((s) => s.roomCode) const leaveRoom = useRoomStore((s) => s.leaveRoom) const playerId = useRoomStore((s) => s.playerId) const connected = useRoomStore((s) => s.connected) const pseudoSet = useRoomStore((s) => s.pseudoSet) const boomKey = useRoomStore((s) => s.boomKey) const roundKey = useRoomStore((s) => s.roundKey) const voteProgress = useRoomStore((s) => s.voteProgress) const round = useRoomStore((s) => s.round) const roundKind = useRoomStore((s) => s.roundKind) const roundModeChanged = useRoomStore((s) => s.roundModeChanged) // Pas dans cette room (accès direct sans rejoindre / refresh) : retour accueil. if (roomCode !== code) { return (

Room introuvable ou session perdue.

) } // Pseudo pas encore choisi : on l'affiche d'abord. if (!pseudoSet) { return } // En attente du premier snapshot. if (!snapshot || snapshot.code !== code) { return (

Chargement…

) } // Phase grossière : on n'anime qu'aux frontières lobby ↔ jeu ↔ fin pour // préserver le lecteur YouTube entre in_round / reveal / scores. const phase = snapshot.status === "lobby" ? "lobby" : snapshot.status === "ended" ? "ended" : "game" return (
{/* Halo d'ambiance en fond */}
{connected ? "Connecté" : "Déconnecté"}
{phase === "lobby" && } {phase === "game" && ( <> {round?.type === "blindtest" ? ( ) : ( )} )} {phase === "ended" && }
{boomKey > 0 && } {roundKey > 0 && round && ( )}
) }