"use client"; import { LocaleLink, useLocalePathname } from "@i18n/routing"; import { config } from "@repo/config"; import { useSession } from "@saas/auth/hooks/use-session"; import { ColorModeToggle } from "@shared/components/ColorModeToggle"; import { LocaleSwitch } from "@shared/components/LocaleSwitch"; import { Logo } from "@shared/components/Logo"; import { Button } from "@ui/components/button"; import { Sheet, SheetContent, SheetTitle, SheetTrigger, } from "@ui/components/sheet"; import { cn } from "@ui/lib"; import { MenuIcon } from "lucide-react"; import { useTranslations } from "next-intl"; import NextLink from "next/link"; import { Suspense, useEffect, useState } from "react"; import { useDebounceCallback } from "usehooks-ts"; export function NavBar() { const t = useTranslations(); const { user } = useSession(); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const localePathname = useLocalePathname(); const [isTop, setIsTop] = useState(true); const debouncedScrollHandler = useDebounceCallback( () => { setIsTop(window.scrollY <= 10); }, 150, { maxWait: 150, }, ); useEffect(() => { window.addEventListener("scroll", debouncedScrollHandler); debouncedScrollHandler(); return () => { window.removeEventListener("scroll", debouncedScrollHandler); }; }, [debouncedScrollHandler]); useEffect(() => { setMobileMenuOpen(false); }, [localePathname]); const isDocsPage = localePathname.startsWith("/docs"); const menuItems: { label: string; href: string; }[] = [ { label: t("common.menu.pricing"), href: "/#pricing", }, { label: t("common.menu.faq"), href: "/#faq", }, { label: t("common.menu.blog"), href: "/blog", }, { label: t("common.menu.changelog"), href: "/changelog", }, ...(config.contactForm.enabled ? [ { label: t("common.menu.contact"), href: "/contact", }, ] : []), { label: t("common.menu.docs"), href: "/docs", }, ]; const isMenuItemActive = (href: string) => localePathname.startsWith(href); return ( ); }