From c7e5c995d9ca81b42135b588cd303be12db76eeb Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 12 May 2026 20:33:09 +0200 Subject: [PATCH 1/2] CC-50: Single Match Does Not Set Player 1 Fixes CC-50 --- src/components/MatchResultForm/MatchResultForm.tsx | 9 ++++++++- .../MatchResultPlayerFields/MatchResultPlayerFields.tsx | 1 + .../FlamesOfWarV4MatchResultPlayerFields.tsx | 3 ++- .../TeamYankeeV2MatchResultPlayerFields.tsx | 3 ++- .../components/PlayerField/PlayerField.tsx | 6 ++---- src/components/MatchResultPlayers/MatchResultPlayers.tsx | 2 ++ 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/MatchResultForm/MatchResultForm.tsx b/src/components/MatchResultForm/MatchResultForm.tsx index c7359dc8..a5db8c3a 100644 --- a/src/components/MatchResultForm/MatchResultForm.tsx +++ b/src/components/MatchResultForm/MatchResultForm.tsx @@ -61,8 +61,13 @@ export const MatchResultForm = ({ loading: tournamentPairingsLoading, } = useGetActiveTournamentPairingsByUser(currentUser ? { userId: currentUser._id } : 'skip'); + const isSingleMatch = !existingValues && !forcedValues?.tournamentPairingId; + const singleMatchDefaults = (isSingleMatch && currentUser) + ? { player0UserId: currentUser._id } + : {}; + const form = useForm({ - defaultValues: merge({}, defaultValues, existingValues, forcedValues), + defaultValues: merge({}, defaultValues, singleMatchDefaults, existingValues, forcedValues), mode: 'onSubmit', }); @@ -181,11 +186,13 @@ export const MatchResultForm = ({ diff --git a/src/components/MatchResultForm/components/MatchResultPlayerFields/MatchResultPlayerFields.tsx b/src/components/MatchResultForm/components/MatchResultPlayerFields/MatchResultPlayerFields.tsx index 554139e9..2f0261b9 100644 --- a/src/components/MatchResultForm/components/MatchResultPlayerFields/MatchResultPlayerFields.tsx +++ b/src/components/MatchResultForm/components/MatchResultPlayerFields/MatchResultPlayerFields.tsx @@ -12,6 +12,7 @@ import { export interface MatchResultPlayerFieldsProps { index: 0 | 1; tournamentPairing?: TournamentPairing | null; + playerReadOnly?: boolean; // Passed by FormField via Controller: className?: string; diff --git a/src/components/MatchResultForm/components/MatchResultPlayerFields/gameSystems/FlamesOfWarV4MatchResultPlayerFields/FlamesOfWarV4MatchResultPlayerFields.tsx b/src/components/MatchResultForm/components/MatchResultPlayerFields/gameSystems/FlamesOfWarV4MatchResultPlayerFields/FlamesOfWarV4MatchResultPlayerFields.tsx index 5a500062..b2edcb7d 100644 --- a/src/components/MatchResultForm/components/MatchResultPlayerFields/gameSystems/FlamesOfWarV4MatchResultPlayerFields/FlamesOfWarV4MatchResultPlayerFields.tsx +++ b/src/components/MatchResultForm/components/MatchResultPlayerFields/gameSystems/FlamesOfWarV4MatchResultPlayerFields/FlamesOfWarV4MatchResultPlayerFields.tsx @@ -28,6 +28,7 @@ export const FlamesOfWarV4MatchResultPlayerFields = ({ index, className, disabled = false, + playerReadOnly, tournamentPairing, }: MatchResultPlayerFieldsProps): JSX.Element => { @@ -80,7 +81,7 @@ export const FlamesOfWarV4MatchResultPlayerFields = ({ return (
- + { @@ -80,7 +81,7 @@ export const TeamYankeeV2MatchResultPlayerFields = ({ return (
- + , 'renderCo export const PlayerField = ({ tournamentPairing, index, + readOnly: readOnlyProp, ...props }: PlayerFieldProps): JSX.Element => { - const currentUser = useAuth(); const [deviceSize] = useDeviceSize(); const isMobile = deviceSize === DeviceSize.Mobile; @@ -100,8 +99,7 @@ export const PlayerField = ({ selectedUserRef.current = selectedUser; } - const isOwnSingleMatch = !tournamentPairing && currentUser?._id === userId; - const readOnly = (competitorUserOptions.length === 1) || isBye || isOwnSingleMatch; + const readOnly = readOnlyProp || (competitorUserOptions.length === 1) || isBye; const fieldId = `player${index}UserId`; diff --git a/src/components/MatchResultPlayers/MatchResultPlayers.tsx b/src/components/MatchResultPlayers/MatchResultPlayers.tsx index a6af7bc6..7a87e1eb 100644 --- a/src/components/MatchResultPlayers/MatchResultPlayers.tsx +++ b/src/components/MatchResultPlayers/MatchResultPlayers.tsx @@ -22,6 +22,7 @@ export const MatchResultPlayers = ({ size="large" user={matchResult.player0User} placeholder={{ displayName: matchResult.player0Placeholder }} + disableLink={!!matchResult.player0Placeholder} /> {/* TODO: Add factions */} {/* @@ -45,6 +46,7 @@ export const MatchResultPlayers = ({ size="large" user={matchResult.player1User} placeholder={{ displayName: matchResult.player1Placeholder }} + disableLink={!!matchResult.player1Placeholder} /> {/* TODO: Add factions */} {/* From 8c2a0fe54bcbd5bcc270bc9a26aeba40d339fb8d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 12 May 2026 21:23:28 +0200 Subject: [PATCH 2/2] Update MatchResultForm.tsx --- src/components/MatchResultForm/MatchResultForm.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/MatchResultForm/MatchResultForm.tsx b/src/components/MatchResultForm/MatchResultForm.tsx index a5db8c3a..d36d06bd 100644 --- a/src/components/MatchResultForm/MatchResultForm.tsx +++ b/src/components/MatchResultForm/MatchResultForm.tsx @@ -61,10 +61,9 @@ export const MatchResultForm = ({ loading: tournamentPairingsLoading, } = useGetActiveTournamentPairingsByUser(currentUser ? { userId: currentUser._id } : 'skip'); - const isSingleMatch = !existingValues && !forcedValues?.tournamentPairingId; - const singleMatchDefaults = (isSingleMatch && currentUser) - ? { player0UserId: currentUser._id } - : {}; + const singleMatchDefaults = !existingValues && !forcedValues?.tournamentPairingId && currentUser ? { + player0UserId: currentUser._id, + } : {}; const form = useForm({ defaultValues: merge({}, defaultValues, singleMatchDefaults, existingValues, forcedValues), @@ -186,7 +185,7 @@ export const MatchResultForm = ({