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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { UnitTypeComponent } from './list/unit-type.component';
import { UnitTypeDetailComponent } from './detail/unit-type-detail.component';
import { UnitTypeUpdateComponent } from './update/unit-type-update.component';
import UnitTypeResolve from './route/unit-type-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { UnitTypeService } from './service/unit-type.service';
import { Resources } from 'app/security/resources.model';

const unitTypeRoute: Routes = [
  {
    path: '',
    component: UnitTypeComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: UnitTypeService,
      resource: Resources.UNIT_TYPE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: UnitTypeDetailComponent,
    resolve: {
      unitType: UnitTypeResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: UnitTypeService,
      resource: Resources.UNIT_TYPE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: UnitTypeUpdateComponent,
    resolve: {
      unitType: UnitTypeResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: UnitTypeService,
      resource: Resources.UNIT_TYPE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: UnitTypeUpdateComponent,
    resolve: {
      unitType: UnitTypeResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: UnitTypeService,
      resource: Resources.UNIT_TYPE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default unitTypeRoute;
