import { ReactNode, useState, useEffect } from 'react' import { Link, useLocation } from 'react-router-dom' import { useQuery } from '@tanstack/react-query' import { ThemeToggle } from './ThemeToggle' import { Button } from './ui/Button' import { useAuth } from '../hooks/useAuth' import { checkHealth } from '../api/health' import NotificationCenter from './NotificationCenter' import SystemStatus from './SystemStatus' import { Menu, ChevronDown, ChevronRight } from 'lucide-react' interface LayoutProps { children: ReactNode } export default function Layout({ children }: LayoutProps) { const location = useLocation() const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false) const [isCollapsed, setIsCollapsed] = useState(() => { const saved = localStorage.getItem('sidebarCollapsed') return saved ? JSON.parse(saved) : false }) const [expandedMenus, setExpandedMenus] = useState([]) const { logout, user } = useAuth() useEffect(() => { localStorage.setItem('sidebarCollapsed', JSON.stringify(isCollapsed)) }, [isCollapsed]) const toggleMenu = (name: string) => { setExpandedMenus(prev => prev.includes(name) ? prev.filter(item => item !== name) : [...prev, name] ) } const { data: health } = useQuery({ queryKey: ['health'], queryFn: checkHealth, staleTime: 1000 * 60 * 60, // 1 hour }) const navigation = [ { name: 'Dashboard', path: '/', icon: '📊' }, { name: 'Proxy Hosts', path: '/proxy-hosts', icon: '🌐' }, { name: 'Remote Servers', path: '/remote-servers', icon: '🖥️' }, { name: 'Domains', path: '/domains', icon: '🌍' }, { name: 'Certificates', path: '/certificates', icon: '🔒' }, { name: 'Uptime', path: '/uptime', icon: '📈' }, { name: 'Notifications', path: '/notifications', icon: '🔔' }, { name: 'Import Caddyfile', path: '/import', icon: '📥' }, { name: 'Settings', path: '/settings', icon: '⚙️', children: [ { name: 'System', path: '/settings/system', icon: '⚙️' }, { name: 'Account', path: '/settings/account', icon: '🛡️' }, ] }, { name: 'Tasks', path: '/tasks', icon: '📋', children: [ { name: 'Backups', path: '/tasks/backups', icon: '💾' }, { name: 'Logs', path: '/tasks/logs', icon: '📝' }, ] }, ] return (
{/* Mobile Header */}

CPM+

{/* Sidebar */} {/* Overlay for mobile */} {/* Mobile Overlay */} {mobileSidebarOpen && (
setMobileSidebarOpen(false)} /> )} {/* Main Content */}
{/* Desktop Header */}

CPM+

{user && ( {user.name} )}
{children}
) }