import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BaseLayoutComponent, CustomLayoutComponent, NotFoundComponent } from '@xdf/layouts';
import { AuthGuard, LoginComponent } from '@xdf/security';
import { HomeComponent } from './views/home/home.component';

const routes: Routes = [
  // Remover para SSO
  { path: 'login', component: LoginComponent },
  // Main redirect
  { path: '', redirectTo: 'home', pathMatch: 'full', canActivate: [AuthGuard] },
  {
    path: '', component: CustomLayoutComponent,
    children: [
      { path: 'home', component: HomeComponent, data: { breadcrumb: 'Home' } },
      {
        path: 'security', data: { breadcrumb: 'Seguridad' }, canLoad: [AuthGuard],
        loadChildren: () => import('./modules/security/security.module').then(m => m.SecurityModule)
      },
      {
        path: 'settings', data: { breadcrumb: 'Ajustes Generales' }, canLoad: [AuthGuard],
        loadChildren: () => import('./modules/settings/settings.module').then(m => m.SettingsModule)
      },
      {
        path: 'configuration', data: { breadcrumb: 'Agentes' }, canLoad: [AuthGuard],
        loadChildren: () => import('./modules/agent/agent.module').then(m => m.AgentModule)
      },
      {
        path: "airport", data: { breadcrumb: "Aeropuertos" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/airport/airport.module").then( m => m.AirportModule)
      },
      {
        path: "passenger", data: { breadcrumb: "Pasajeros" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/passenger/passenger.module").then( m => m.PassengerModule)
      },
      {
        path: "agent", data: { breadcrumb: "Agentes" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/booking-agent/booking-agent.module").then( m => m.BookingAgentModule)
      },
      {
        path: "payment", data: { breadcrumb: "Pagos" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/payment/payment.module").then( m => m.PaymentModule)
      },
      {
        path: "payment-reservation", data: {breadcrumb: "Pagos Reserva"}, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/payment-reservation/payment-reservation.module").then( m => m.PaymentReservationModule)
      },
      {
        path: "flight", data: { breadcrumb: "Vuelos" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/flight/flight.module").then( m => m.FlightModule)
      },
      {
        path: "reservation", data: { breadcrumb: "Reservaciones" }, canLoad: [AuthGuard],
        loadChildren: () => import("./modules/reservation/reservation.module").then( m => m.ReservationModule)
      }
    ],
    canActivate: [AuthGuard]
  },
  { path: 'notpermitted', component: NotFoundComponent},

  // Handle all other routes
  { path: '**', component: NotFoundComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {
    scrollPositionRestoration: 'enabled',
    anchorScrolling: 'enabled',
    onSameUrlNavigation: 'ignore'
  })],
  exports: [RouterModule]
})
export class AppRoutingModule { }
