import { getScopes } from '@utils/scopes';
import { USER_SCOPES } from '@constants/entities/Scope';
import { expansionMenuItem, disabledMenuItem } from '../utils';
import registeredRoute from './registered';
import forCancelRegistrationRoute from './for-cancel-registration';
import personalFileRequestsRoute from './personal-file-requests';
import notificationsRoute from './notifications';
import archiveRoute from './archive';

export default function createRoute({ path, icon, label, order }) {
  return expansionMenuItem({
    path,
    label,
    icon,
    order,
    children: [
      registeredRoute({
        path: 'registered',
        // icon: 'pgs-user',
        label: 'Состоящие на учёте',
        // order: 1,
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSAR,
          USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
          USER_SCOPES.GOMU_SPECIALIST,
          USER_SCOPES.GOMU_OBSERVER,
          USER_SCOPES.SYSTEM_ADMINISTRATOR,
          USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
        ]),
      }),
      {
        component: () =>
          import('@/recruits/components/archive/record/index.vue'),
        path: 'archive/:id',
        name: 'archive-record',
        redirect: { name: 'archive-recruit-personal' },
        children: [
          {
            name: 'archive-recruit-personal',
            component: () =>
              import(
                '@/recruits/components/archive/record/tabs/personal-info.vue'
              ),
            path: 'personal',
            meta: {},
          },
          {
            name: 'archive-recruit-details',
            component: () =>
              import('@/recruits/components/archive/record/tabs/details.vue'),
            path: 'details',
            meta: {},
          },
          {
            name: 'archive-recruit-attached-documents',
            component: () =>
              import(
                '@/recruits/components/archive/record/tabs/attached-documents.vue'
              ),
            path: 'attached-documents',
            meta: {},
          },
          {
            name: 'archive-recruit-attached-decision',
            component: () =>
              import(
                '@/recruits/components/archive/record/tabs/attached-decision.vue'
              ),
            path: 'attached-decision',
            meta: {},
          },
          {
            name: 'archive-recruit-history',
            component: () =>
              import('@/recruits/components/archive/record/tabs/history.vue'),
            path: 'history',
            meta: {},
          },
          {
            name: 'archive-recruit-pf-requests',
            components: {
              masthead: () =>
                import('@/recruits/components/archive/record/header.vue'),
              default: () =>
                import(
                  '@/recruits/components/archive/record/tabs/request-personal-file.vue'
                ),
            },
            path: 'personal-file-request',
            meta: {},
          },
        ],
      },
      expansionMenuItem({
        path: 'registration',
        label: 'Постановка',
        children: [
          {
            component: () => import('@/recruits/layouts/basic-list-layout'),
            path: 'browse',
            children: [
              {
                name: 'initial-17',
                components: {
                  listButtons: () =>
                    import('@/recruits/components/initial-17/listButtons.vue'),
                  default: () => import('@/recruits/components/initial-17'),
                },
                path: 'initial-17',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
                  ]),
                  // disabled: true,
                  // clickable: false,
                  place: 'drawer',
                  label: 'Первоначальная - 17 лет',
                },
              },
              {
                name: 'initial-over-18',
                components: {
                  listButtons: () =>
                    import(
                      '@/recruits/components/initial-over-18/listButtons.vue'
                    ),
                  default: () =>
                    import('@/recruits/components/initial-over-18'),
                },
                path: 'initial-over-18',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
                  ]),
                  place: 'drawer',
                  label: 'Первоначальная - старше 18 лет',
                  storeCountGetters: 'menuCounters/initialMilRegOver18',
                },
              },
              {
                name: 'list-of-recruits', // Смена адреса
                components: {
                  listButtons: () =>
                    import('@/recruits/components/recruits/listButtons.vue'),
                  default: () => import('@/recruits/components/recruits'),
                },
                // TODO - нужен конструктор в SearchFilterUtils для передачи начальных параметров для фильтров, вместо прокидывания query в роутере
                query: {
                  statuses: [
                    'rejected',
                    'cancelled',
                    'requested',
                    'sended',
                    'nonrequested',
                  ],
                },
                path: '',
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
                  ]),
                  place: 'drawer',
                  label: 'Смена адреса',
                  storeCountGetters: 'menuCounters/militaryRegistration',
                },
              },
            ],
          },
          disabledMenuItem({
            path: 'log-object',
            label: 'Журнал постановки на ВУ',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          // {
          //   component: () => import('@/recruits/layouts/basic-list-layout.vue'),
          //   path: 'lists',
          //   children: [
          //     {
          //       name: 'log-object', // Смена адреса регистрации
          //       component: () => import('@/recruits/components/log/log-object'),
          //       path: 'log-object',
          //       meta: {
          //         label: 'Журнал постановки на учёт',
          //         place: 'drawer',
          //       },
          //     },
          //   ]
          // },
          {
            component: () => import('@/recruits/components/recruit-card'),
            path: 'card/:id',
            children: [
              {
                name: 'recruit-personal',
                component: () =>
                  import(
                    '@/recruits/components/recruit-card/personal-info.vue'
                  ),
                path: 'personal',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-details',
                component: () =>
                  import('@/recruits/components/recruit-card/details.vue'),
                path: 'details',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'application',
                component: () =>
                  import('@/recruits/components/recruit-card/application.vue'),
                path: 'application',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-attached-documents',
                component: () =>
                  import(
                    '@/recruits/components/recruit-card/attached-documents.vue'
                  ),
                path: 'attached-documents',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-attached-decision',
                component: () =>
                  import(
                    '@/recruits/components/recruit-card/attached-decision.vue'
                  ),
                path: 'attached-decision',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-history',
                component: () =>
                  import('@/recruits/components/recruit-card/history.vue'),
                path: 'history',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-summons',
                component: () =>
                  import('@/recruits/components/recruit-card/summons.vue'),
                path: 'summons',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-incidents',
                component: () =>
                  import('@/recruits/components/recruit-card/incidents.vue'),
                path: 'incidents',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-temporary-measures',
                component: () =>
                  import(
                    '@/recruits/components/recruit-card/temporary-measures.vue'
                  ),
                path: 'temporary-measures',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-pf-requests',
                component: () =>
                  import(
                    '@/recruits/components/recruit-card/request-personal-file.vue'
                  ),
                path: 'personal-file-request',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-versions',
                component: () =>
                  import('@/recruits/components/recruit-card/versions'),
                path: 'versions',
                meta: {
                  isTrackable: false,
                },
              },
              {
                name: 'recruit-extracts',
                component: () =>
                  import('@/recruits/components/recruit-card/extracts.vue'),
                path: 'extracts',
                meta: {
                  isTrackable: false,
                },
              },
            ],
          },
        ],
      }),
      forCancelRegistrationRoute({
        path: 'for-cancel-registration',
        label: 'Снятие с учёта',
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSAR,
          USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
          USER_SCOPES.GOMU_SPECIALIST,
          USER_SCOPES.GOMU_OBSERVER,
          USER_SCOPES.SYSTEM_ADMINISTRATOR,
          USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
        ]),
      }),

      personalFileRequestsRoute({
        path: 'personal-file-requests',
        // icon: 'pgs-file-search',
        label: 'Запросы личного дела',
        // order: 6,
        scopes: getScopes([
          USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
          USER_SCOPES.GOMU_OBSERVER,
          USER_SCOPES.SYSTEM_ADMINISTRATOR,
          USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
        ]),
      }),

      notificationsRoute({
        path: 'notifications',
        // icon: 'pgs-mail',
        label: 'Уведомления',
        // order: 8,
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSAR,
          USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
          USER_SCOPES.GOMU_OBSERVER,
          USER_SCOPES.SYSTEM_ADMINISTRATOR,
          USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
        ]),
      }),

      archiveRoute({
        path: 'archive',
        // icon: 'pgs-database',
        label: 'Архив',
        // order: 11,
        scopes: getScopes([
          USER_SCOPES.MILITARY_COMMISSAR,
          USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
          USER_SCOPES.GOMU_SPECIALIST,
          USER_SCOPES.GOMU_OBSERVER,
          USER_SCOPES.SYSTEM_ADMINISTRATOR,
          USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
        ]),
      }),
    ],
  });
}
