diff --git a/src/components/MatchResultForm/MatchResultForm.tsx b/src/components/MatchResultForm/MatchResultForm.tsx index c7359dc8..d36d06bd 100644 --- a/src/components/MatchResultForm/MatchResultForm.tsx +++ b/src/components/MatchResultForm/MatchResultForm.tsx @@ -61,8 +61,12 @@ export const MatchResultForm = ({ loading: tournamentPairingsLoading, } = useGetActiveTournamentPairingsByUser(currentUser ? { userId: currentUser._id } : 'skip'); + const singleMatchDefaults = !existingValues && !forcedValues?.tournamentPairingId && currentUser ? { + player0UserId: currentUser._id, + } : {}; + const form = useForm({ - defaultValues: merge({}, defaultValues, existingValues, forcedValues), + defaultValues: merge({}, defaultValues, singleMatchDefaults, existingValues, forcedValues), mode: 'onSubmit', }); @@ -181,11 +185,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 */} {/*