import { Link, Outlet } from "react-router-dom"; import { Panel } from "../components/ui/Panel"; import { useAuth } from "./AuthContext"; /** * Route gate for admin-only sections (the Users plane). Sits inside * ProtectedRoute, so the user is already authenticated here — this only checks * the admin role. * * A non-admin who navigates to an admin route sees a calm, explicit * access-denied panel (NOT a redirect loop and NOT a 403 toast storm). The * server remains the real authority: the underlying /api/users calls are * admin-gated server-side, so this is defense-in-depth plus correct UX. */ export function AdminRoute() { const { isAdmin } = useAuth(); if (!isAdmin) { return (

Admins only

User management is restricted to administrators. Your account does not have admin access. If you need it, ask an administrator to update your role.

Back to Machines
); } return ; }