aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/dashboard.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/routes/dashboard.tsx')
-rw-r--r--frontend/app/routes/dashboard.tsx122
1 files changed, 61 insertions, 61 deletions
diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index 1f80634..1c2137d 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -5,72 +5,72 @@ import { apiGetGames } from "../.server/api/client";
import { isAuthenticated } from "../.server/auth";
export const meta: MetaFunction = () => {
- return [{ title: "Dashboard | iOSDC Japan 2024 Albatross.swift" }];
+ return [{ title: "Dashboard | iOSDC Japan 2024 Albatross.swift" }];
};
export async function loader({ request }: LoaderFunctionArgs) {
- const { user, token } = await isAuthenticated(request, {
- failureRedirect: "/login",
- });
- if (user.is_admin) {
- return redirect("/admin/dashboard");
- }
- const { games } = await apiGetGames(token);
- return {
- user,
- games,
- };
+ const { user, token } = await isAuthenticated(request, {
+ failureRedirect: "/login",
+ });
+ if (user.is_admin) {
+ return redirect("/admin/dashboard");
+ }
+ const { games } = await apiGetGames(token);
+ return {
+ user,
+ games,
+ };
}
export default function Dashboard() {
- const { user, games } = useLoaderData<typeof loader>()!;
+ const { user, games } = useLoaderData<typeof loader>()!;
- return (
- <div className="min-h-screen p-8">
- <div className="p-6 rounded shadow-md max-w-4xl mx-auto">
- <h1 className="text-3xl font-bold mb-4">
- {user.username}{" "}
- {user.is_admin && <span className="text-red-500 text-lg">admin</span>}
- </h1>
- <h2 className="text-2xl font-semibold mb-2">User</h2>
- <div className="mb-6">
- <ul className="list-disc list-inside">
- <li>Name: {user.display_name}</li>
- </ul>
- </div>
- <h2 className="text-2xl font-semibold mb-2">Games</h2>
- <div>
- <ul className="list-disc list-inside">
- {games.map((game) => (
- <li key={game.game_id}>
- {game.display_name}{" "}
- {game.state === "closed" || game.state === "finished" ? (
- <span className="inline-block px-6 py-2 text-gray-400 bg-gray-200 cursor-not-allowed rounded">
- Entry
- </span>
- ) : (
- <Link
- to={`/golf/${game.game_id}/play`}
- className="inline-block px-6 py-2 text-white bg-blue-500 hover:bg-blue-700 rounded"
- >
- Entry
- </Link>
- )}
- </li>
- ))}
- </ul>
- </div>
- <div>
- <Form method="post" action="/logout">
- <button
- className="mt-6 px-6 py-2 text-white bg-red-500 hover:bg-red-700 rounded"
- type="submit"
- >
- Logout
- </button>
- </Form>
- </div>
- </div>
- </div>
- );
+ return (
+ <div className="min-h-screen p-8">
+ <div className="p-6 rounded shadow-md max-w-4xl mx-auto">
+ <h1 className="text-3xl font-bold mb-4">
+ {user.username}{" "}
+ {user.is_admin && <span className="text-red-500 text-lg">admin</span>}
+ </h1>
+ <h2 className="text-2xl font-semibold mb-2">User</h2>
+ <div className="mb-6">
+ <ul className="list-disc list-inside">
+ <li>Name: {user.display_name}</li>
+ </ul>
+ </div>
+ <h2 className="text-2xl font-semibold mb-2">Games</h2>
+ <div>
+ <ul className="list-disc list-inside">
+ {games.map((game) => (
+ <li key={game.game_id}>
+ {game.display_name}{" "}
+ {game.state === "closed" || game.state === "finished" ? (
+ <span className="inline-block px-6 py-2 text-gray-400 bg-gray-200 cursor-not-allowed rounded">
+ Entry
+ </span>
+ ) : (
+ <Link
+ to={`/golf/${game.game_id}/play`}
+ className="inline-block px-6 py-2 text-white bg-blue-500 hover:bg-blue-700 rounded"
+ >
+ Entry
+ </Link>
+ )}
+ </li>
+ ))}
+ </ul>
+ </div>
+ <div>
+ <Form method="post" action="/logout">
+ <button
+ className="mt-6 px-6 py-2 text-white bg-red-500 hover:bg-red-700 rounded"
+ type="submit"
+ >
+ Logout
+ </button>
+ </Form>
+ </div>
+ </div>
+ </div>
+ );
}