"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { Menu, X, Home, Box, Briefcase, Newspaper, Search, Globe, LogIn, ChevronDown, Video, Music, Image as ImageIcon, FileText, } from "lucide-react"; import { fetchPublishedArticles } from "@/lib/articles-public"; const LANDING_SECTION_IDS = new Set(["products", "services"]); function scrollToSectionId(id: string) { document .getElementById(id) ?.scrollIntoView({ behavior: "smooth", block: "start" }); } export type LandingSiteNavProps = { /** GET form target for navbar search (e.g. `/news-services`). If omitted, search is display-only. */ searchFormAction?: string; searchDefaultValue?: string; searchPlaceholder?: string; /** News hub pages: “Home” → `/news-services`, plus Konten submenu in drawer */ newsHub?: boolean; }; export default function LandingSiteNav({ searchFormAction, searchDefaultValue = "", searchPlaceholder = "Search", newsHub = false, }: LandingSiteNavProps) { const pathname = usePathname(); const router = useRouter(); const [open, setOpen] = useState(false); const [openKonten, setOpenKonten] = useState(false); const [activeMenu, setActiveMenu] = useState(null); const [event, setEvent] = useState(null); const [popular, setPopular] = useState([]); useEffect(() => { const loadPopular = async () => { const res = await fetchPublishedArticles( { typeId: 1, limit: 3, page: 1, sortBy: "view_count", sort: "desc", }, { mode: "client" }, ); setPopular(res?.items ?? []); }; loadPopular(); }, []); useEffect(() => { const loadEvent = async () => { const res = await fetchPublishedArticles( { typeId: 1, limit: 1, page: 1, sortBy: "created_at", sort: "desc", }, { mode: "client" }, ); const firstItem = res?.items?.[0]; if (firstItem) { setEvent(firstItem); } }; loadEvent(); }, []); useEffect(() => { if (pathname !== "/") return; const syncFromHash = () => { const raw = window.location.hash.replace(/^#/, ""); if (!LANDING_SECTION_IDS.has(raw)) return; const el = document.getElementById(raw); if (!el) return; requestAnimationFrame(() => el.scrollIntoView({ behavior: "smooth", block: "start" }), ); }; const t = window.setTimeout(syncFromHash, 0); window.addEventListener("hashchange", syncFromHash); return () => { window.clearTimeout(t); window.removeEventListener("hashchange", syncFromHash); }; }, [pathname]); const homePath = newsHub ? "/news-services" : "/"; const goHome = () => { setOpen(false); if (pathname === homePath) { window.scrollTo({ top: 0, behavior: "smooth" }); } else { router.push(homePath); } }; function MenuItem({ icon, label, onClick, }: { icon: React.ReactNode; label: string; onClick?: () => void; }) { return (
{icon} {label}
); } const searchField = (
); return ( <> {open ? ( {/* MENU */}
} label="Home" onClick={goHome} /> } label="Product" onClick={() => setActiveMenu("product")} /> } label="Services" onClick={() => setActiveMenu("services")} /> } label="News and Services" onClick={() => setActiveMenu("news&services")} /> } label="Login" onClick={() => router.push("/auth")} />
{activeMenu === "product" && (

Product

MediaHUB Content Aggregator

Multipool Reputation Management

PR Room Opinion Management

)} {activeMenu === "services" && (

Services

Artifintel

Produksi Video Animasi

Reelithic

Qudoin

Talkshow Ai

)} {activeMenu === "news&services" && (

News & Services

setOpen(false)} >

Homepage News

setOpen(false)} >

Audio Visual

setOpen(false)} >

Audio

setOpen(false)} >

Foto

setOpen(false)} >

Teks

)}
{/* POPULAR */}

    POPULAR PAGES

    {popular.length > 0 ? ( popular.map((item) => (
  • setOpen(false)} className="hover:underline line-clamp-2 text-sm" > {item.title}
  • )) ) : (
  • Loading...
  • )}
{/* EVENT */}

Upcoming Event

{event ? (
{/* IMAGE */}
{event.thumbnailUrl ? ( {event.title} ) : (
)}
{/* TEXT */}

{event.title}

{event.description?.slice(0, 120)}...

) : (

Loading...

)}
); } function MenuItem({ icon, label }: { icon: React.ReactNode; label: string }) { return (
{label} {icon}
); }