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 { ApiKeyFormPageComponent } from 'src/app/modules/admin/administration/api-keys/form-page/api-key-form-page.component';
import { ApiKeysPage } from 'src/app/modules/admin/administration/api-keys/api-keys.page';
import { ApiKeysDataService } from 'src/app/modules/admin/administration/api-keys/api-keys.data.service';
import { ApiKeysColumns } from 'src/app/modules/admin/administration/api-keys/api-keys.columns';
import { HistoryComponent } from 'src/app/modules/admin/administration/api-keys/history/history.component';

const routes: Routes = [
  {
    path: '',
    title: 'Admin - ApiKeys | Maxlan',
    component: ApiKeysPage,
    children: [
      {
        path: 'create',
        component: ApiKeyFormPageComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.apiKeysCreate],
        },
      },
      {
        path: 'edit/:id',
        component: ApiKeyFormPageComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.apiKeysUpdate],
        },
      },
      {
        path: 'history/:historyId',
        component: HistoryComponent,
        canActivate: [PermissionGuard],
        data: {
          permissions: [PermissionsEnum.apiKeys],
        },
      },
    ],
  },
];

@NgModule({
  declarations: [ApiKeysPage, ApiKeyFormPageComponent, HistoryComponent],
  imports: [CommonModule, SharedModule, RouterModule.forChild(routes)],
  providers: [ApiKeysDataService.provide(), ApiKeysColumns.provide()],
})
export class ApiKeysModule {}
