import { Routes } from '@angular/router';

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { VariableCategoryComponent } from './list/variable-category.component';
import { VariableCategoryDetailComponent } from './detail/variable-category-detail.component';
import { VariableCategoryUpdateComponent } from './update/variable-category-update.component';
import VariableCategoryResolve from './route/variable-category-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { VariableCategoryService } from './service/variable-category.service';
import { Resources } from 'app/security/resources.model';

const variableCategoryRoute: Routes = [
  {
    path: '',
    component: VariableCategoryComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'variableScope.code,' + ASC,
      action: SecurityAction.READ,
      service: VariableCategoryService,
      resource: Resources.VARIABLE_CATEGORY,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: VariableCategoryDetailComponent,
    resolve: {
      variableCategory: VariableCategoryResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: VariableCategoryService,
      resource: Resources.VARIABLE_CATEGORY,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: VariableCategoryUpdateComponent,
    resolve: {
      variableCategory: VariableCategoryResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: VariableCategoryService,
      resource: Resources.VARIABLE_CATEGORY,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: VariableCategoryUpdateComponent,
    resolve: {
      variableCategory: VariableCategoryResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: VariableCategoryService,
      resource: Resources.VARIABLE_CATEGORY,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default variableCategoryRoute;
