From 94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Thu, 1 Aug 2024 21:13:11 +0900
Subject: refactor(frontend): provide simpler API client

---
 frontend/app/routes/dashboard.tsx | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

(limited to 'frontend/app/routes/dashboard.tsx')

diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index 08780f9..b93e5d1 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -2,7 +2,7 @@ import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
 import { redirect } from "@remix-run/node";
 import { Link, useLoaderData, Form } from "@remix-run/react";
 import { isAuthenticated } from "../.server/auth";
-import { apiClient } from "../.server/api/client";
+import { apiGetGames } from "../.server/api/client";
 
 export const meta: MetaFunction = () => {
   return [{ title: "Dashboard | iOSDC Japan 2024 Albatross.swift" }];
@@ -15,19 +15,10 @@ export async function loader({ request }: LoaderFunctionArgs) {
   if (user.is_admin) {
     return redirect("/admin/dashboard");
   }
-  const { data, error } = await apiClient.GET("/games", {
-    params: {
-      header: {
-        Authorization: `Bearer ${token}`,
-      },
-    },
-  });
-  if (error) {
-    throw new Error(error.message);
-  }
+  const { games } = await apiGetGames(token);
   return {
     user,
-    games: data.games,
+    games,
   };
 }
 
-- 
cgit v1.2.3-70-g09d2

