import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from 'src/app/modules/shared/shared.module';
import { RouterModule, Routes } from '@angular/router';
import { PermissionGuard } from 'src/app/core/guard/permission.guard';
import { PermissionsEnum } from 'src/app/model/auth/permissionsEnum';
import { RoleFormPageComponent } from 'src/app/modules/admin/administration/roles/form-page/role-form-page.component';
import { RolesPage } from 'src/app/modules/admin/administration/roles/roles.page';
import { RolesDataService } from 'src/app/modules/admin/administration/roles/roles.data.service';
import { RolesColumns } from 'src/app/modules/admin/administration/roles/roles.columns';
import { HistoryComponent } from 'src/app/modules/admin/administration/roles/history/history.component';

const routes: Routes = [
  {
    path: '',
    title: 'Admin - Roles | Maxlan',
    component: RolesPage,
    children: [
      {
        path: 'create',
        component: RoleFormPageComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.rolesCreate],
        },
      },
      {
        path: 'edit/:id',
        component: RoleFormPageComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.rolesUpdate],
        },
      },
      {
        path: 'history/:historyId',
        component: HistoryComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.roles],
        },
      },
    ],
  },
];

@NgModule({
  declarations: [RolesPage, RoleFormPageComponent, HistoryComponent],
  imports: [CommonModule, SharedModule, RouterModule.forChild(routes)],
  providers: [RolesDataService.provide(), RolesColumns.provide()],
})
export class RolesModule {}
