diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-31 01:49:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-31 01:49:28 +0900 |
| commit | 5bcffc6a83021b2bcb06b8c6f622a1d623fc753e (patch) | |
| tree | 95456a82897787bac87c350dbc65cad6f35e4ebd /frontend | |
| parent | 2385e1832fa0acc98fd285453701d5e829670955 (diff) | |
| download | iosdc-japan-2024-albatross-5bcffc6a83021b2bcb06b8c6f622a1d623fc753e.tar.gz iosdc-japan-2024-albatross-5bcffc6a83021b2bcb06b8c6f622a1d623fc753e.tar.zst iosdc-japan-2024-albatross-5bcffc6a83021b2bcb06b8c6f622a1d623fc753e.zip | |
feat(frontend): implement /admin/dashboard page
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/app/routes/admin.dashboard.tsx | 28 | ||||
| -rw-r--r-- | frontend/app/routes/dashboard.tsx | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/frontend/app/routes/admin.dashboard.tsx b/frontend/app/routes/admin.dashboard.tsx new file mode 100644 index 0000000..d5f3809 --- /dev/null +++ b/frontend/app/routes/admin.dashboard.tsx @@ -0,0 +1,28 @@ +import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; +import { Link } from "@remix-run/react"; +import { isAuthenticated } from "../.server/auth"; + +export const meta: MetaFunction = () => { + return [{ title: "[Admin] Dashboard | iOSDC 2024 Albatross.swift" }]; +}; + +export async function loader({ request }: LoaderFunctionArgs) { + const { user } = await isAuthenticated(request, { + failureRedirect: "/login", + }); + if (!user.is_admin) { + throw new Error("Unauthorized"); + } + return null; +} + +export default function AdminDashboard() { + return ( + <div> + <h1>[Admin] Dashboard</h1> + <p> + <Link to="/admin/users">Users</Link> + </p> + </div> + ); +} diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx index 9afee86..badf8c4 100644 --- a/frontend/app/routes/dashboard.tsx +++ b/frontend/app/routes/dashboard.tsx @@ -1,4 +1,5 @@ import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; +import { redirect } from "@remix-run/node"; import { Link, useLoaderData, Form } from "@remix-run/react"; import { isAuthenticated } from "../.server/auth"; import { apiClient } from "../.server/api/client"; @@ -11,6 +12,9 @@ export async function loader({ request }: LoaderFunctionArgs) { const { user, token } = await isAuthenticated(request, { failureRedirect: "/login", }); + if (user.is_admin) { + return redirect("/admin/dashboard"); + } const { data, error } = await apiClient.GET("/games", { params: { query: { |
