import { NgModule } from '@angular/core';
import { CommonModule, } from '@angular/common';
import { BrowserModule  } from '@angular/platform-browser';
import { Routes, RouterModule } from '@angular/router';
import { AdminModule } from './layouts/admin/admin.module';

import { AdminComponent } from './layouts/admin/admin.component';
import { LoginComponent } from './components/login/login.component';
//import { AuthGuard } from './services/authentication.service';
import { AuthGuard } from './services/auth.guard';
import { Role } from './models/role';
import { ConfirmAccountComponent } from './components/confirm-account/confirm-account.component';

const routes: Routes =[
  {
    path: '',
    redirectTo: 'dashboard',
    pathMatch: 'full',
  }, 
  {
    path: '',
    component: AdminComponent,
    canActivate: [AuthGuard],
    children: [{
      path: '',
      loadChildren : './layouts/admin/admin.module#AdminModule' //() => AdminModule
    }]
  }, 
  { path: 'login', component: LoginComponent },
  { path: 'confirm-account', component: ConfirmAccountComponent },
  { path: '**', redirectTo: '' }
];

@NgModule({
  imports: [
    CommonModule,
    BrowserModule,
    RouterModule.forRoot(routes,{
       useHash: true,
       onSameUrlNavigation: 'reload'
    })
  ],
  exports: [
  ],
})
export class AppRoutingModule { }
