import {Route} from '@angular/router';
import {
  AuthenticationGuard,
  ConfirmExitGuard,
  SignedInGuard,
} from "@webbpm/base-package";
import {LoginComponent} from "./component/login.component";
import {AccessDeniedComponent} from "./component/access-denied.component";
import {RegisterComponent} from "./component/register.component";
import {ConfirmUserEmailComponent} from "./component/confirm-user-email.component";
import {ResetPasswordComponent} from "./component/reset-password.component";
import {NewPasswordComponent} from "./component/new-password.component";
import {previewRoutes} from "../preview/preview.routes";

export const appRoutes: Route[] = [
  {
    path: '',
    loadComponent: () => import('page-main').then(
            m => m.PagemainComponent),
    canActivate: [AuthenticationGuard],
    pathMatch: 'full',
  },
  {
    path: 'webbpm-preview',
    children: previewRoutes,
  },
  {
    path: 'login',
    component: LoginComponent,
    canActivate: [SignedInGuard]
  },
  {
    path: 'access-denied',
    component: AccessDeniedComponent,
    canActivate: [AuthenticationGuard, ConfirmExitGuard]
  },
  {
    path: 'registration',
    component: RegisterComponent,
    canActivate: [SignedInGuard]
  },
  {
    path: 'confirm',
    component: ConfirmUserEmailComponent
  },
  {
    path: 'reset-password',
    component: ResetPasswordComponent
  },
  {
    path: 'new-password',
    component: NewPasswordComponent
  },
  {
    path: 'user-management',
    canActivate: [AuthenticationGuard],
    children: [
      {
        path: 'users',
        loadComponent: () => import('page-user-management-users').then(
            m => m.PageusermanagementusersComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'users/new',
        loadComponent: () => import('page-user-management-user-create').then(
            m => m.PageusermanagementusercreateComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'users/:id',
        loadComponent: () => import('page-user-management-user-edit').then(
            m => m.PageusermanagementusereditComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'org-units',
        loadComponent: () => import('page-user-management-org-units').then(
            m => m.PageusermanagementorgunitsComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'org-units/new',
        loadComponent: () => import('page-user-management-org-unit').then(
            m => m.PageusermanagementorgunitComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'org-units/:id',
        loadComponent: () => import('page-user-management-org-unit').then(
            m => m.PageusermanagementorgunitComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'roles',
        loadComponent: () => import('page-user-management-roles').then(
            m => m.PageusermanagementrolesComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'roles/new',
        loadComponent: () => import('page-user-management-role').then(
            m => m.PageusermanagementroleComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'roles/:id',
        loadComponent: () => import('page-user-management-role').then(
            m => m.PageusermanagementroleComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'groups',
        loadComponent: () => import('page-user-management-groups').then(
            m => m.PageusermanagementgroupsComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'groups/new',
        loadComponent: () => import('page-user-management-group-create').then(
            m => m.PageusermanagementgroupcreateComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'groups/:id',
        loadComponent: () => import('page-user-management-group-edit').then(
            m => m.PageusermanagementgroupeditComponent),
        canActivate: [ConfirmExitGuard]
      },
      {
        path: 'authorities',
        loadComponent: () => import('page-user-management-authorities').then(
            m => m.PageusermanagementauthoritiesComponent),
        canActivate: [ConfirmExitGuard]
      }
    ]
  },
  {
    path: '**',
    redirectTo: '',
  }
];
