diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index 9843565..50f41e8 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -40,10 +40,25 @@ export function Sidebar({ open, onClose }: SidebarProps) { const navigate = useNavigate() const isAdmin = user?.role === 'super_admin' - const isHousekeeper = user?.role === 'housekeeper' const isModuleActive = (id: string) => statuses[id] === 'active' || statuses[id] === 'trial' + // Role-based permission map (which module keys each role can access) + const ROLE_PERMS: Record = { + hotel_admin: ['*'], + manager: ['*'], + receptionist: ['calendar','bookings','guests','rooms','availability','housekeeping','room_service','rental','pos','reviews','reports'], + housekeeper: ['calendar','housekeeping','maintenance','rooms'], + accountant: ['calendar','reports','pos','discounts','tariffs','pricing','loyalty'], + security: ['calendar','bookings'], + technician: ['calendar','housekeeping','maintenance','rooms'], + } + const can = (permission: string) => { + const role = user?.role ?? 'housekeeper' + const perms = ROLE_PERMS[role] ?? [] + return perms.includes('*') || perms.includes(permission) + } + // Core modules with dedicated nav positions (not shown in generic module list) const CORE_MODULE_IDS = ['channel-manager', 'rental'] @@ -117,35 +132,33 @@ export function Sidebar({ open, onClose }: SidebarProps) {

Основное

- - {!isHousekeeper && ( - <> - - - - - + {can('calendar') && } + {can('bookings') && } + {can('guests') && } + {can('rooms') && } + {can('rooms') && } + {can('availability') && } - {/* ── Цены ── */} -

- Цены и тарифы -

- - - - {isModuleActive('rental') && ( - - )} - + {/* ── Цены ── */} + {(can('tariffs') || can('pricing') || can('discounts') || (can('rental') && isModuleActive('rental'))) && ( +

+ Цены и тарифы +

+ )} + {can('tariffs') && } + {can('pricing') && } + {can('discounts')&& } + {can('rental') && isModuleActive('rental') && ( + )} {/* ── Модули ── */} - {(isModuleActive('housekeeping') || (!isHousekeeper && activeModuleItems.length > 0)) && ( + {(can('housekeeping') && isModuleActive('housekeeping') || (activeModuleItems.some(m => can(m.id)) )) && (

Модули

)} - {isModuleActive('housekeeping') && ( + {can('housekeeping') && isModuleActive('housekeeping') && ( <> - {!isHousekeeper && ( - - )} + {can('maintenance') && } )} - {!isHousekeeper && activeModuleItems.map(m => ( + {activeModuleItems.filter(m => can(m.id)).map(m => ( + Управление +

+ )} + {can('users') && } + {can('loyalty') && } + {can('maintenance')&& } + {can('rooms') && } + {can('channels') && isModuleActive('channel-manager') && ( + m.id === 'channel-manager')!.sidebarItem!.icon} + label="Каналы" + onClick={onClose} + /> + )} + {can('settings') && } + {can('settings') && } + {can('settings') && ( <> -

- Управление -

- - - - - {isModuleActive('channel-manager') && ( - m.id === 'channel-manager')!.sidebarItem!.icon} - label="Каналы" - onClick={onClose} - /> - )} - - -

Разработчикам