import { useState } from 'react'; import { Outlet, NavLink, Link } from 'react-router-dom'; import { useAuth } from '../hooks/useAuth'; import { useTheme } from '../hooks/useTheme'; interface NavItem { label: string; path: string; icon: React.ReactNode; adminManagerOnly?: boolean; } interface NavGroup { label: string; items: NavItem[]; adminOnly?: boolean; } const iconProps = { fill: 'none' as const, viewBox: '0 0 24 24', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const, width: 18, height: 18, }; const IconDashboard = () => ( ); const IconRequestLog = () => ( ); const IconServiceStatus = () => ( ); const IconServiceStats = () => ( ); const IconUserStats = () => ( ); const IconApiStats = () => ( ); const IconTenantStats = () => ( ); const IconUsageTrend = () => ( ); const IconMyKey = () => ( ); const IconKeyRequest = () => ( ); const IconKeyManage = () => ( ); const IconService = () => ( ); const IconDomain = () => ( ); const IconApiManage = () => ( ); const IconSampleCode = () => ( ); const navGroups: NavGroup[] = [ { label: '모니터링', items: [ { label: '요청 로그', path: '/monitoring/request-logs', icon: }, { label: '서비스 상태', path: '/monitoring/service-status', icon: }, ], }, { label: '통계', items: [ { label: '서비스 통계', path: '/statistics/services', icon: }, { label: '사용자 통계', path: '/statistics/users', icon: }, { label: 'API 통계', path: '/statistics/apis', icon: }, { label: '부서 통계', path: '/statistics/tenants', icon: }, { label: '사용량 추이', path: '/statistics/usage-trend', icon: }, ], }, { label: 'API 키', items: [ { label: '내 키', path: '/apikeys/my-keys', icon: }, { label: '키 신청', path: '/apikeys/request', icon: }, { label: '키 관리', path: '/apikeys/admin', icon: , adminManagerOnly: true }, ], }, { label: '관리자', adminOnly: true, items: [ { label: '서비스', path: '/admin/services', icon: }, { label: '도메인', path: '/admin/domains', icon: }, { label: 'API 관리', path: '/admin/apis', icon: }, { label: '공통 샘플 코드', path: '/admin/sample-code', icon: }, { label: '사용자', path: '/admin/users', icon: }, { label: '부서', path: '/admin/tenants', icon: }, ], }, ]; const ROLES = ['ADMIN', 'MANAGER', 'USER'] as const; const MainLayout = () => { const { user, setRole } = useAuth(); const { theme, toggleTheme } = useTheme(); const [openGroups, setOpenGroups] = useState>({ '모니터링': true, '통계': true, 'API 키': true, '관리자': true, }); const toggleGroup = (label: string) => { setOpenGroups((prev) => ({ ...prev, [label]: !prev[label] })); }; const isAdminOrManager = user?.role === 'ADMIN' || user?.role === 'MANAGER'; return (
{/* Sidebar */} {/* Main Content */}
{/* Header */}
{/* 테마 토글 */} {/* 역할 스위처 */}
{ROLES.map((role) => ( ))}
{/* Content */}
); }; export default MainLayout;