import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard, ResourceAuthGuard } from '@xdf/security';
import { DirtyGuard } from '@xdf/gallery';
import { AgentComponent } from './view/agent/agent.component';
import { AgentDetailComponent } from './view/agent-detail/agent-detail.component';
import { AgentDataForWizardResolver } from './resolver/agent-data-wizard.resolver';
import { AgentDetailResolver } from './resolver/agent-detail.resolver';
import { AgentListComponent } from './view/agent-list/agent-list.component';
import { CountryDataForWizardResolver } from './resolver/country-data-wizard.resolver';


const routes: Routes = [
  {
    path: 'agent', component: AgentListComponent, canActivate: [AuthGuard, ResourceAuthGuard], 
    data: {
      program: 'CONVERSATIONAL_AGENT',
      breadcrumb: 'Agentes'
    }
  },
  {
    path: 'agent/detail/new',
    //component: AgentDetailComponent,
    component: AgentComponent,
    resolve: {
      countryData : CountryDataForWizardResolver
    },
    canActivate: [AuthGuard, ResourceAuthGuard], canDeactivate: [DirtyGuard],
    data:
    {
      mode: 'create',
      program: 'CONVERSATIONAL_AGENT',
      breadcrumb: 'Agentes',
      backButton: true
    }
  },
  {
    path: 'agent/detail/edit/:code',
    //component: AgentDetailComponent,
    component: AgentComponent,
    resolve: {
      agentDetail: AgentDetailResolver,
      countryData : CountryDataForWizardResolver
    },
    canActivate: [AuthGuard, ResourceAuthGuard], canDeactivate: [DirtyGuard],
    data:
    {
      mode: 'edit',
      program: 'CONVERSATIONAL_AGENT',
      breadcrumb: 'Agentes',
      backButton: true
    }
  },{
    path: 'agent/detail/view/:code',
    //component: AgentDetailComponent,
    component: AgentComponent,
    resolve: {
      agentDetail: AgentDetailResolver,
      countryData : CountryDataForWizardResolver
    },
    canActivate: [AuthGuard, ResourceAuthGuard],
    data:
    {
      mode: 'view',
      program: 'CONVERSATIONAL_AGENT',
      breadcrumb: 'Agentes',
      backButton: true
    }
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AgentRoutingModule { }
