'use client'; import Link from 'next/link'; import { useEffect, useRef, useState } from 'react'; type NavLink = { href: string; label: string }; type NavSection = { title: string; links: NavLink[] }; export default function NavDropdown({ label, links, sections, }: { label: string; links?: NavLink[]; sections?: NavSection[]; }) { const [open, setOpen] = useState(false); const ref = useRef(null); useEffect(() => { const onClickOutside = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); }; document.addEventListener('mousedown', onClickOutside); return () => document.removeEventListener('mousedown', onClickOutside); }, []); return (
{open && (
{sections ? ( sections.every((s) => s.links.length === 0) ? (

Coming soon.

) : (
{sections .filter((s) => s.links.length > 0) .map((section) => (

{section.title}

{section.links.map((link) => ( setOpen(false)} className="block px-4 py-2.5 text-sm hover:bg-surface" > {link.label} ))}
))}
) ) : links && links.length > 0 ? ( links.map((link) => ( setOpen(false)} className="block px-4 py-3 text-sm hover:bg-surface" > {link.label} )) ) : (

Coming soon.

)}
)}
); }