From dff743f83d313d47a328ca8908a1321db92485e1 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sat, 17 Aug 2024 21:22:12 +0900
Subject: feat(frontend): do not redirect from dashboard to admin dashboard
 even if user is admin

---
 frontend/app/routes/dashboard.tsx | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

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

diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index 614b3ae..7aa77fd 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -1,5 +1,4 @@
 import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
 import { Form, useLoaderData } from "@remix-run/react";
 import { apiGetGames } from "../.server/api/client";
 import { ensureUserLoggedIn } from "../.server/auth";
@@ -12,13 +11,6 @@ export const meta: MetaFunction = () => [
 
 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/iosdc-japan/2024/code-battle/admin/dashboard"
-				: "https://t.nil.ninja/iosdc-japan/2024/code-battle/admin/dashboard",
-		);
-	}
 	const { games } = await apiGetGames(token);
 	return {
 		user,
@@ -95,6 +87,18 @@ export default function Dashboard() {
 					</button>
 				</Form>
 			</div>
+			{user.is_admin && (
+				<a
+					href={
+						process.env.NODE_ENV === "development"
+							? "http://localhost:8002/iosdc-japan/2024/code-battle/admin/dashboard"
+							: "/iosdc-japan/2024/code-battle/admin/dashboard"
+					}
+					className="mt-4 text-lg text-white bg-pink-600 px-4 py-2 rounded transition duration-300 hover:bg-pink-500 focus:ring focus:ring-pink-400 focus:outline-none"
+				>
+					Admin Dashboard
+				</a>
+			)}
 		</div>
 	);
 }
-- 
cgit v1.2.3-70-g09d2

