Files
mkd/constants/roleAccess.ts
2026-02-04 00:17:04 +05:00

61 lines
1.8 KiB
TypeScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Единый источник прав портала: роли, разделы по умолчанию, scope по умолчанию.
* Используется на фронте и синхронизируется с backend/constants/roleAccess.js.
*/
export type UserRole =
| 'DIRECTOR'
| 'ENGINEER'
| 'MASTER'
| 'LAWYER'
| 'FINANCIER'
| 'HR_MANAGER'
| 'PR_MANAGER';
/** Названия ролей для UI */
export const ROLE_NAMES: Record<UserRole, string> = {
DIRECTOR: 'Директор',
ENGINEER: 'Гл. Инженер',
MASTER: 'Мастер',
LAWYER: 'Юрист',
FINANCIER: 'Финансист',
HR_MANAGER: 'HR-менеджер',
PR_MANAGER: 'PR-менеджер',
};
/** Разделы по умолчанию для каждой роли (при пустом permissions) */
export const ROLE_ACCESS: Record<UserRole, string[]> = {
DIRECTOR: ['all'],
ENGINEER: ['dashboard', 'objects', 'requests', 'office', 'development'],
MASTER: ['objects', 'requests'],
LAWYER: ['dashboard', 'legal', 'objects', 'requests'],
FINANCIER: ['dashboard', 'finance', 'office', 'objects'],
HR_MANAGER: ['dashboard', 'hr', 'office'],
PR_MANAGER: ['dashboard', 'pr', 'requests'],
};
/** Scope по умолчанию для каждой роли */
export const ROLE_DEFAULT_SCOPE: Record<UserRole, 'all' | 'own_district'> = {
DIRECTOR: 'all',
ENGINEER: 'all',
MASTER: 'own_district',
LAWYER: 'all',
FINANCIER: 'all',
HR_MANAGER: 'all',
PR_MANAGER: 'all',
};
/** Список кодов разделов портала (порядок для allowedSections) */
export const SECTION_IDS: string[] = [
'dashboard',
'objects',
'requests',
'pr',
'finance',
'legal',
'development',
'hr',
'office',
'admin',
];