From 2034d5efe124ffa8a9bb56821a9dfcfea27425ff Mon Sep 17 00:00:00 2001 From: nsfisis 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 (
-

- {user.username}{" "} - {user.is_admin && admin} -

+

{user.username}

User

    -- cgit v1.2.3-70-g09d2