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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { UnitComponent } from './list/unit.component';
import { UnitDetailComponent } from './detail/unit-detail.component';
import { UnitUpdateComponent } from './update/unit-update.component';
import UnitResolve from './route/unit-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { UnitService } from './service/unit.service';
import { Resources } from 'app/security/resources.model';

const unitRoute: Routes = [
  {
    path: '',
    component: UnitComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: UnitService,
      resource: Resources.UNIT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: UnitDetailComponent,
    resolve: {
      unit: UnitResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: UnitService,
      resource: Resources.UNIT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: UnitUpdateComponent,
    resolve: {
      unit: UnitResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: UnitService,
      resource: Resources.UNIT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: UnitUpdateComponent,
    resolve: {
      unit: UnitResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: UnitService,
      resource: Resources.UNIT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default unitRoute;
