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

const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'urls',
  },
  {
    path: 'groups',
    loadChildren: () =>
      import('src/app/modules/admin/groups/groups.module').then(
        m => m.GroupsModule
      ),
    canActivate: [PermissionGuard],
    data: { permissions: [PermissionsEnum.groups], isInUserSpace: true },
  },
  {
    path: 'urls',
    loadChildren: () =>
      import('src/app/modules/admin/short-urls/short-urls.module').then(
        m => m.ShortUrlsModule
      ),
    canActivate: [PermissionGuard],
    data: {
      permissions: [
        PermissionsEnum.shortUrls,
        PermissionsEnum.shortUrlsByAssignment,
      ],
      isInUserSpace: true,
    },
  },
  {
    path: 'rooms',
    loadChildren: () =>
      import('src/app/modules/admin/user-spaces/user-spaces.module').then(
        m => m.UserSpacesModule
      ),
  },
  {
    path: 'administration',
    loadChildren: () =>
      import('src/app/modules/admin/administration/administration.module').then(
        m => m.AdministrationModule
      ),
  },
];

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