diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-01 21:35:25 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-01 21:35:25 +0900 |
| commit | f6443042fbec1bd394439904f3c69e23709f7e6a (patch) | |
| tree | 46872e86ed7e42962895e0bfe04064387487523f /frontend/app/routes/admin.games_.$gameId.tsx | |
| parent | 10b9be2c2a46b204f83be7d152ca62bf69e8843e (diff) | |
| parent | 94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4 (diff) | |
| download | phperkaigi-2025-albatross-f6443042fbec1bd394439904f3c69e23709f7e6a.tar.gz phperkaigi-2025-albatross-f6443042fbec1bd394439904f3c69e23709f7e6a.tar.zst phperkaigi-2025-albatross-f6443042fbec1bd394439904f3c69e23709f7e6a.zip | |
Merge branch 'refactor/api'
Diffstat (limited to 'frontend/app/routes/admin.games_.$gameId.tsx')
| -rw-r--r-- | frontend/app/routes/admin.games_.$gameId.tsx | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/frontend/app/routes/admin.games_.$gameId.tsx b/frontend/app/routes/admin.games_.$gameId.tsx index ff8f136..1ad8a2a 100644 --- a/frontend/app/routes/admin.games_.$gameId.tsx +++ b/frontend/app/routes/admin.games_.$gameId.tsx @@ -5,7 +5,7 @@ import type { } from "@remix-run/node"; import { useLoaderData, Form } from "@remix-run/react"; import { isAuthenticated } from "../.server/auth"; -import { apiClient } from "../.server/api/client"; +import { adminApiPutGame, adminApiGetGame } from "../.server/api/client"; export const meta: MetaFunction<typeof loader> = ({ data }) => { return [ @@ -25,20 +25,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) { throw new Error("Unauthorized"); } const { gameId } = params; - const { data, error } = await apiClient.GET("/admin/games/{game_id}", { - params: { - path: { - game_id: Number(gameId), - }, - header: { - Authorization: `Bearer ${token}`, - }, - }, - }); - if (error) { - throw new Error(error.message); - } - return { game: data.game }; + const { game } = await adminApiGetGame(token, Number(gameId)); + return { game }; } export async function action({ request, params }: ActionFunctionArgs) { @@ -63,22 +51,9 @@ export async function action({ request, params }: ActionFunctionArgs) { throw new Error("Invalid action"); } - const { error } = await apiClient.PUT("/admin/games/{game_id}", { - params: { - path: { - game_id: Number(gameId), - }, - header: { - Authorization: `Bearer ${token}`, - }, - }, - body: { - state: nextState, - }, + await adminApiPutGame(token, Number(gameId), { + state: nextState, }); - if (error) { - throw new Error(error.message); - } return null; } |
