import { NgModule } from '@angular/core';
import { ActivatedRouteSnapshot, RouterModule, Routes } from '@angular/router';
import { IRouteConfig } from '@shared/ui-api/interfaces/route-config/route-config';

const routes: Routes = [
  {
    path: 'api-users',
    loadChildren: () => import('./api-users/api-users.module').then(mod => mod.ApiUsersModule),
    data: {
      config: {
        getBreadCrumbDetail: () => $localize`API users`,
      } as IRouteConfig,
    }
  },
  {
    path: 'clusters',
    loadChildren: () => import('./clusters/clusters.module').then(mod => mod.ClustersModule),
  },
  {
    path: 'cluster-templates',
    loadChildren: () => import('./cluster-templates/cluster-templates.module').then(mod => mod.ClusterTemplatesModule),
  },
  {
    path: 'images',
    loadChildren: () => import('./images/images.module').then(mod => mod.ImagesModule),
  },
  {
    path: 'floating-ips',
    loadChildren: () => import('./floating-ips/floating-ips.module').then(mod => mod.FloatingIpsModule),
  },
  {
    path: 'instances',
    loadChildren: () => import('./instances/instances.module').then(mod => mod.InstancesModule),
  },
  {
    path: 'networks',
    loadChildren: () => import('./networks/networks.module').then(mod => mod.NetworksModule),
  },
  {
    path: 'object-store',
    data: {
      config: {
        getBreadCrumbQueryParams(snapshot: ActivatedRouteSnapshot): { [key: string]: any } {
          const queryParams: { [key: string]: any } = {};
          if (snapshot.queryParams?.region) {
            queryParams.region = snapshot.queryParams?.region;
          }
          return queryParams;
        },
      } as IRouteConfig
    },
    loadChildren: () => import('./object-store/object-store.module').then(mod => mod.ObjectStoreModule),
  },
  {
    path: 'heat-stacks',
    loadChildren: () => import('./heat-stacks/heat-stacks.module').then(mod => mod.HeatStacksModule),
  },
  {
    path: 'heat-resource-types',
    loadChildren: () => import(
      './heat-resource-types/heat-resource-types.module'
      ).then(mod => mod.HeatResourceTypesModule),
  },
  {
    path: 'heat-template-versions',
    loadChildren: () => import(
      './heat-template-versions/heat-template-versions.module'
      ).then(mod => mod.HeatTemplateVersionsModule),
  },
  {
    path: 'load-balancers',
    data: {
      config: {
        getBreadCrumbQueryParams(snapshot: ActivatedRouteSnapshot): { [key: string]: any } {
          const queryParams: { [key: string]: any } = {};
          if (snapshot.queryParams?.region) {
            queryParams.region = snapshot.queryParams?.region;
          }
          return queryParams;
        },
      } as IRouteConfig
    },
    loadChildren: () => import('./load-balancers/load-balancers.module').then(mod => mod.LoadBalancersModule),
  },
  {
    path: 'ports',
    loadChildren: () => import('./ports/ports.module').then(mod => mod.PortsModule),
  },
  {
    path: 'routers',
    loadChildren: () => import('./routers/routers.module').then(mod => mod.RoutersModule),
  },
  {
    path: 'security-groups',
    loadChildren: () => import('./security-groups/security-groups.module').then(mod => mod.SecurityGroupsModule),
  },
  {
    path: 'ssh-keys',
    loadChildren: () => import('./ssh-keys/ssh-keys.module').then(mod => mod.SshKeysModule),
    data: {
      config: {
        getBreadCrumbDetail: () => $localize`SSH keys`,
      } as IRouteConfig,
    }
  },
  {
    path: 'volumes',
    loadChildren: () => import('./volumes/volumes.module').then(mod => mod.VolumesModule),
  },
  {
    path: 'volume-backups',
    loadChildren: () => import('./volume-backups/volume-backups.module').then(mod => mod.VolumeBackupsModule),
  },
  {
    path: 'volume-snapshots',
    loadChildren: () => import('./volume-snapshots/volume-snapshots.module').then(mod => mod.VolumeSnapshotsModule),
  },
  {
    path: 'database-instances',
    loadChildren: () => import('./dbaas/dbaas.module').then(mod => mod.DbaasModule),
  },
  {
    path: 'zones',
    loadChildren: () => import('./zones/zones.module').then(mod => mod.ZonesModule),
  },
];

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