From b466dd2a0ae693eeef39e8485fe3ac177c40ab72 Mon Sep 17 00:00:00 2001 From: Frank Schwenk Date: Fri, 20 Jun 2025 10:44:27 +0200 Subject: [PATCH] feat: complete wizard navigation for all steps - Adds forward navigation arrows to the 'Game Type' and 'Race To' steps in the new game wizard. - Unifies navigation logic across all five steps. - Users can now review their selections before proceeding. Closes #11 --- src/components/NewGame.jsx | 73 ++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/src/components/NewGame.jsx b/src/components/NewGame.jsx index a4689b4..738568f 100644 --- a/src/components/NewGame.jsx +++ b/src/components/NewGame.jsx @@ -438,14 +438,22 @@ const Player3Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) * @returns {import('preact').VNode} */ const GameTypeStep = ({ onNext, onCancel, initialValue = '' }) => { + const [gameType, setGameType] = useState(initialValue); const gameTypes = ['8-Ball', '9-Ball', '10-Ball', '14/1 endlos']; - const handleSelect = (gameType) => { - onNext(gameType); + const handleSelect = (selectedType) => { + setGameType(selectedType); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + if (gameType) { + onNext(gameType); + } }; return ( -
+
Neues Spiel – Schritt 4/5
@@ -459,7 +467,7 @@ const GameTypeStep = ({ onNext, onCancel, initialValue = '' }) => { - {/* No "weiter" arrow, selection proceeds automatically */} -
{/* Placeholder to balance the flex container */} +
-
+
); }; @@ -492,24 +520,24 @@ const GameTypeStep = ({ onNext, onCancel, initialValue = '' }) => { * @returns {import('preact').VNode} */ const RaceToStep = ({ onNext, onCancel, initialValue = '' }) => { - const [currentValue, setCurrentValue] = useState(initialValue); + const [raceTo, setRaceTo] = useState(initialValue); const quickPicks = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const handleQuickPick = (value) => { - onNext(value); + setRaceTo(value); }; const handleInputChange = (e) => { - setCurrentValue(e.target.value); + setRaceTo(e.target.value); }; - const handleCustomSubmit = (e) => { + const handleSubmit = (e) => { e.preventDefault(); - onNext(parseInt(currentValue, 10) || 0); + onNext(parseInt(raceTo, 10) || 0); }; return ( -
+
Neues Spiel – Schritt 5/5
@@ -521,7 +549,7 @@ const RaceToStep = ({ onNext, onCancel, initialValue = '' }) => {
-
+
);