import { Routes } from '@angular/router';

import {Error404Component} from './pages/error/error404/error404.component';
import {InitGuardService} from './utils/initGuard.service';
import {IndexComponent} from './pages/body/index/index.component';

export const routes: Routes = [
  {path: '', pathMatch: 'full', redirectTo: 'admin/index'},
  {
    path: 'login',
    loadChildren: () => import('./pages/login/login.routes').then(m => m.LOGIN_ROUTES)
  },
  {
    path: 'index',
    loadChildren: () => import('./pages/login/login.routes').then(m => m.LOGIN_ROUTES)
  },
  {
    path: 'admin', component: IndexComponent,
    children: [
      {
        path: 'index',
        loadChildren: () => import('./pages/index/index.routes').then(m => m.INDEX_ROUTES),
        canActivate: [InitGuardService]
      },
      {
        path: 'system',
        loadChildren: () => import('./pages/system/system.routes').then(m => m.SYSTEM_ROUTES),
        canActivate: [InitGuardService]
      },
      {
        path: 'account',
        loadChildren: () => import('./pages/account/account.routes').then(m => m.ACCOUNT_ROUTES),
        canActivate: [InitGuardService]
      },
      {
        path: 'student',
        loadChildren: () => import('./pages/student/student.routes').then(m => m.STUDENT_ROUTES),
        canActivate: [InitGuardService]
      },
    ]
  },
  {
    path: 'error',
    loadChildren: () => import('./pages/error/error.routes').then(m => m.ERROR_ROUTES),
  },
  {
    path: '**', component: Error404Component
  },
];
