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/auth.guard";
import { Role } from "./models/role";
import { WorkflowGuard } from "./services/investment-proposal-workflow.guard";

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

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