diff --git a/.gitignore b/.gitignore index 87cfc77..c1c2679 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ pnpm-debug.log* .idea/ .gitea -dev/ \ No newline at end of file +dev/.gitea diff --git a/src/components/App.jsx b/src/components/App.jsx index acbc37d..a15375a 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -117,6 +117,22 @@ const App = () => { setScreen('game-detail'); }, [currentGameId]); + const handleRematch = useCallback(() => { + const completedGame = games.find(g => g.id === currentGameId); + if (!completedGame) return; + + const newId = handleCreateGame({ + player1: completedGame.player1, + player2: completedGame.player2, + player3: completedGame.player3, + gameType: completedGame.gameType, + raceTo: completedGame.raceTo, + }); + + setCompletionModal({ open: false, game: null }); + showGameDetail(newId); + }, [games, currentGameId, handleCreateGame, showGameDetail]); + // Delete game const handleDeleteGame = useCallback((id) => { setModal({ open: true, gameId: id }); @@ -258,6 +274,7 @@ const App = () => { game={completionModal.game} onConfirm={handleConfirmCompletion} onClose={() => setCompletionModal({ open: false, game: null })} + onRematch={handleRematch} /> diff --git a/src/components/GameCompletionModal.jsx b/src/components/GameCompletionModal.jsx index ff096db..641006d 100644 --- a/src/components/GameCompletionModal.jsx +++ b/src/components/GameCompletionModal.jsx @@ -9,9 +9,10 @@ import styles from './GameCompletionModal.module.css'; * @param {object} props.game * @param {Function} props.onConfirm * @param {Function} props.onClose + * @param {Function} props.onRematch * @returns {import('preact').VNode|null} */ -const GameCompletionModal = ({ open, game, onConfirm, onClose }) => { +const GameCompletionModal = ({ open, game, onConfirm, onClose, onRematch }) => { if (!open || !game) return null; const playerNames = [game.player1, game.player2, game.player3].filter(Boolean); const scores = [game.score1, game.score2, game.score3].filter((_, i) => playerNames[i]); @@ -41,6 +42,7 @@ const GameCompletionModal = ({ open, game, onConfirm, onClose }) => {
+