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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { DocumentComponent } from './list/document.component';
import { DocumentDetailComponent } from './detail/document-detail.component';
import { DocumentUpdateComponent } from './update/document-update.component';
import DocumentResolve from './route/document-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { Resources } from 'app/security/resources.model';
import { DocumentService } from './service/document.service';

const documentRoute: Routes = [
  {
    path: '',
    component: DocumentComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: DocumentService,
      resource: Resources.DOCUMENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: DocumentDetailComponent,
    resolve: {
      document: DocumentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: DocumentService,
      resource: Resources.DOCUMENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: DocumentUpdateComponent,
    resolve: {
      document: DocumentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: DocumentService,
      resource: Resources.DOCUMENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: DocumentUpdateComponent,
    resolve: {
      document: DocumentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: DocumentService,
      resource: Resources.DOCUMENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default documentRoute;
