import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { useLoaderData, Link } from "@remix-run/react"; import { isAuthenticated } from "../.server/auth"; import { adminApiGetGames } from "../.server/api/client"; export const meta: MetaFunction = () => { return [{ title: "[Admin] Games | iOSDC Japan 2024 Albatross.swift" }]; }; export async function loader({ request }: LoaderFunctionArgs) { const { user, token } = await isAuthenticated(request, { failureRedirect: "/login", }); if (!user.is_admin) { throw new Error("Unauthorized"); } const { games } = await adminApiGetGames(token); return { games }; } export default function AdminGames() { const { games } = useLoaderData()!; return (

[Admin] Games

    {games.map((game) => (
  • {game.display_name} (id={game.game_id})
  • ))}
); }