"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useState, type ReactNode } from "react"; import Icon from "@/components/Icon"; import Logo from "@/components/Logo"; import SearchBar from "@/components/SearchBar"; import { ThemeToggle } from "@/components/ThemeProvider"; import { cn } from "@/lib/utils"; const NAV = [ { href: "/dashboard", label: "Overview", icon: "grid" }, { href: "/dashboard/searches", label: "Search history", icon: "history" }, { href: "/dashboard/saved", label: "Saved results", icon: "bookmark" }, { href: "/dashboard/collections", label: "Collections", icon: "folder" }, { href: "/dashboard/settings", label: "Settings", icon: "settings" }, ]; export default function DashboardShell({ children }: { children: ReactNode }) { const pathname = usePathname(); const [open, setOpen] = useState(false); useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(false); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open]); const isActive = (href: string) => href === "/dashboard" ? pathname === "/dashboard" : pathname === href || pathname.startsWith(`${href}/`); const sidebar = (
Back to Fox Search
); return (
{open && (
setOpen(false)} />
)}
{children}
); }