'use client' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { useState, useEffect } from 'react' const NAV_LINKS = [ { href: '/', label: 'Home' }, { href: '/groups', label: 'Groups' }, { href: '/stats', label: 'Statistics' }, { href: '/history', label: 'History' }, ] export function Nav() { const pathname = usePathname() const router = useRouter() const [q, setQ] = useState('') const [open, setOpen] = useState(false) // Close menu on route change useEffect(() => { setOpen(false) }, [pathname]) // Lock body scroll when menu open useEffect(() => { document.body.style.overflow = open ? 'hidden' : '' return () => { document.body.style.overflow = '' } }, [open]) const handleSearch = (e: React.FormEvent) => { e.preventDefault() if (q.trim()) { router.push(`/search?q=${encodeURIComponent(q.trim())}`) setOpen(false) setQ('') } } const isActive = (href: string) => href === '/' ? pathname === '/' : pathname.startsWith(href) return ( <> {/* Mobile menu overlay */} {open && (
setOpen(false)} /> )} {/* Mobile menu panel */}
{NAV_LINKS.map(({ href, label }) => ( {label} ))}
setQ(e.target.value)} placeholder="Search players, teams, tournaments…" className="w-full pl-9 pr-4 py-3 rounded-xl text-[14px] text-text outline-none bg-green/[6%] border border-green/[18%]" />
) }