import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { PermissionGuard } from 'src/app/core/guard/permission.guard';
import { PermissionsEnum } from 'src/app/model/auth/permissionsEnum';
import { SharedModule } from 'src/app/modules/shared/shared.module';

const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'users',
  },
  {
    path: 'domains',
    loadChildren: () =>
      import(
        'src/app/modules/admin/administration/domains/domains.module'
      ).then(m => m.DomainsModule),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.domains] },
  },
  {
    path: 'users',
    title: 'Users | Maxlan',
    loadChildren: () =>
      import('src/app/modules/admin/administration/users/users.module').then(
        m => m.UsersModule
      ),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.users] },
  },
  {
    path: 'roles',
    title: 'Roles | Maxlan',
    loadChildren: () =>
      import('src/app/modules/admin/administration/roles/roles.module').then(
        m => m.RolesModule
      ),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.roles] },
  },
  {
    path: 'api-keys',
    title: 'API Key | Maxlan',
    loadChildren: () =>
      import(
        'src/app/modules/admin/administration/api-keys/api-keys.module'
      ).then(m => m.ApiKeysModule),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.apiKeys] },
  },
  {
    path: 'feature-flags',
    title: 'Feature-flags | Maxlan',
    loadChildren: () =>
      import(
        'src/app/modules/admin/administration/feature-flags/feature-flags.module'
      ).then(m => m.FeatureFlagsModule),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.administrator] },
  },
  {
    path: 'settings',
    title: 'Settings | Maxlan',
    loadChildren: () =>
      import(
        'src/app/modules/admin/administration/settings/settings.module'
      ).then(m => m.SettingsModule),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.administrator] },
  },
];

@NgModule({
  declarations: [],
  imports: [CommonModule, SharedModule, RouterModule.forChild(routes)],
})
export class AdministrationModule {}
