import { getScopes } from '@utils/scopes';
import { USER_SCOPES } from '@constants/entities/Scope';
import { lazyLoadView } from '@utils/lazyloadview';

const categories = {
  statements: {
    label: 'Заявления',
    path: 'statements',
    scopes: getScopes([
      USER_SCOPES.MILITARY_APPLICATION_SPECIALIST,
      USER_SCOPES.SYSTEM_ADMINISTRATOR,
    ]),
  },
};

const routes = [
  {
    children: [
      {
        component: () => import('@components/statements/index.vue'),
        meta: {
          icon: 'forum',
          label: categories.statements.label,
          place: 'drawer',
          order: 11,
          scopes: getScopes([
            USER_SCOPES.MILITARY_APPLICATION_SPECIALIST,
            USER_SCOPES.MILITARY_COMMISSAR,
            USER_SCOPES.SYSTEM_ADMINISTRATOR,
          ]),
          storeCountGetters: 'menuCounters/applicationsCounter',
        },
        name: 'statements',
        path: '',
        props: (route) => {
          return {
            searchQuery: {
              onlyMy: !(route.query.onlyMy === 'false'),
              status: route.query.status,
              daterange: route.query.daterange,
              daterangeDecision: route.query.daterangeDecision,
              employees: route.query.employees,
              organizations: route.query.organizations,
              departments: route.query.departments,
              search: route.query.search,
              services: route.query.services,
              goals: route.query.goals,
              subjects: route.query.subjects,
              term: route.query.term,
            },
          };
        },
      },
      {
        component: () => import('@components/statements/create/index.vue'),
        name: 'statements-create',
        path: 'create',
        children: [
          {
            component: () => import('@components/statements/create/index.vue'),
            name: 'from-draft',
            path: 'from-draft/:id',
          },
        ],
      },
      {
        component: () =>
          import('@components/statements/electronic-duplicate/index.vue'),
        name: 'statements-electronic-duplicate',
        path: 'electronic-duplicate',
      },
    ],
    component: () => lazyLoadView(import('@router/statements/index.vue')),
    meta: {
      scopes: getScopes([
        USER_SCOPES.MILITARY_COMMISSAR,
        USER_SCOPES.MILITARY_APPLICATION_SPECIALIST,
        USER_SCOPES.SYSTEM_ADMINISTRATOR,
      ]),
    },
    path: categories.statements.path,
  },
];

export default routes;
