"use client"; import { useEffect, useRef } from "react"; import { ArticleView } from "./ArticleView"; import { Breadcrumbs } from "./Breadcrumbs"; import type { Room } from "../api/rooms/route"; type GameScreenProps = { room: Room; playerId: string; html: string; title: string; loading: boolean; loadError: string | null; history: string[]; clicks: number; elapsed: string; countdown: number | null; onNavigate: (title: string) => void; onRetry: () => void; onNextRound: () => void; onResetGame: () => void; }; export function GameScreen({ room, playerId, html, title, loading, loadError, history, clicks, elapsed, countdown, onNavigate, onRetry, onNextRound, onResetGame, }: GameScreenProps) { const breadcrumbEndRef = useRef(null); const myPlayer = room.players.find((p) => p.id === playerId); const isHost = myPlayer?.isHost ?? false; const sortedPlayers = [...room.players].sort((a, b) => b.score - a.score); const winner = room.roundWinner ? room.players.find((p) => p.id === room.roundWinner) : null; useEffect(() => { breadcrumbEndRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "end" }); }, [history]); const btnPrimary = "w-full min-h-11 px-5 rounded-xl text-sm font-semibold bg-[#7c3aed] text-white hover:bg-[#6d28d9] cursor-pointer transition-colors"; const btnGhost = "w-full min-h-11 px-5 rounded-xl text-sm font-semibold bg-[#242424] border border-[#2e2e2e] text-[#f0f0f0] hover:bg-[#1a1a1a] cursor-pointer transition-colors"; // Results if (room.phase === "results") return (
{winner ? ( <>
🏆
{winner.name} a gagné la manche !
) : (
Manche terminée !
)}
{room.startArticle} → {room.targetArticle}

Classement

    {sortedPlayers.map((p, i) => (
  • #{i + 1} {p.name} {p.hasWon && Gagnant} {p.score} pts
  • ))}
{isHost ? (
) : (

En attente de l'hĂ´te...

)}
); // Countdown if (room.phase === "countdown") return (
Départ {room.startArticle}
→
Cible {room.targetArticle}
{countdown !== null && countdown > 0 ? countdown : "Partez !"}
); // Playing return (
{/* Topbar */}
Cible {room.targetArticle}
{elapsed} {clicks} clics {myPlayer?.score ?? 0} pts
{/* Content */}
{loading && (
Chargement...
)} {loadError && (

{loadError}

)} {!loading && !loadError && html && (

{title}

)}
{/* Sidebar - desktop seulement */}
); }