diff options
| author | nsfisis <54318333+nsfisis@users.noreply.github.com> | 2026-02-21 09:35:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-21 09:35:03 +0900 |
| commit | aa25d66376f30c590c697a2c7eb981a24e1057bb (patch) | |
| tree | cd6dc50573a90bb2625df981b8c9305c63f156c0 /frontend/app/pages/GolfWatchPage.tsx | |
| parent | 00354d392a0bcddaac71fee7b6aae721e5747f59 (diff) | |
| parent | 277c9726f0f39d1db83624a8b62a77ac19c2ac0a (diff) | |
| download | phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.tar.gz phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.tar.zst phperkaigi-2026-albatross-aa25d66376f30c590c697a2c7eb981a24e1057bb.zip | |
Merge pull request #6 from nsfisis/claude/allow-viewing-without-login-zODtV
Allow unauthenticated users to view games and watch matches
Diffstat (limited to 'frontend/app/pages/GolfWatchPage.tsx')
| -rw-r--r-- | frontend/app/pages/GolfWatchPage.tsx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/frontend/app/pages/GolfWatchPage.tsx b/frontend/app/pages/GolfWatchPage.tsx index 4f76136..168bd6f 100644 --- a/frontend/app/pages/GolfWatchPage.tsx +++ b/frontend/app/pages/GolfWatchPage.tsx @@ -1,6 +1,5 @@ import { createStore, Provider as JotaiProvider } from "jotai"; import { useEffect, useMemo, useState } from "react"; -import { useLocation } from "wouter"; import { ApiClientContext, createApiClient } from "../api/client"; import type { components } from "../api/schema"; import GolfWatchApp from "../components/GolfWatchApp"; @@ -12,14 +11,13 @@ type LatestGameState = components["schemas"]["LatestGameState"]; type RankingEntry = components["schemas"]["RankingEntry"]; export default function GolfWatchPage({ gameId }: { gameId: string }) { - const [, navigate] = useLocation(); - const [game, setGame] = useState<Game | null>(null); const [ranking, setRanking] = useState<RankingEntry[]>([]); const [gameStates, setGameStates] = useState<{ [key: string]: LatestGameState; }>({}); const [loading, setLoading] = useState(true); + const [error, setError] = useState(false); const gameIdNum = Number(gameId); @@ -41,16 +39,16 @@ export default function GolfWatchPage({ gameId }: { gameId: string }) { setRanking(ranking); setGameStates(states); }) - .catch(() => navigate("/dashboard")) + .catch(() => setError(true)) .finally(() => setLoading(false)); - }, [gameIdNum, navigate]); + }, [gameIdNum]); const store = useMemo(() => { if (!game) return null; return createStore(); }, [game]); - if (loading || !game || !store) { + if (loading) { return ( <div className="min-h-screen bg-gray-100 flex items-center justify-center"> <p className="text-gray-500">Loading...</p> @@ -58,6 +56,14 @@ export default function GolfWatchPage({ gameId }: { gameId: string }) { ); } + if (error || !game || !store) { + return ( + <div className="min-h-screen bg-gray-100 flex items-center justify-center"> + <p className="text-red-500">試合が見つかりませんでした</p> + </div> + ); + } + return ( <JotaiProvider store={store}> <ApiClientContext.Provider value={createApiClient()}> |
