import { Link, useLocation, useNavigate } from 'react-router-dom'; import { useThemeContext } from '../contexts/ThemeContext'; interface MenuItem { id: string; label: string; path: string; } interface MenuSection { id: string; label: string; shortLabel: string; icon: React.ReactNode; defaultPath: string; children: MenuItem[]; } const MENU_STRUCTURE: MenuSection[] = [ { id: 'collector', label: 'S&P Collector', shortLabel: 'Collector', icon: ( ), defaultPath: '/dashboard', children: [ { id: 'dashboard', label: '대시보드', path: '/dashboard' }, { id: 'executions', label: '실행 이력', path: '/executions' }, { id: 'recollects', label: '재수집 이력', path: '/recollects' }, { id: 'jobs', label: '작업 관리', path: '/jobs' }, { id: 'schedules', label: '스케줄', path: '/schedules' }, { id: 'timeline', label: '타임라인', path: '/schedule-timeline' }, ], }, { id: 'bypass', label: 'S&P Bypass', shortLabel: 'Bypass', icon: ( ), defaultPath: '/bypass-catalog', children: [ { id: 'bypass-catalog', label: 'API 카탈로그', path: '/bypass-catalog' }, { id: 'bypass-config', label: 'API 관리', path: '/bypass-config' }, ], }, { id: 'risk', label: 'S&P Risk & Compliance', shortLabel: 'Risk & Compliance', icon: ( ), defaultPath: '/risk-compliance-history', children: [ { id: 'risk-compliance-history', label: 'Change History', path: '/risk-compliance-history' }, { id: 'screening-guide', label: 'Screening Guide', path: '/screening-guide' }, ], }, ]; function getCurrentSection(pathname: string): MenuSection | null { for (const section of MENU_STRUCTURE) { if (section.children.some((c) => pathname === c.path || pathname.startsWith(c.path + '/'))) { return section; } } return null; } export default function Navbar() { const location = useLocation(); const navigate = useNavigate(); const { theme, toggle } = useThemeContext(); const currentSection = getCurrentSection(location.pathname); // 메인 화면에서는 숨김 if (!currentSection) return null; const isActivePath = (path: string) => { return location.pathname === path || location.pathname.startsWith(path + '/'); }; return (
{/* 1단: 섹션 탭 */}
{MENU_STRUCTURE.map((section) => ( ))}
{/* 2단: 서브 탭 */}
{currentSection?.children.map((child) => ( ))}
); }