'use client'; import { Button } from '@/components/ui/Button'; import { Icon } from '@/components/ui/Icon'; import { cn } from '@/lib/utils'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import React, { useEffect, useState } from 'react'; interface SidebarProps { isOpen?: boolean; onClose?: () => void; } const NAVIGATION_SECTIONS = [ { group: 'Main', items: [ { name: 'Dashboard', href: '/vcon/dashboard', icon: 'LayoutDashboard' }, { name: 'Events', href: '/vcon/data', icon: 'Activity' }, { name: 'Clients', href: '/vcon/clients', icon: 'Key' }, { name: 'Export', href: '/vcon/export', icon: 'Download' }, { name: 'Storage', href: '/vcon/storage', icon: 'HardDrive' }, ], }, { group: 'System', items: [ { name: 'Python SDK', href: '/vcon/sdk', icon: 'FileCode2' }, { name: 'Simulator', href: '/vcon/simulator', icon: 'Play' }, { name: 'Settings', href: '/vcon/settings', icon: 'Sliders' }, { name: 'Profile', href: '/vcon/profile', icon: 'User' }, ], }, ]; export const Sidebar: React.FC = ({ isOpen = false, onClose, }) => { const pathname = usePathname(); const [isSigningOut, setIsSigningOut] = useState(false); const [theme, setTheme] = useState<'dark' | 'light'>('dark'); useEffect(() => { const saved = localStorage.getItem('datastack-theme') as 'dark' | 'light' | null; const initial = saved === 'light' ? 'light' : 'dark'; setTheme(initial); document.documentElement.classList.toggle('light', initial === 'light'); document.documentElement.classList.toggle('dark', initial === 'dark'); }, []); const toggleTheme = () => { const nextTheme = theme === 'dark' ? 'light' : 'dark'; setTheme(nextTheme); localStorage.setItem('datastack-theme', nextTheme); document.documentElement.classList.toggle('light', nextTheme === 'light'); document.documentElement.classList.toggle('dark', nextTheme === 'dark'); }; const signOut = async () => { setIsSigningOut(true); try { const response = await fetch('/api/auth/logout', { method: 'POST', credentials: 'include', }); if (!response.ok) throw new Error('Unable to sign out'); window.location.assign('/vcon/login'); } catch { setIsSigningOut(false); } }; return ( <> {isOpen && (
)} ); }; export default Sidebar;