import { useMemo, useState, type ReactNode } from 'react'; import { Bell, ChevronDown, ChevronRight, Menu, Search, UserRound } from 'lucide-react'; import { Button } from '../components/ui'; import { cn } from '../lib/utils'; import { navGroups } from './navigation'; type AppLayoutProps = { children: ReactNode; currentPath: string; onNavigate: (path: string) => void; }; function isChildActive(item: { path?: string; children?: Array<{ path: string }> }, currentPath: string) { if (item.path === currentPath) return true; return item.children?.some((child) => child.path === currentPath) ?? false; } export function AppLayout({ children, currentPath, onNavigate }: AppLayoutProps) { const [openGroups, setOpenGroups] = useState>({}); const [menuSearch, setMenuSearch] = useState(''); const normalizedSearch = menuSearch.trim().toLowerCase(); const visibleGroups = useMemo(() => { if (!normalizedSearch) return navGroups; return navGroups .map((group) => ({ ...group, items: group.items.flatMap((item) => { const parentMatched = item.label.toLowerCase().includes(normalizedSearch); if ('children' in item && item.children) { const children = item.children.filter((child) => child.label.toLowerCase().includes(normalizedSearch)); if (parentMatched) return [item]; if (children.length) return [{ ...item, children }]; return []; } return parentMatched ? [item] : []; }) })) .filter((group) => group.items.length > 0); }, [normalizedSearch]); return (
setMenuSearch(event.target.value)} />
{children}
); } export function PageTitle({ eyebrow, title, description, actions }: { eyebrow: string; title: string; description?: string; actions?: ReactNode; }) { return (

{eyebrow}

{title}

{description ?

{description}

: null}
{actions ?
{actions}
: null}
); }