import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { loginGuard } from "./cores/guards/login.guard";
import { authGuard } from "./cores/guards/auth.guard";

const routes: Routes = [
  {
    path: "",
    pathMatch: "full",
    redirectTo: "auth",
  },
  {
    path: "auth",
    loadChildren: () =>
      import("./pages/auth/auth.module").then((m) => m.AuthModule),
    title: "Dashboard - Login",
    canActivate: [loginGuard],
  },
  {
    path: "dashboard",
    loadChildren: () =>
      import("./pages/dashboard/dashboard.module").then(
        (m) => m.DashboardModule
      ),
    title: "Dashboard",
    canActivate: [authGuard],
  },
  {
    path: "**",
    loadChildren: () =>
      import("./pages/error-not-found/error-not-found.module").then(
        (m) => m.ErrorNotFoundModule
      ),
    title: "Halaman Tidak Ditemukan",
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}
