import {NgModule} from "@angular/core";
import {RouterModule, Routes} from "@angular/router";
import {AccessDeniedComponent} from "./component/access-denied.component";
import {LoginComponent} from "./component/login.component";
import {AuthenticationGuard, ConfirmExitGuard, SignedInGuard, ProcessInstanceRouteResolver} from "@webbpm/base-package";
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 {TaskListComponent} from "./component/task-list.component";

const appRoutes: Routes = [
  {
    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: 'process',
    canActivate: [AuthenticationGuard, ConfirmExitGuard],
    children: [
      {
        path: 'instance',
        loadChildren: 'generated-sources/page-process-instance-list.module#PageprocessinstancelistModule',
        resolve: {
          processInstanceId: ProcessInstanceRouteResolver
        }
      },
      {
        path: 'instance/:processInstanceId',
        loadChildren: 'generated-sources/page-process-instance.module#PageprocessinstanceModule',
        resolve: {
          processInstanceId: ProcessInstanceRouteResolver
        }
      },
      {
        path: 'tasks',
        component: TaskListComponent,
      }
    ]
  }
];

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

}
