import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { redirect } from "@remix-run/node"; import { Form, Link, useLoaderData } from "@remix-run/react"; import { apiGetGames } from "../.server/api/client"; import { ensureUserLoggedIn } from "../.server/auth"; export const meta: MetaFunction = () => [ { title: "Dashboard | iOSDC Japan 2024 Albatross.swift" }, ]; export async function loader({ request }: LoaderFunctionArgs) { const { user, token } = await ensureUserLoggedIn(request); if (user.is_admin) { return redirect( process.env.NODE_ENV === "development" ? "http://localhost:8002/admin/dashboard" : "/admin/dashboard", ); } const { games } = await apiGetGames(token); return { user, games, }; } export default function Dashboard() { const { user, games } = useLoaderData()!; return (

{user.username}

User

  • Name: {user.display_name}

Games

    {games.map((game) => (
  • {game.display_name} {game.game_type === "multiplayer" ? " (Multiplayer)" : " (1v1)"} {game.state === "closed" || game.state === "finished" ? ( Entry ) : ( Entry )}
  • ))}
); }