import { Fragment, useState, type CSSProperties } from 'react' import { type GameState } from '../types' import { computeRunningTotals, isGameOver } from '../game/scoring' import PageFrame from '../components/PageFrame' import PrimaryButton from '../components/PrimaryButton' import styles from './ScoreSheet.module.css' interface Props { game: GameState onScoreRound: () => void onNewGame: () => void onEditRound: (i: number) => void } export default function ScoreSheet({ game, onScoreRound, onNewGame, onEditRound }: Props) { const [confirmingNewGame, setConfirmingNewGame] = useState(false) const totals = computeRunningTotals(game.rounds) const gameOver = isGameOver(totals) const lastTotals = totals[totals.length - 1] ?? [] const winnerIndex = gameOver ? lastTotals.indexOf(Math.max(...lastTotals)) : -1 const newGameButton = ( ) const confirmOverlay = (
End this game?