import scopes from '@utils/scopes';
import { lazyLoadView } from '@utils/lazyloadview';
import { Route } from 'vue-router';
import Vue from 'vue';

const categories = {
  personalAccounts: {
    label: 'personalAccounts.personnelFilesRegirtry',
    path: 'personal-accounts',
    scopes: scopes.personalAccounts,
  },
};

const routes = [
  {
    children: [
      {
        component: () => import('@components/personal-accounts/index.vue'),
        meta: {
          icon: 'contact_page',
          label: categories.personalAccounts.label,
          place: 'drawer',
          order: 6,
          showProd: Vue.prototype.$appConfig.isDebugMode === 'true',
        },
        name: 'personalAccounts',
        path: '',
        props: (route: Route) => {
          return {
            searchQuery: {
              applicationNum: route.query.applicationNum,
              solutionNum: route.query.solutionNum,
              phone: route.query.phone,
              email: route.query.email,
              series: route.query.series,
              number: route.query.number,
              documentType: route.query.documentType,
              address: route.query.address,
              snils: route.query.snils,
              inn: route.query.inn,
              birthday: route.query.birthday,
              fullName: route.query.fullName,
            },
          };
        },
      },
      {
        component: () => import('@components/personal-accounts/Create.vue'),
        meta: {
          showProd: Vue.prototype.$appConfig.isDebugMode === 'true',
        },
        name: 'personalAccountsSearch',
        path: 'create',
      },
      {
        component: () => import('@components/personal-accounts/Edit.vue'),
        meta: {
          showProd: Vue.prototype.$appConfig.isDebugMode === 'true',
        },
        name: 'personalAccountsCreate',
        path: 'edit',
      },
      {
        component: () => import('@components/personal-accounts/Edit.vue'),
        meta: {
          showProd: Vue.prototype.$appConfig.isDebugMode === 'true',
        },
        name: 'personalAccountsEdit',
        path: 'edit/:id',
      },
    ],
    component: () => lazyLoadView(import('@router/personal-accounts/index.vue')),
    meta: {
      scopes: categories.personalAccounts.scopes,
    },
    path: categories.personalAccounts.path,
  },
];

export default routes;
