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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { PeriodComponent } from './list/period.component';
import { PeriodDetailComponent } from './detail/period-detail.component';
import { PeriodUpdateComponent } from './update/period-update.component';
import PeriodResolve from './route/period-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { PeriodService } from './service/period.service';
import { Resources } from 'app/security/resources.model';

const periodRoute: Routes = [
  {
    path: '',
    component: PeriodComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: PeriodService,
      resource: Resources.PERIOD,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: PeriodDetailComponent,
    resolve: {
      period: PeriodResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: PeriodService,
      resource: Resources.PERIOD,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: PeriodUpdateComponent,
    resolve: {
      period: PeriodResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: PeriodService,
      resource: Resources.PERIOD,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: PeriodUpdateComponent,
    resolve: {
      period: PeriodResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: PeriodService,
      resource: Resources.PERIOD,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default periodRoute;
