aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/admin.games.tsx
blob: 23e45c59b60db2b5e7179a04da5a916222491527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Link, useLoaderData } from "@remix-run/react";
import { adminApiGetGames } from "../.server/api/client";
import { ensureAdminUserLoggedIn } from "../.server/auth";

export const meta: MetaFunction = () => {
	return [{ title: "[Admin] Games | iOSDC Japan 2024 Albatross.swift" }];
};

export async function loader({ request }: LoaderFunctionArgs) {
	const { token } = await ensureAdminUserLoggedIn(request);
	const { games } = await adminApiGetGames(token);
	return { games };
}

export default function AdminGames() {
	const { games } = useLoaderData<typeof loader>()!;

	return (
		<div>
			<div>
				<h1>[Admin] Games</h1>
				<ul>
					{games.map((game) => (
						<li key={game.game_id}>
							<Link to={`/admin/games/${game.game_id}`}>
								{game.display_name} (id={game.game_id})
							</Link>
						</li>
					))}
				</ul>
			</div>
		</div>
	);
}