"use client"; import { useState, useEffect } from "react"; import { cn, getCookiesDecrypt } from "@/lib/utils"; import Image from "next/image"; import Link from "next/link"; 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 } from "next/navigation"; 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: "/public/publication/bumn" }, { label: "Pemerintah Daerah", href: "/public/publication/pemerintah-daerah" }, ]; export default function Navbar() { const [isSidebarOpen, setIsSidebarOpen] = useState(false); const [user, setUser] = useState<{ id: number; name: string; avatar: string; } | null>(null); const [isDropdownOpen, setDropdownOpen] = useState(false); const [showProfileMenu, setShowProfileMenu] = useState(false); const pathname = usePathname(); useEffect(() => { const roleId = getCookiesDecrypt("urie"); console.log("roleId", roleId); switch (roleId) { case "3": setUser({ id: 3, name: "Mabes Polri - Approver", avatar: "/contributor.png", }); break; case "7": setUser({ id: 7, name: "DivHumas - RoMulmed - BagDise", avatar: "/contributor.png", }); break; case "6": setUser({ id: 11, name: "jurnalis-kompas1", avatar: "/contributor.png", }); break; default: setUser(null); } }, []); const isLoggedIn = user !== null; const filteredNavItems = isLoggedIn ? NAV_ITEMS.filter((item) => item.label !== "Mengikuti") : NAV_ITEMS; const handleLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { Cookies.remove(cookieName); }); window.location.href = "/"; setUser(null); setShowProfileMenu(false); }; return (
Logo
{" "} setIsSidebarOpen(true)} />
{isSidebarOpen && (

Bahasa

Fitur

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

Subscribe to Our Newsletter

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