diff --git a/client/src/App.tsx b/client/src/App.tsx index c6eb1ce..44400f4 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -7,6 +7,7 @@ import UsersPage from "./pages/UsersPage"; import CatalogPage from "./pages/CatalogPage"; import VendorPage from "./pages/VendorPage"; import ReportsPage from "./pages/ReportsPage"; +import EventsPage from "./pages/EventsPage"; function ProtectedRoute({ children }: { children: React.ReactNode }) { const { user, loading } = useAuth(); @@ -43,6 +44,7 @@ export default function App() { > } /> } /> + } /> } /> } /> } /> diff --git a/client/src/components/Layout.tsx b/client/src/components/Layout.tsx index 1f1cba3..b8a23a1 100644 --- a/client/src/components/Layout.tsx +++ b/client/src/components/Layout.tsx @@ -3,11 +3,12 @@ import { NavLink, Outlet, useNavigate } from "react-router-dom"; import { useAuth } from "../context/AuthContext"; const NAV = [ - { to: "/", label: "Dashboard", exact: true }, - { to: "/catalog", label: "Catalog" }, - { to: "/users", label: "Users" }, - { to: "/vendor", label: "Vendor" }, - { to: "/reports", label: "Reports" }, + { to: "/", label: "Dashboard", exact: true, roles: ["admin", "vendor", "user"] }, + { to: "/catalog", label: "Catalog", roles: ["admin", "vendor", "user"] }, + { to: "/events", label: "Events", roles: ["admin", "vendor"] }, + { to: "/users", label: "Users", roles: ["admin", "vendor"] }, + { to: "/vendor", label: "Vendor", roles: ["admin", "vendor"] }, + { to: "/reports", label: "Reports", roles: ["admin", "vendor"] }, ]; export default function Layout() { @@ -19,12 +20,14 @@ export default function Layout() { navigate("/login", { replace: true }); }; + const visibleNav = NAV.filter((item) => item.roles.includes(user?.role ?? "")); + return (