aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-04 17:09:39 +0900
committernsfisis <nsfisis@gmail.com>2024-08-04 17:10:00 +0900
commit2034d5efe124ffa8a9bb56821a9dfcfea27425ff (patch)
treea2330caa3c7c7ac7fd5294050b7ec1410a35ebca
parentdd3440009ae75ecc00e10e48b014ef23bb446964 (diff)
downloadiosdc-japan-2024-albatross-2034d5efe124ffa8a9bb56821a9dfcfea27425ff.tar.gz
iosdc-japan-2024-albatross-2034d5efe124ffa8a9bb56821a9dfcfea27425ff.tar.zst
iosdc-japan-2024-albatross-2034d5efe124ffa8a9bb56821a9dfcfea27425ff.zip
feat(frontend): redirect to /admin/dashboard if logged-in user is admin
-rw-r--r--frontend/app/routes/dashboard.tsx11
1 files changed, 6 insertions, 5 deletions
diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index 229375c..e23d7aa 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -11,7 +11,11 @@ export const meta: MetaFunction = () => [
export async function loader({ request }: LoaderFunctionArgs) {
const { user, token } = await ensureUserLoggedIn(request);
if (user.is_admin) {
- return redirect("/admin/dashboard");
+ return redirect(
+ process.env.NODE_ENV === "development"
+ ? "http://localhost:8002/admin/dashboard"
+ : "/admin/dashboard",
+ );
}
const { games } = await apiGetGames(token);
return {
@@ -26,10 +30,7 @@ export default function Dashboard() {
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>
+ <h1 className="text-3xl font-bold mb-4">{user.username}</h1>
<h2 className="text-2xl font-semibold mb-2">User</h2>
<div className="mb-6">
<ul className="list-disc list-inside">