/** * 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'; interface MenuItem { name: string; path: string; icon: string; roles?: UserRole[]; } const menuItems: MenuItem[] = [ { name: 'Дашборд', path: '/dashboard', icon: '📊' }, { name: 'Организации', path: '/organizations', icon: '🏢' }, { name: 'ВС и типы', path: '/aircraft', icon: '✈️' }, { name: 'Заявки', path: '/applications', icon: '📋' }, { name: 'Чек-листы', path: '/checklists', icon: '✅' }, { name: 'Аудиты', path: '/audits', icon: '🔍' }, { name: 'Риски', path: '/risks', icon: '⚠️' }, { name: 'Пользователи', path: '/users', icon: '👥', roles: ['admin', 'authority_inspector'] }, { name: 'Лётная годность', path: '/airworthiness', icon: '📜' }, { name: '📅 Календарь ТО', path: '/calendar', icon: '📅' }, { name: '🔧 Контроль ЛГ', path: '/airworthiness-core', icon: '🔧' }, { name: 'Тех. обслуживание', path: '/maintenance', icon: '🔧' }, { name: 'Дефекты', path: '/defects', icon: '🛠️' }, { name: 'Модификации', path: '/modifications', icon: '⚙️' }, { name: 'Документы', path: '/documents', icon: '📄' }, { name: 'Inbox', path: '/inbox', icon: '📥' }, { name: 'Нормативные документы', path: '/regulations', icon: '📚' }, { name: 'Мониторинг', path: '/monitoring', icon: '📈', roles: ['admin', 'authority_inspector'] }, { name: 'История изменений', path: '/audit-history', icon: '📝', roles: ['admin', 'authority_inspector'] }, { name: 'API Документация', path: '/api-docs', icon: '📖', roles: ['admin'] }, { name: '📊 Аналитика', path: '/analytics', icon: '📊', roles: ['admin', 'authority_inspector'] }, { name: '🎓 Персонал ПЛГ', path: '/personnel-plg', icon: '🎓' }, { name: '👤 Профиль', path: '/profile', icon: '👤' }, { name: '📚 Справка', path: '/help', icon: '📚' }, { name: '⚙️ Настройки', path: '/settings', icon: '⚙️' }, { name: '🏛️ ФГИС РЭВС', path: '/fgis-revs', icon: '🏛️', roles: ['admin'] }, { name: '🏛️ Панель ФАВТ', path: '/regulator', icon: '🏛️', 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)} />} ); }