"use client"; import { usePathname } from "next/navigation"; import { getToken } from "../lib/auth"; import { canAccess, featureForPath } from "../lib/features"; import { useFeatureUser } from "./FeatureGate"; type NavigationItem = { href: string; label: string; shortLabel: string; icon: "dashboard" | "media" | "issues" | "invites" | "settings" | "stats"; adminOnly?: boolean; match: (path: string) => boolean; }; const NAVIGATION: NavigationItem[] = [ { href: "/new-requests", label: "New Request", shortLabel: "New", icon: "media", match: (path) => path === "/new-requests", }, { href: "/", label: "My Requests", shortLabel: "Requests", icon: "dashboard", match: (path) => path === "/" || path.startsWith("/requests/"), }, { href: "/insights", label: "My Stats", shortLabel: "Stats", icon: "stats", match: (path) => path === "/insights" || path.startsWith("/insights/"), }, { href: "/portal/issues", label: "Issues", shortLabel: "Issues", icon: "issues", match: (path) => path.startsWith("/portal/issues"), }, { href: "/profile/invites", label: "Invites", shortLabel: "Invites", icon: "invites", match: (path) => path.startsWith("/profile/invites"), }, { href: "/admin", label: "Configuration", shortLabel: "Config", icon: "settings", adminOnly: true, match: (path) => path.startsWith("/admin") || path.startsWith("/users"), }, ]; const HIDDEN_ROUTES = ["/login", "/signup", "/forgot-password", "/reset-password", "/how-it-works"]; function NavigationIcon({ name }: { name: NavigationItem["icon"] }) { const paths: Record = { stats: ( <> ), dashboard: ( <> ), media: ( <> ), issues: ( <> ), invites: ( <> ), settings: ( <> ), }; return ( ); } export default function WorkspaceNavigation() { const pathname = usePathname(); const { user, ready } = useFeatureUser(); const role = user?.role; if (!ready || !getToken() || HIDDEN_ROUTES.some((route) => pathname.startsWith(route))) { return null; } const items = NAVIGATION.filter( (item) => (!item.adminOnly || role === "admin") && canAccess(user, featureForPath(item.href)), ); return ( ); }