"use client"; import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useSession, signOut } from "next-auth/react"; import { NotificationBell } from "./NotificationBell"; export function Navbar() { const pathname = usePathname(); const { data: session, status } = useSession(); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const role = (session?.user as any)?.role || "GUEST"; const isEmployer = role === "EMPLOYER"; const isAdmin = role === "ADMIN"; // Build role-tailored navigation items const navLinks: Array<{ href: string; label: string; badge?: string }> = [ { href: "/jobs", label: "Search Directory" }, { href: "/companies", label: "Companies" }, { href: "/salary-insights", label: "Salaries" }, ]; if (status === "authenticated") { if (isEmployer) { navLinks.push( { href: "/employer/jobs", label: "Listings" }, { href: "/employer/jobs/new", label: "Post a Job", badge: "New" }, { href: "/employer/ats", label: "Pipeline" }, { href: "/employer/team", label: "Team" }, { href: "/employer/candidates", label: "Talent" } ); } else if (isAdmin) { navLinks.push( { href: "/employer/jobs", label: "Jobs" }, { href: "/employer/jobs/new", label: "Post Job" }, { href: "/employer/ats", label: "ATS" }, { href: "/admin", label: "Admin Console", badge: "Admin" } ); } else { // Job Seeker navLinks.push( { href: "/saved-jobs", label: "Saved" }, { href: "/applications", label: "Applications" }, { href: "/resume", label: "Resume" }, { href: "/alerts", label: "Alerts" }, { href: "/profile", label: "Profile" } ); } } return (
{/* Logo & Desktop Nav */}
DirectWire / beta
{/* User Session & Actions */}
{status === "authenticated" && session?.user ? (
{session.user.name || session.user.email} [{role}]
) : (
Log In Get Started →
)} {/* Mobile Menu Toggle */}
{/* Mobile Dropdown */} {mobileMenuOpen && (
{navLinks.map((link) => { const isActive = link.href === "/" ? pathname === "/" : pathname.startsWith(link.href); return ( setMobileMenuOpen(false)} className={`flex items-center justify-between px-3 py-2 text-xs transition-colors ${ isActive ? "bg-stone-200/70 text-stone-950 font-bold" : "text-stone-700 hover:bg-stone-100" }`} > {link.label} {link.badge && ( {link.badge} )} ); })}
)}
); }