"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useMemo, useState } from "react"; import { useLanguage } from "@/app/context/LanguageContext"; import { useTranslation } from "@/app/hooks/useTranslation"; export default function HeaderClient({ brand, }: { brand: { name: string }; }) { const pathname = usePathname(); const [mobileOpen, setMobileOpen] = useState(false); const { lang, setLang } = useLanguage(); const { site } = useTranslation(); const isHome = pathname === "/" || pathname === "/ipv6" || pathname === "/ipv6/"; const navItems = useMemo( () => site.nav.filter((x) => !["/", "/registration", "/sponsor"].includes(x.href)), [site.nav], ); const isActive = (href: string) => { if (href === "/") return isHome; return pathname === href || pathname === `/ipv6${href}` || pathname?.startsWith(`${href}/`) || pathname?.startsWith(`/ipv6${href}/`); }; const loginLabel = lang === "vi" ? "Đăng Nhập" : "Log In"; const loginNowLabel = lang === "vi" ? "Đăng Nhập" : "Log In"; const backLabel = lang === "vi" ? "Trang Chủ" : "Home"; useEffect(() => { if (!mobileOpen) return; document.body.style.overflow = "hidden"; return () => { document.body.style.overflow = ""; }; }, [mobileOpen]); return ( <>
{brand.name}
{/* Language Switcher — Desktop */}
|
{loginLabel}
{/* Mobile Menu Overlay */}
setMobileOpen(false)} /> {/* Mobile Menu Side Drawer */}
Menu
{/* Language Switcher — Mobile */}
setMobileOpen(false)} > {loginNowLabel}
); }