diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-29 03:44:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-29 19:38:39 +0900 |
| commit | d73fd8bf5bf589a4a391c867e980761fadb647ce (patch) | |
| tree | 15f2454b48cae461a6d8acc7edb2c2111d445d3e /frontend/app/routes | |
| parent | 3f95e0e6d62267cf8863e98f3ab7de8971a91000 (diff) | |
| download | phperkaigi-2025-albatross-d73fd8bf5bf589a4a391c867e980761fadb647ce.tar.gz phperkaigi-2025-albatross-d73fd8bf5bf589a4a391c867e980761fadb647ce.tar.zst phperkaigi-2025-albatross-d73fd8bf5bf589a4a391c867e980761fadb647ce.zip | |
feat: partially implement watching
Diffstat (limited to 'frontend/app/routes')
| -rw-r--r-- | frontend/app/routes/golf.$gameId.watch.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/frontend/app/routes/golf.$gameId.watch.tsx b/frontend/app/routes/golf.$gameId.watch.tsx new file mode 100644 index 0000000..e1cb5d7 --- /dev/null +++ b/frontend/app/routes/golf.$gameId.watch.tsx @@ -0,0 +1,33 @@ +import type { LoaderFunctionArgs } from "@remix-run/node"; +import { isAuthenticated } from "../.server/auth"; +import { apiClient } from "../.server/api/client"; +import { useLoaderData } from "@remix-run/react"; +import GolfWatchApp from "../components/GolfWatchApp"; + +export async function loader({ params, request }: LoaderFunctionArgs) { + const { token } = await isAuthenticated(request, { + failureRedirect: "/login", + }); + const { data, error } = await apiClient.GET("/games/{game_id}", { + params: { + path: { + game_id: Number(params.gameId), + }, + header: { + Authorization: `Bearer ${token}`, + }, + }, + }); + if (error) { + throw new Error(error.message); + } + return { + game: data, + }; +} + +export default function GolfWatch() { + const { game } = useLoaderData<typeof loader>(); + + return <GolfWatchApp game={game} />; +} |
