From df57e43059a230062d903f55f9af7339828875c3 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 28 Jul 2024 23:28:10 +0900
Subject: feat(frontend): partially implement gaming

---
 frontend/app/routes/golf.$gameId.play.tsx | 33 +++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 frontend/app/routes/golf.$gameId.play.tsx

(limited to 'frontend/app/routes/golf.$gameId.play.tsx')

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} />;
+}
-- 
cgit v1.3.1

