"use client"; import Image from "next/image"; import Logo from "@/image/Logo.svg"; import { ListIcon, XIcon } from "@phosphor-icons/react/dist/ssr"; import Link from "next/link"; import { useState, useEffect } from "react"; import { usePathname } from "next/navigation"; export default function Navbar() { const [open, setOpen] = useState(false); const [activeSection, setActiveSection] = useState(""); const pathname = usePathname(); const isContact = pathname === "/contact"; const active = isContact ? "contact" : activeSection; const hideMenu = ["/perubahan-pricing-waba"].some((path) => pathname.includes(path)); const menu = [ { label: "About Us", url: "/#about-us", id: "about-us" }, { label: "Services", url: "/#services", id: "services" }, { label: "Portfolio", url: "/#portfolio", id: "portfolio" }, { label: "Process", url: "/#process", id: "process" }, { label: "Contact", url: "/contact", id: "contact" }, ]; useEffect(() => { if (isContact) return; const ids = ["about-us", "services", "portfolio", "process"]; const sections = ids.map((id) => document.getElementById(id)).filter(Boolean) as HTMLElement[]; const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) setActiveSection(entry.target.id); }); }, { rootMargin: "-50% 0px -50% 0px" } ); sections.forEach((section) => observer.observe(section)); return () => observer.disconnect(); }, [isContact]); return ( <>
logo
{menu?.map((item) => (
{item.label}
))}
{open &&
setOpen(false)} />}
logo
{menu?.map((item) => ( setOpen(false)}>
{item.label}
))}
); }