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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { OrganizationComponent } from './list/organization.component';
import { OrganizationDetailComponent } from './detail/organization-detail.component';
import { OrganizationUpdateComponent } from './update/organization-update.component';
import OrganizationResolve from './route/organization-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { OrganizationService } from './service/organization.service';
import { Resources } from 'app/security/resources.model';

const organizationRoute: Routes = [
  {
    path: '',
    component: OrganizationComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: OrganizationService,
      resource: Resources.ORGANIZATION,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: OrganizationDetailComponent,
    resolve: {
      organization: OrganizationResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: OrganizationService,
      resource: Resources.ORGANIZATION,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: OrganizationUpdateComponent,
    resolve: {
      organization: OrganizationResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: OrganizationService,
      resource: Resources.ORGANIZATION,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: OrganizationUpdateComponent,
    resolve: {
      organization: OrganizationResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: OrganizationService,
      resource: Resources.ORGANIZATION,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default organizationRoute;
