"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useSession, signOut } from "next-auth/react"; const Navigation = () => { const pathname = usePathname(); const { data: session, status } = useSession(); const isActive = (path) => { if (path === "/") return pathname === "/"; // Exact match for paths if (pathname === path) return true; // For nested paths, ensure we match the full path segment if (pathname.startsWith(path + "/")) return true; return false; }; const navItems = [ { href: "/", label: "Dashboard" }, { href: "/projects", label: "Projects" }, { href: "/tasks/templates", label: "Task Templates" }, { href: "/project-tasks", label: "Project Tasks" }, { href: "/contracts", label: "Contracts" }, ]; // Add admin-only items if (session?.user?.role === 'admin') { navItems.push({ href: "/admin/users", label: "User Management" }); } const handleSignOut = async () => { await signOut({ callbackUrl: "/auth/signin" }); }; // Don't show navigation on auth pages if (pathname.startsWith('/auth/')) { return null; } return ( ); }; export default Navigation;