diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-29 02:59:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-29 02:59:07 +0900 |
| commit | d1c8aa42aec32c8b042ae32d249df9c3c969453d (patch) | |
| tree | 2f248715213d12d6649f32b5ddcbb0d9a0281ed8 /frontend/app/routes | |
| parent | 22ddf340f0b0c8d0cd04c34d9fa1481a1fbf422f (diff) | |
| parent | 161d82bee9f9e65680516a9cfd392e0cf297eadf (diff) | |
| download | phperkaigi-2025-albatross-d1c8aa42aec32c8b042ae32d249df9c3c969453d.tar.gz phperkaigi-2025-albatross-d1c8aa42aec32c8b042ae32d249df9c3c969453d.tar.zst phperkaigi-2025-albatross-d1c8aa42aec32c8b042ae32d249df9c3c969453d.zip | |
Merge branch 'game-playing'
Diffstat (limited to 'frontend/app/routes')
| -rw-r--r-- | frontend/app/routes/golf.$gameId.play.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/frontend/app/routes/golf.$gameId.play.tsx b/frontend/app/routes/golf.$gameId.play.tsx new file mode 100644 index 0000000..bda563f --- /dev/null +++ b/frontend/app/routes/golf.$gameId.play.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 GolfPlayApp from "../components/GolfPlayApp"; + +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 GolfPlay() { + const { game } = useLoaderData<typeof loader>(); + + return <GolfPlayApp game={game} />; +} |
