"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { MenuIcon } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; import { NAV_ITEMS } from "@/components/nav-config"; import { ThemeToggle } from "@/components/theme-toggle"; // --------------------------------------------------------------------------- // Mobile header (sm:hidden) // // Single-row layout: // ┌──┐ ┌────┐ // │cm│ Page title │menu│ // └──┘ └────┘ // // The brand mark on the left links home. The page title (derived from // the current nav route) gives the user a "you are here" cue without // waiting for the page content to render. The menu button on the right // opens a Sheet with the full nav list and the theme toggle. // --------------------------------------------------------------------------- function MobileHeader() { const pathname = usePathname(); const [open, setOpen] = useState(false); // Close the drawer when the route changes (i.e. the user picked a nav // item). Without this, navigating leaves the sheet open over the new // page until the user dismisses it manually. useEffect(() => { setOpen(false); }, [pathname]); const currentItem = NAV_ITEMS.find(({ href }) => href === "/" ? pathname === "/" : pathname.startsWith(href), ); const title = currentItem?.label ?? "WhatsApp Bot"; return (
cm {title} cm WhatsApp Bot Primary navigation menu
); } // --------------------------------------------------------------------------- // Sidebar (desktop only — hidden below sm) // --------------------------------------------------------------------------- function Sidebar() { const pathname = usePathname(); return ( ); } // --------------------------------------------------------------------------- // AppShell — the outer container // --------------------------------------------------------------------------- interface AppShellProps { children: React.ReactNode; } export function AppShell({ children }: AppShellProps) { return ( <> {/* Desktop sidebar */} {/* Mobile header (single row: brand · title · menu) */} {/* Main content Mobile: push down for the h-14 header (56px) plus a small gap so page titles don't kiss the bottom edge of the nav. Desktop: push right for the sidebar (sm:pl-56), no top offset. */}
{children}
); }