import { AnalystRoleGuard } from './core/guards/analyst-role.guard';
import { UnavailableGuard } from './core/guards/unavailable.guard';
import { NgModule } from "@angular/core";
import { Routes, RouterModule, PreloadAllModules } from "@angular/router";
import { UnavailableComponent } from "./core/unavailable/unavailable.component";
import { HomeComponent } from './core/home/home.component';
import { UserRoleGuard } from './core/guards/user-role.guard';

const coreRoutes: Routes = [
    { path: '', component: HomeComponent, pathMatch: 'full' },
    { path: 'database', loadChildren: './attacks/attacks.module#AttacksModule', canActivate: [AnalystRoleGuard] },
    { path: 'news', loadChildren: './news/news.module#NewsModule' },
    { path: 'charts', loadChildren: './charts/charts.module#ChartsModule' },
    { path: 'map', loadChildren: './map/map.module#MapModule', canActivate: [UserRoleGuard] },
    { path: 'unavailable', component: UnavailableComponent, canActivate: [UnavailableGuard] },
]; 

@NgModule({
    imports: [
        RouterModule.forRoot(coreRoutes, { preloadingStrategy: PreloadAllModules })
    ],
    exports: [
        RouterModule
    ]
})
export class AppRoutesModule{

}