From 2034d5efe124ffa8a9bb56821a9dfcfea27425ff Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 4 Aug 2024 17:09:39 +0900
Subject: feat(frontend): redirect to /admin/dashboard if logged-in user is
 admin

---
 frontend/app/routes/dashboard.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'frontend/app/routes/dashboard.tsx')

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">
-- 
cgit v1.2.3-70-g09d2

