import React from 'react'; import { Game } from '../../types'; import { useGameStateContext } from '../../context/GameStateContext'; const HistoryScreen: React.FC = () => { const { gameState, setCurrentScreen } = useGameStateContext(); const renderHistory = () => { if (!gameState.gameHistory || gameState.gameHistory.length === 0) { return
No games yet.
; } return (
{gameState.gameHistory.map((game, index) => (
{ // Would load game details setCurrentScreen('setup'); }} >

{game.players.length} players, {game.rounds.length} rounds

{new Date(game.date).toLocaleDateString()}
{Object.entries(game.finalScores).map(([playerId, score]) => ( {game.players.find(p => p.id === playerId)?.name}: {score} ))}
))}
); }; const exportData = () => { const dataStr = JSON.stringify(gameState.gameHistory, null, 2); const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr); const exportFileDefaultName = 'tschausepp-history.json'; const linkElement = document.createElement('a'); linkElement.setAttribute('href', dataUri); linkElement.setAttribute('download', exportFileDefaultName); linkElement.click(); }; const clearHistory = () => { if (window.confirm('Are you sure you want to clear all game history?')) { // This would normally be handled by the hook, but we're doing it manually for demo localStorage.removeItem('tschausepp_game_state'); window.location.reload(); } }; return (

📚 Game History

{renderHistory()}
); }; export default HistoryScreen;