import React from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { useDemoStore } from '../../mock/store'; import { BUSINESS_PROFILES } from '../../core/profiles/profiles'; import { SYSTEM_ROLES } from '../../core/permissions/types'; import { SYSTEM_MODULES } from '../../core/modules/registry'; import { Button } from '../../shared/components/Button'; import { Search, Plus, Bell, Sun, Moon, Sparkles, Monitor, Tablet, Smartphone, ChevronDown, MapPin, Shield, Layers, } from 'lucide-react'; export const Topbar: React.FC = () => { const { theme, setTheme, viewportMode, setViewportMode, currentProfileId, setProfileId, currentRoleId, setRoleId, activeLocation, setActiveLocation, setIsCommandPaletteOpen, setIsQuickActionsOpen, setIsNotificationsOpen, setIsAiDrawerOpen, notifications, getActiveProfile, getActiveCapabilities, } = useDemoStore(); const location = useLocation(); const navigate = useNavigate(); const profile = getActiveProfile(); const capabilities = getActiveCapabilities(); const currentRole = SYSTEM_ROLES[currentRoleId]; const unreadNotificationsCount = notifications.filter((n) => !n.read).length; // Determine current active module from route const currentPath = location.pathname; const currentModule = SYSTEM_MODULES.find((m) => { if (m.route === '/') return currentPath === '/'; return currentPath.startsWith(m.route); }) || SYSTEM_MODULES[0]; // For operations, tabs are dynamic based on active profile & capabilities! const getSubtabs = () => { if (currentModule.id === 'operations') { return profile.operationsTabs.filter((tab) => { if (!tab.requiredCapability) return true; return capabilities[tab.requiredCapability]; }); } return currentModule.sections.filter((sec) => { if (!sec.requiredCapability) return true; return capabilities[sec.requiredCapability]; }); }; const activeSubtabs = getSubtabs(); return (
{/* Upper Control Bar */}
{/* Left: Profile & Location controls */}
{/* Profile Switcher */}
Профиль бизнеса {profile.name}
{/* Dropdown Menu */}
Отраслевые профили Кроны
{Object.values(BUSINESS_PROFILES).map((p) => ( ))}
{/* Location Selector */}
{activeLocation}
Точки продаж / Локации
{profile.locations.map((loc) => ( ))}
{/* Role (RBAC) Switcher */}
Роль {currentRole.badge}
Переключение роли (RBAC)
{Object.values(SYSTEM_ROLES).map((r) => ( ))}
{/* Center: Global Search & Shortcuts */}
{/* Right: Quick actions, AI, Themes, Viewports, Notifications */}
{/* AI trigger */} {/* Quick Action (+) button */} {/* Viewport Switcher */}
{/* Theme Switcher */}
{/* Notifications bell */}
{/* Horizontal Module Subnavigation Tabs */} {activeSubtabs.length > 0 && ( )}
); };