import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { CustomLayoutComponent, NotFoundComponent } from "@xdf/layouts";
import { AuthGuard, LoginComponent } from "@xdf/security";
import { BytebotLayoutComponent } from "./modules/bytebot-layout/bytebot-layout/bytebot-layout.component";
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: "reserva",
        data: { breadcrumb: "Aeropuertos" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/aeropuerto/aeropuerto.module").then(
            (m) => m.AeropuertoModule
          ),
      },
      {
        path: "pasajero",
        data: { breadcrumb: "Pasajeros" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/pasajero/pasajero.module").then(
            (m) => m.PasajeroModule
          ),
      },
      {
        path: "agente",
        data: { breadcrumb: "Agentes" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/booking-agent/booking-agent.module").then(
            (m) => m.BookingAgentModule
          ),
      },
      {
        path: "pago",
        data: { breadcrumb: "Pagos" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/pago/pago.module").then(
            (m) => m.PagoModule
          ),
      },
      {
        path: "pago-reserva",
        data: { breadcrumb: "Pagos Reserva" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/pago-reserva/pago-reserva.module").then(
            (m) => m.PagoReservaModule
          ),
      },
      {
        path: "vuelo",
        data: { breadcrumb: "Vuelos" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/vuelo/vuelo.module").then(
            (m) => m.VueloModule
          ),
      },
      {
        path: "reservacion",
        data: { breadcrumb: "Reservaciones" },
        canLoad: [AuthGuard],
        loadChildren: () =>
          import("./modules/reservation/reservation.module").then(
            (m) => m.ReservationModule
          ),
      }
    ],
    canActivate: [AuthGuard],
  },
  { path: "notpermitted", component: NotFoundComponent },

  { path: "**", component: NotFoundComponent },
];

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