import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '@xdf/security';
import { TemplateResolver, DirtyGuard, CrudGridComponent, RecordResolver } from '@xdf/gallery';
import { ResourceAuthGuard } from '@xdf/security';
import { CalendarFormComponent } from './calendar-form/calendar-form.component';

const routes: Routes = [
  {
    path: '', component: CrudGridComponent, canActivate: [AuthGuard, ResourceAuthGuard],
    resolve: { template: TemplateResolver },
    data: {
      innerTemplate: 'none',
      program: 'calendar',
      breadcrumb: 'breadcrumb.calendar'
    }
  },
  {
    path: 'detail/:mode', component: CalendarFormComponent, canActivate: [AuthGuard, ResourceAuthGuard], canDeactivate: [DirtyGuard],
    resolve: { record: RecordResolver },
    data: {
      innerTemplate: 'none',
      program: 'calendar',
      breadcrumb: 'breadcrumb.calendar.detail',
    },
    children: [
      {
        path: '', component: CrudGridComponent, canActivate: [AuthGuard, ResourceAuthGuard],
        resolve: { record: RecordResolver, calendarException: TemplateResolver },
        data: {
          innerTemplate: 'none',
          program: 'CALENDAR-EXCEPTION',
          breadcrumb: 'breadcrumb.calendar-exception.detail',
        }
      },
    ]
  }

];

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