diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-28 23:28:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-29 02:32:54 +0900 |
| commit | df57e43059a230062d903f55f9af7339828875c3 (patch) | |
| tree | bdce6908a7da4bbe5528e3fb3069eb489efa41d5 /frontend/app/routes | |
| parent | daaf81ae931654e20f882fbc6bbc4a02cbfc0273 (diff) | |
| download | phperkaigi-2025-albatross-df57e43059a230062d903f55f9af7339828875c3.tar.gz phperkaigi-2025-albatross-df57e43059a230062d903f55f9af7339828875c3.tar.zst phperkaigi-2025-albatross-df57e43059a230062d903f55f9af7339828875c3.zip | |
feat(frontend): partially implement gaming
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} />; +} |
