Add per-round edit button to scoresheet

A ✎ button next to each round label opens the score entry form
pre-populated with that round's scores. Submitting replaces the round
in place instead of appending a new one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 22:36:39 -05:00
parent 35c1694e18
commit aa121bbcf3
4 changed files with 38 additions and 7 deletions
+13 -3
View File
@@ -24,6 +24,7 @@ export default function App() {
const [game, setGame] = useState<GameState | null>(loadGame)
const [page, setPage] = useState<Page>(() => (game ? 'scoresheet' : 'title'))
const [previousPlayers, setPreviousPlayers] = useState<string[] | undefined>(undefined)
const [editingRound, setEditingRound] = useState<number | null>(null)
function handleNewGame() {
setPreviousPlayers(game?.players)
@@ -39,15 +40,24 @@ export default function App() {
setPage('scoresheet')
}
function handleEditRound(i: number) {
setEditingRound(i)
setPage('enterscores')
}
function handleSubmitScores(scores: number[]) {
const updated: GameState = { ...game!, rounds: [...game!.rounds, scores] }
const rounds = editingRound !== null
? game!.rounds.map((r, i) => (i === editingRound ? scores : r))
: [...game!.rounds, scores]
const updated: GameState = { ...game!, rounds }
saveGame(updated)
setGame(updated)
setEditingRound(null)
setPage('scoresheet')
}
if (page === 'title') return <TitleScreen onNewGame={handleNewGame} />
if (page === 'setup') return <PlayerSetup onStart={handleStart} initialNames={previousPlayers} />
if (page === 'scoresheet') return <ScoreSheet game={game!} onScoreRound={() => setPage('enterscores')} onNewGame={handleNewGame} />
if (page === 'enterscores') return <EnterScores game={game!} onSubmit={handleSubmitScores} />
if (page === 'scoresheet') return <ScoreSheet game={game!} onScoreRound={() => setPage('enterscores')} onNewGame={handleNewGame} onEditRound={handleEditRound} />
if (page === 'enterscores') return <EnterScores game={game!} onSubmit={handleSubmitScores} initialValues={editingRound !== null ? game!.rounds[editingRound] : undefined} />
}