import { Routes, PreloadAllModules } from '@angular/router';
import { LoginComponent } from './pages/login/login.component';
import { LayoutComponent } from './components/layout/layout.component';
import { authGuard } from './guards/auth.guard';
import { NotFoundComponent } from './pages/not-found/not-found.component';

export const routes: Routes = [
  { path: 'login', component: LoginComponent },
  {
    path: '',
    component: LayoutComponent,
    canActivate: [authGuard],
    children: [
      { path: '', redirectTo: 'inicio', pathMatch: 'full' },
      { 
        path: 'inicio', 
        loadComponent: () => import('./pages/home/home.component').then(m => m.HomeComponent),
        data: { title: 'Inicio' } 
      },
      { 
        path: 'unidad-concesiones', 
        loadComponent: () => import('./pages/concesiones/concesiones.component').then(m => m.ConcesionesComponent),
        data: { title: 'Unidad de Concesiones' } 
      },
      { 
        path: 'ct-actualizacion', 
        loadComponent: () => import('./pages/actualizacion-pd/actualizacion-pd.component').then(m => m.ActualizacionPdComponent),
        data: { title: 'Cronograma temporal por actualización de PD' } 
      },
      { 
        path: 'ct-ajuste', 
        loadComponent: () => import('./pages/ajuste-pd/ajuste-pd.component').then(m => m.AjustePdComponent),
        data: { title: 'Cronograma temporal por ajuste de PD' } 
      },
      { 
        path: 'resumen', 
        loadComponent: () => import('./pages/resumen/resumen.component').then(m => m.ResumenComponent),
        data: { title: 'Resumen' } 
      },
      { 
        path: 'unidad-informacion', 
        loadComponent: () => import('./pages/unidad-informacion/unidad-informacion.component').then(m => m.UnidadInformacionComponent),
        data: { title: 'Unidad de Información' } 
      },
      { 
        path: '404', 
        component: NotFoundComponent,
        data: { title: 'Error 404' } 
      },
    ]
  },
  { path: '**', redirectTo: '404' }

];
