import { h } from 'preact';
import { Screen } from '../ui/Layout';
import GameDetail from '../GameDetail';
import type { Game, EndlosGame } from '../../types/game';

interface GameDetailScreenProps {
  game?: Game;
  onUpdateScore: (player: number, change: number) => void;
  onFinishGame: () => void;
  onUpdateGame: (game: EndlosGame) => void;
  onUndo: () => void;
  onForfeit: () => void;
  onBack: () => void;
}

export default function GameDetailScreen({
  game,
  onUpdateScore,
  onFinishGame,
  onUpdateGame,
  onUndo,
  onForfeit,
  onBack,
}: GameDetailScreenProps) {
  if (!game) {
    return (
      <Screen>
        <div>Game not found</div>
      </Screen>
    );
  }

  return (
    <Screen>
      <GameDetail
        game={game}
        onUpdateScore={onUpdateScore}
        onFinishGame={onFinishGame}
        onUpdateGame={onUpdateGame}
        onUndo={onUndo}
        onForfeit={onForfeit}
        onBack={onBack}
      />
    </Screen>
  );
}