"use client"; import { useState, useEffect } from "react"; import { cn, getCookiesDecrypt } from "@/lib/utils"; import Image from "next/image"; import { Menu, ChevronDown } from "lucide-react"; import { Button } from "../ui/button"; import Cookies from "js-cookie"; import { Card } from "../ui/card"; import { Input } from "../ui/input"; import { usePathname, useRouter } from "next/navigation"; import { Link } from "@/i18n/routing"; import { DynamicLogoTenant } from "./dynamic-logo-tenant"; const NAV_ITEMS = [ { label: "Beranda", href: "/" }, { label: "Untuk Anda", href: "/public/for-you" }, { label: "Mengikuti", href: "/auth" }, { label: "Publikasi", href: "/publikasi" }, { label: "Jadwal", href: "/public/schedule" }, ]; const PUBLIKASI_SUBMENU = [ { label: "K/L", href: "/public/publication/kl" }, { label: "BUMN", href: "/in/public/publication/bumn" }, { label: "Pemerintah Daerah", href: "/public/publication/pemerintah-daerah" }, ]; export default function Navbar() { const [isSidebarOpen, setIsSidebarOpen] = useState(false); const [isDropdownOpen, setDropdownOpen] = useState(false); const [showProfileMenu, setShowProfileMenu] = useState(false); const [isLoggedIn, setIsLoggedIn] = useState(false); const pathname = usePathname(); const router = useRouter(); // 🔍 Fungsi cek login const checkLoginStatus = () => { const roleId = getCookiesDecrypt("urie"); const fullname = Cookies.get("ufne"); return roleId && fullname ? true : false; }; useEffect(() => { setIsLoggedIn(checkLoginStatus()); }, []); const filteredNavItems = isLoggedIn ? NAV_ITEMS.filter((item) => item.label !== "Mengikuti") : NAV_ITEMS; // 🚪 Fungsi logout const handleLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { Cookies.remove(cookieName, { path: "/" }); Cookies.remove(cookieName, { path: "", domain: window.location.hostname, }); Cookies.remove(cookieName, { path: "/", domain: window.location.hostname, }); }); setIsLoggedIn(false); setShowProfileMenu(false); window.location.href = "/"; }; const username = Cookies.get("username"); const fullname = Cookies.get("ufne"); return (
Logo
setIsSidebarOpen(true)} />
{/* 🌐 NAV MENU */} {/* 🔹 PROFILE / LOGIN SECTION */} {/* 📱 SIDEBAR MOBILE */} {isSidebarOpen && (

Bahasa

Fitur

{NAV_ITEMS.map((item) => ( ))}
Tentang Kami Advertising Kontak Kami {!isLoggedIn ? ( <> Login Daftar ) : ( )}

Subscribe to Our Newsletter

setIsSidebarOpen(false)} />
)}
); }