/** * Sidebar navigation — RBAC-aware, Tailwind CSS. * Разработчик: АО «REFLY» */ 'use client'; import { useState } from 'react'; import { useDarkMode } from '@/hooks/useDarkMode'; import Link from 'next/link'; import GlobalSearch from './GlobalSearch'; import { usePathname } from 'next/navigation'; import NotificationBell from './NotificationBell'; import { useAuth, UserRole } from '@/lib/auth-context'; import { sidebarIcons, commonIcons } from '@/icons/refly-icons'; import type { SidebarKey } from '@/icons/refly-icons'; import { Icon } from '@/components/Icon'; import ReflyLogo from '@/components/ReflyLogo'; interface MenuItem { name: string; path: string; iconKey: SidebarKey; roles?: UserRole[]; } const menuItems: MenuItem[] = [ { name: 'Дашборд', path: '/dashboard', iconKey: 'dashboard' }, { name: 'Организации', path: '/organizations', iconKey: 'organizations' }, { name: 'ВС и типы', path: '/aircraft', iconKey: 'aircraft' }, { name: 'Заявки', path: '/applications', iconKey: 'applications' }, { name: 'Чек-листы', path: '/checklists', iconKey: 'checklists' }, { name: 'Аудиты', path: '/audits', iconKey: 'audits' }, { name: 'Риски', path: '/risks', iconKey: 'risks' }, { name: 'Пользователи', path: '/users', iconKey: 'users', roles: ['admin', 'authority_inspector'] }, { name: 'Лётная годность', path: '/airworthiness', iconKey: 'airworthiness' }, { name: 'Календарь ТО', path: '/calendar', iconKey: 'calendar' }, { name: 'Контроль ЛГ', path: '/airworthiness-core', iconKey: 'airworthiness-core' }, { name: 'Тех. обслуживание', path: '/maintenance', iconKey: 'maintenance' }, { name: 'Дефекты', path: '/defects', iconKey: 'defects' }, { name: 'Модификации', path: '/modifications', iconKey: 'modifications' }, { name: 'Документы', path: '/documents', iconKey: 'documents' }, { name: 'Inbox', path: '/inbox', iconKey: 'inbox' }, { name: 'Нормативные документы', path: '/regulations', iconKey: 'regulations' }, { name: 'Мониторинг', path: '/monitoring', iconKey: 'monitoring', roles: ['admin', 'authority_inspector'] }, { name: 'История изменений', path: '/audit-history', iconKey: 'audit-history', roles: ['admin', 'authority_inspector'] }, { name: 'API Документация', path: '/api-docs', iconKey: 'api-docs', roles: ['admin'] }, { name: 'Аналитика', path: '/analytics', iconKey: 'analytics', roles: ['admin', 'authority_inspector'] }, { name: 'Персонал ПЛГ', path: '/personnel-plg', iconKey: 'personnel-plg' }, { name: 'Профиль', path: '/profile', iconKey: 'profile' }, { name: 'Справка', path: '/help', iconKey: 'help' }, { name: 'Настройки', path: '/settings', iconKey: 'settings' }, { name: 'ФГИС РЭВС', path: '/fgis-revs', iconKey: 'fgis-revs', roles: ['admin'] }, { name: 'Регулятор (Минтранс, ФАВТ, Ространснадзор)', path: '/regulator', iconKey: 'regulator', roles: ['admin', 'favt_inspector'] }, ]; export default function Sidebar() { const pathname = usePathname(); const { user, logout, hasRole } = useAuth(); const [mobileOpen, setMobileOpen] = useState(false); const { isDark, toggle: toggleDark } = useDarkMode(); const visibleItems = menuItems.filter(item => !item.roles || item.roles.some(r => hasRole(r))); return ( <> {/* Mobile hamburger */} {/* Mobile overlay */} {mobileOpen &&
setMobileOpen(false)} />} ); }