"use client"; import React from "react"; import { usePathname, useRouter } from "next/navigation"; import Link from "next/link"; import Image from "next/image"; import { cn } from "@/shared/utils/utils"; import { appConfig, isActiveFeature } from "@/shared/config/app-config"; import { useAuthSession } from "@/shared/hooks/use-session"; import { handleLogout } from "@/shared/hooks/use-auth-api"; import { Button } from "../button/button"; const navigation = [ { name: "Katalog Mapset", href: "#catalog" }, { name: "Daftar OPD", href: "#organization" }, { name: "Statistik Konten", href: "#statistic" }, isActiveFeature.news && { name: "Berita dan Pengumuman", href: "#news" }, ]; export function Header() { const [isScrolled, setIsScrolled] = React.useState(false); const pathname = usePathname(); const router = useRouter(); const { session, isAuthenticated } = useAuthSession(); React.useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 10); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const handleNavigation = ( e: React.MouseEvent, href: string, ) => { e.preventDefault(); const fixedHeaderHeight = 64; if (pathname === "/") { const targetElement = document.querySelector(href); if (targetElement) { const elementTop = targetElement.getBoundingClientRect().top + window.pageYOffset; const offsetTop = elementTop - fixedHeaderHeight; window.scrollTo({ top: offsetTop, behavior: "smooth", }); } } else { router.push(`/${href}`); } }; const handleLogin = () => { router.push("/auth/admin/login?callbackUrl=/admin"); }; return (
Satu Peta
{isAuthenticated ? (
Hi, {session?.user?.name}
) : ( )}
); }