From 7a3dca768afd7ebdcb5674be66f8f69b50597000 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 19 Apr 2026 20:48:53 +0200 Subject: [PATCH] feat(36-02): add /admin layout route and placeholder index - admin.tsx: createFileRoute('/admin') with sidebar shell (Items, Tags disabled with Soon badge) - admin/index.tsx: createFileRoute('/admin/') placeholder with shield icon - useEffect guard redirects non-admin users to / --- src/client/routes/admin.tsx | 62 +++++++++++++++++++++++++++++++ src/client/routes/admin/index.tsx | 18 +++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/client/routes/admin.tsx create mode 100644 src/client/routes/admin/index.tsx diff --git a/src/client/routes/admin.tsx b/src/client/routes/admin.tsx new file mode 100644 index 0000000..827cfa3 --- /dev/null +++ b/src/client/routes/admin.tsx @@ -0,0 +1,62 @@ +import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router"; +import { useEffect } from "react"; +import { useAuth } from "../hooks/useAuth"; +import { LucideIcon } from "../lib/iconData"; + +export const Route = createFileRoute("/admin")({ + component: AdminLayout, +}); + +function AdminLayout() { + const navigate = useNavigate(); + const { data: auth, isLoading } = useAuth(); + + useEffect(() => { + if (!isLoading && !auth?.user?.isAdmin) { + navigate({ to: "/" }); + } + }, [auth, isLoading, navigate]); + + // Don't render the shell until auth is confirmed + if (isLoading || !auth?.user?.isAdmin) return null; + + return ( +
+ {/* Sidebar */} + + + {/* Main content */} +
+ +
+
+ ); +} diff --git a/src/client/routes/admin/index.tsx b/src/client/routes/admin/index.tsx new file mode 100644 index 0000000..8c4e94a --- /dev/null +++ b/src/client/routes/admin/index.tsx @@ -0,0 +1,18 @@ +import { createFileRoute } from "@tanstack/react-router"; +import { LucideIcon } from "../../lib/iconData"; + +export const Route = createFileRoute("/admin/")({ + component: AdminIndex, +}); + +function AdminIndex() { + return ( +
+ +

Admin Panel

+

+ Select a section from the sidebar +

+
+ ); +}