aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/dashboard.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-01 22:28:29 +0900
committernsfisis <nsfisis@gmail.com>2024-08-01 22:28:29 +0900
commit4b206bf707ef5d092ea9579fe82a06ee1d6e0337 (patch)
treef3eb93e716cf1c6da2bccc112ce3b7cebff95222 /frontend/app/routes/dashboard.tsx
parent7ccf1da2f7448d93f8209982813e4097af13fd70 (diff)
parent3a59aa595b1674e9286f4df0035b5b1e38e6957d (diff)
downloadphperkaigi-2025-albatross-4b206bf707ef5d092ea9579fe82a06ee1d6e0337.tar.gz
phperkaigi-2025-albatross-4b206bf707ef5d092ea9579fe82a06ee1d6e0337.tar.zst
phperkaigi-2025-albatross-4b206bf707ef5d092ea9579fe82a06ee1d6e0337.zip
Merge branch 'feat/biome'
Diffstat (limited to 'frontend/app/routes/dashboard.tsx')
-rw-r--r--frontend/app/routes/dashboard.tsx126
1 files changed, 63 insertions, 63 deletions
diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index b93e5d1..1c2137d 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -1,76 +1,76 @@
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { redirect } from "@remix-run/node";
-import { Link, useLoaderData, Form } from "@remix-run/react";
-import { isAuthenticated } from "../.server/auth";
+import { Form, Link, useLoaderData } from "@remix-run/react";
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>
+ );
}