diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-17 21:22:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-17 21:22:15 +0900 |
| commit | dff743f83d313d47a328ca8908a1321db92485e1 (patch) | |
| tree | 7d4102f724fb47c712065f27c4663a367e678b40 | |
| parent | 01d3120fd7129f573d88f7aa7c227b3ef93fe368 (diff) | |
| download | iosdc-japan-2024-albatross-dff743f83d313d47a328ca8908a1321db92485e1.tar.gz iosdc-japan-2024-albatross-dff743f83d313d47a328ca8908a1321db92485e1.tar.zst iosdc-japan-2024-albatross-dff743f83d313d47a328ca8908a1321db92485e1.zip | |
feat(frontend): do not redirect from dashboard to admin dashboard even if user is admin
| -rw-r--r-- | frontend/app/routes/dashboard.tsx | 20 |
1 files changed, 12 insertions, 8 deletions
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> ); } |
