"use client" import { useEffect, useState } from "react" import Link from "next/link" import { usePathname } from "next/navigation" import { ChevronRight, HelpCircle, LayoutGrid, Menu, Package, Settings, ShoppingCart, X, type LucideIcon, } from "lucide-react" import { cn } from "@/lib/utils" const navItems: { title: string; href: string; icon: LucideIcon; chevron?: boolean }[] = [ { title: "Dashboard", href: "/dashboard", icon: LayoutGrid }, { title: "Products", href: "/dashboard/products", icon: Package, chevron: true }, { title: "Orders", href: "/dashboard/orders", icon: ShoppingCart, chevron: true }, { title: "Settings", href: "/dashboard/settings", icon: Settings, chevron: true }, { title: "Help", href: "/dashboard/help", icon: HelpCircle }, ] function SidebarContent({ collapsed, onCollapse, onClose, pathname, isMobile, }: { collapsed: boolean onCollapse: () => void onClose?: () => void pathname: string isMobile: boolean }) { return ( ) } export function AppSidebar() { const pathname = usePathname() const [collapsed, setCollapsed] = useState(false) const [mobileOpen, setMobileOpen] = useState(false) // Close mobile menu on route change useEffect(() => { const timeout = setTimeout(() => setMobileOpen(false), 0) return () => clearTimeout(timeout) }, [pathname]) // Prevent body scroll when mobile menu is open useEffect(() => { document.body.style.overflow = mobileOpen ? "hidden" : "" return () => { document.body.style.overflow = "" } }, [mobileOpen]) return ( <> {/* ── Desktop sidebar ─────────────────────────────── */}
setCollapsed((v) => !v)} pathname={pathname} isMobile={false} />
{/* ── Mobile hamburger trigger ─────────────────────── */} {/* ── Mobile overlay backdrop ──────────────────────── */} {mobileOpen && (
setMobileOpen(false)} aria-hidden="true" /> )} {/* ── Mobile drawer ────────────────────────────────── */}
{}} onClose={() => setMobileOpen(false)} pathname={pathname} isMobile={true} />
) }