diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-13 23:08:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-13 23:08:50 +0900 |
| commit | 470b7235b80d082009ad350e2b33ef6637209e02 (patch) | |
| tree | 60ffe938a4051255ea0d6b35001be50c28b76497 /frontend/app/routes/golf.$gameId.watch.tsx | |
| parent | 482c3a52a0fcc5870a7db4a190475caf61b211a3 (diff) | |
| parent | 6c30f383a65cb000d66a85cadc96253ce7061942 (diff) | |
| download | phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.tar.gz phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.tar.zst phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.zip | |
Merge branch 'feat/frontend-rearchitecture'
Diffstat (limited to 'frontend/app/routes/golf.$gameId.watch.tsx')
| -rw-r--r-- | frontend/app/routes/golf.$gameId.watch.tsx | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/frontend/app/routes/golf.$gameId.watch.tsx b/frontend/app/routes/golf.$gameId.watch.tsx deleted file mode 100644 index 7468be5..0000000 --- a/frontend/app/routes/golf.$gameId.watch.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { Provider as JotaiProvider, createStore } from "jotai"; -import { useMemo } from "react"; -import type { LoaderFunctionArgs, MetaFunction } from "react-router"; -import { redirect, useLoaderData } from "react-router"; -import { ensureUserLoggedIn } from "../.server/auth"; -import { ApiClientContext, createApiClient } from "../api/client"; -import GolfWatchApp from "../components/GolfWatchApp"; -import { APP_NAME } from "../config"; - -export const meta: MetaFunction<typeof loader> = ({ data }) => [ - { - title: data - ? `Golf Watching ${data.game.display_name} | ${APP_NAME}` - : `Golf Watching | ${APP_NAME}`, - }, -]; - -export async function loader({ params, request }: LoaderFunctionArgs) { - const { token } = await ensureUserLoggedIn(request); - const apiClient = createApiClient(token); - - const gameId = Number(params.gameId); - - try { - const [{ game }, { ranking }, { states: gameStates }] = await Promise.all([ - await apiClient.getGame(gameId), - await apiClient.getGameWatchRanking(gameId), - await apiClient.getGameWatchLatestStates(gameId), - ]); - - return { - apiToken: token, - game, - ranking, - gameStates, - }; - } catch { - throw redirect("/dashboard"); - } -} - -export default function GolfWatch() { - const { apiToken, game, ranking, gameStates } = - useLoaderData<typeof loader>(); - - const store = useMemo(() => { - void game.game_id; - return createStore(); - }, [game.game_id]); - - return ( - <JotaiProvider store={store}> - <ApiClientContext.Provider value={createApiClient(apiToken)}> - <GolfWatchApp - key={game.game_id} - game={game} - initialGameStates={gameStates} - initialRanking={ranking} - /> - </ApiClientContext.Provider> - </JotaiProvider> - ); -} |
