From e31c22dda15a665ffefc13b14a8b377062ef0351 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 21 Mar 2025 10:16:42 +0900 Subject: feat(frontend): make main players optional --- .../GolfWatchApps/GolfWatchAppGaming1v1.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx') diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx index 168f5d9..ce12dca 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx @@ -20,8 +20,8 @@ import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; - playerProfileA: PlayerProfile; - playerProfileB: PlayerProfile; + playerProfileA: PlayerProfile | null; + playerProfileB: PlayerProfile | null; problemTitle: string; problemDescription: string; sampleCode: string; @@ -39,11 +39,13 @@ export default function GolfWatchAppGaming1v1({ const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const latestGameStates = useAtomValue(latestGameStatesAtom); - const stateA = latestGameStates[`${playerProfileA.id}`] ?? null; + const stateA = + playerProfileA && (latestGameStates[`${playerProfileA.id}`] ?? null); const codeA = stateA?.code ?? ""; const scoreA = stateA?.score ?? null; const statusA = stateA?.status ?? "none"; - const stateB = latestGameStates[`${playerProfileB.id}`] ?? null; + const stateB = + playerProfileB && (latestGameStates[`${playerProfileB.id}`] ?? null); const codeB = stateB?.code ?? ""; const scoreB = stateB?.score ?? null; const statusB = stateB?.status ?? "none"; @@ -66,14 +68,14 @@ export default function GolfWatchAppGaming1v1({
- {playerProfileA.iconPath && ( + {playerProfileA?.iconPath && ( )} -
{playerProfileA.displayName}
+
{playerProfileA?.displayName}
{scoreA}
@@ -82,9 +84,9 @@ export default function GolfWatchAppGaming1v1({ {gameResultKind ? (
{gameResultKind === "winA" - ? `勝者 ${playerProfileA.displayName}` + ? `勝者 ${playerProfileA!.displayName}` : gameResultKind === "winB" - ? `勝者 ${playerProfileB.displayName}` + ? `勝者 ${playerProfileB!.displayName}` : "引き分け"}
) : ( @@ -94,8 +96,8 @@ export default function GolfWatchAppGaming1v1({
{scoreB}
-
{playerProfileB.displayName}
- {playerProfileB.iconPath && ( +
{playerProfileB?.displayName}
+ {playerProfileB?.iconPath && (