"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useSession, signOut } from "next-auth/react"; import { useTranslation } from "@/lib/i18n"; import LanguageSwitcher from "./LanguageSwitcher"; const Navigation = () => { const pathname = usePathname(); const { data: session, status } = useSession(); const { t } = useTranslation(); 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: "/projects", label: t('navigation.projects') }, { href: "/calendar", label: t('navigation.calendar') || 'Kalendarz' }, { href: "/tasks/templates", label: t('navigation.taskTemplates') }, { href: "/project-tasks", label: t('navigation.projectTasks') }, { href: "/contracts", label: t('navigation.contracts') }, ]; // Add admin-only items if (session?.user?.role === 'admin') { navItems.push({ href: "/admin/users", label: t('navigation.userManagement') }); } 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;