import { expansionMenuItem, disabledMenuItem } from '../utils';
import { getScopes } from '@utils/scopes';
import { USER_SCOPES } from '@constants/entities/Scope';

import organizationsRoute from './organizations';
import accountsRoute from './accounts';
import departmentsRoute from './departments';
import services from '@router/services/routes';
import processesRoutes from '@router/processes/routes';
import userTasksRoutes from '@router/user-tasks/routes';

export default function createRoute({ path, icon, label, order }) {
  return expansionMenuItem({
    path,
    label,
    icon,
    order,
    children: [
      expansionMenuItem({
        path: 'users',
        label: 'Администрирование УЗ',
        children: [
          accountsRoute({
            path: 'accounts',
            // icon: 'pgs-database',
            label: 'Сотрудники и роли',
            // order: 11,
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSARIAT_ADMINISTRATOR,
              USER_SCOPES.SECURITY_ADMINISTRATOR,
            ]),
          }),
          {
            name: 'roles', // Роли
            component: () => import('@/recruits/components/roles/index.vue'),
            path: 'roles',
            meta: {
              scopes: getScopes([USER_SCOPES.SECURITY_ADMINISTRATOR]),
              label: 'Роли',
              place: 'drawer',
            },
          },
          {
            component: () => import('@/recruits/layouts/basic-list-layout.vue'),
            path: 'logs',
            children: [
              {
                name: 'log-auth', // Смена адреса регистрации
                component: () => import('@/recruits/components/log/log-auth'),
                path: 'authentication',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SECURITY_ADMINISTRATOR,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                  ]),
                  label: 'Журнал авторизации',
                  place: 'drawer',
                },
              },
              {
                name: 'user-actions', // Смена адреса регистрации
                component: () => import('@/recruits/components/log/user-actions'),
                path: 'actions',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SECURITY_ADMINISTRATOR,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                  ]),
                  label: 'Журнал пользовательских операций',
                  place: 'drawer',
                },
              },
              {
                name: 'admin-actions',
                component: () =>
                  import('@/recruits/components/log/admin-actions'),
                path: 'admin-actions',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SECURITY_ADMINISTRATOR,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                  ]),
                  label: 'Журнал событий безопасности',
                  place: 'drawer',
                },
              },
            ],
          },
        ],
      }),
      ...services,
      ...processesRoutes,
      ...userTasksRoutes,
      organizationsRoute({
        path: 'organizations',
        // icon: 'pgs-database',
        label: 'Организации',
        // order: 11,
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSARIAT_ADMINISTRATOR,
          USER_SCOPES.SECURITY_ADMINISTRATOR,
        ]),
      }),
      departmentsRoute({
        path: 'departments',
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSARIAT_ADMINISTRATOR,
          USER_SCOPES.SECURITY_ADMINISTRATOR,
        ]),
      }),
    ],
  });
}
