import { useState } from 'react'; import { Outlet, NavLink } from 'react-router-dom'; import { useAuth } from '../hooks/useAuth'; import { useTheme } from '../hooks/useTheme'; interface NavGroup { label: string; items: { label: string; path: string }[]; adminOnly?: boolean; } const navGroups: NavGroup[] = [ { label: 'Monitoring', items: [ { label: 'Request Logs', path: '/monitoring/request-logs' }, { label: 'Service Status', path: '/monitoring/service-status' }, ], }, { label: 'Statistics', items: [ { label: '서비스 통계', path: '/statistics/services' }, { label: '사용자 통계', path: '/statistics/users' }, { label: 'API 통계', path: '/statistics/apis' }, { label: '테넌트 통계', path: '/statistics/tenants' }, { label: '사용량 추이', path: '/statistics/usage-trend' }, ], }, { label: 'API Keys', items: [ { label: 'My Keys', path: '/apikeys/my-keys' }, { label: 'Request', path: '/apikeys/request' }, { label: 'Admin', path: '/apikeys/admin' }, ], }, { label: 'Admin', adminOnly: true, items: [ { label: 'Services', path: '/admin/services' }, { label: 'Users', path: '/admin/users' }, { label: 'Tenants', path: '/admin/tenants' }, ], }, ]; const MainLayout = () => { const { user, logout } = useAuth(); const { theme, toggleTheme } = useTheme(); const [openGroups, setOpenGroups] = useState>({ Monitoring: true, Statistics: true, 'API Keys': true, Admin: true, }); const toggleGroup = (label: string) => { setOpenGroups((prev) => ({ ...prev, [label]: !prev[label] })); }; const handleLogout = async () => { await logout(); }; const isAdminOrManager = user?.role === 'ADMIN' || user?.role === 'MANAGER'; return (
{/* Sidebar */} {/* Main Content */}
{/* Header */}
{user?.userName} {user?.role}
{/* Content */}
); }; export default MainLayout;