import React, { useState, useEffect } from 'react'; import { apiClient } from 'app'; import { Button } from '@/components/ui/button'; import { ScrollArea } from '@/components/ui/scroll-area'; import { History, X, Trophy, AlertTriangle } from 'lucide-react'; interface Props { tableId: string; } export const GameHistory: React.FC = ({ tableId }) => { const [isOpen, setIsOpen] = useState(false); const [history, setHistory] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { if (isOpen) { loadHistory(); } }, [isOpen, tableId]); const loadHistory = async () => { setLoading(true); try { const response = await apiClient.get_round_history({ table_id: tableId }); const data = await response.json(); setHistory(data); } catch (error) { console.error('Failed to load history:', error); } finally { setLoading(false); } }; return ( <> {/* Toggle Button */} {/* History Panel */} {isOpen && (
{/* Header */}

Game History

{/* Content */} {loading ? (
Loading...
) : history ? (
{/* Disqualified Players */} {history.disqualified_players?.length > 0 && (

Disqualified

{history.disqualified_players.map((p: any) => (
{p.email?.split('@')[0]} - {p.cumulative_score} pts
))}
)} {/* Near Disqualification */} {history.near_disqualification?.length > 0 && (

At Risk

{history.near_disqualification.map((p: any) => (
{p.email?.split('@')[0]} - {p.cumulative_score} pts
))}
)} {/* Round History */}

Rounds ({history.total_rounds})

{history.rounds?.map((round: any) => (
Round {round.round}
{round.players?.map((p: any, idx: number) => (
{idx === 0 && } {p.user_email?.split('@')[0]} {p.points} pts
))}
))}
) : (
No history available
)}
)} ); };