From 3c99572923434a5dbf5016d11bbf8be69d9ea241 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Wed, 5 Jan 2022 20:51:58 +0200 Subject: [PATCH] Fix not able to select winner aftr reporting score --- app/components/SubmitButton.tsx | 7 +++++-- app/components/tournament/DuringMatchActionsRosters.tsx | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/SubmitButton.tsx b/app/components/SubmitButton.tsx index 559a5e38c..5fc0a11a5 100644 --- a/app/components/SubmitButton.tsx +++ b/app/components/SubmitButton.tsx @@ -16,11 +16,14 @@ export function SubmitButton( const [showSuccess, setShowSuccess] = useTimeoutState(false); useEffect(() => { - if ((!successText && !onSuccess) || actionData?.ok !== actionType) return; + // did this submit button's action happen? + if (actionData?.ok !== actionType) return; + // this is essentially to ensure this only fires once per mutation + if (transition.type !== "actionReload") return; onSuccess?.(); setShowSuccess(true); - }, [actionData]); + }, [actionData?.ok, transition.type]); const isLoading = (): boolean => { // is there an action happening at the moment? diff --git a/app/components/tournament/DuringMatchActionsRosters.tsx b/app/components/tournament/DuringMatchActionsRosters.tsx index b41368788..0990623bb 100644 --- a/app/components/tournament/DuringMatchActionsRosters.tsx +++ b/app/components/tournament/DuringMatchActionsRosters.tsx @@ -21,7 +21,7 @@ export function DuringMatchActionsRosters({ const [checkedPlayers, setCheckedPlayers] = React.useState< [string[], string[]] >(checkedPlayersInitialState([ownTeam, opponentTeam])); - const [winnerId, setWinnerId] = React.useState(null); + const [winnerId, setWinnerId] = React.useState(); return (
@@ -35,8 +35,7 @@ export function DuringMatchActionsRosters({ type="radio" id={team.id} name="winnerTeamId" - value={team.id} - onChange={(e) => setWinnerId(e.currentTarget.value)} + onChange={() => setWinnerId(team.id)} checked={winnerId === team.id} />