import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { IRouteConfig } from '@shared/ui-api/interfaces/route-config/route-config';
import { FleioObjectsList } from '@fleio-api/fleio-objects-list';
import { IBaseFleioObjectModel } from '@fleio-api/base-model/base-fleio-object.model';
import { AuthGuard } from '@shared/auth/auth.guard';
import { HeatResourceTypeListComponent } from './heat-resource-type-list/heat-resource-type-list.component';
import { HeatResourceTypeListResolver } from '@fleio-api/openstack/orchestration/heat-resource-types/heat-resource-type-list.resolver';
import { HeatResourceTypeDetailsComponent } from './heat-resource-type-details/heat-resource-type-details.component';
import { HeatResourceTypeResolver } from '@fleio-api/openstack/orchestration/heat-resource-types/heat-resource-type.resolver';

const routes: Routes = [
  {
    path: '',
    component: HeatResourceTypeListComponent,
    resolve: {
      heatResourceTypes: HeatResourceTypeListResolver,
    },
    canActivate: [AuthGuard],
    data: {
      config: {
        feature: 'openstack.orchestration.heat-resource-types',
        getTitleDisplay: () => $localize`Heat resource types`,
        search: {
          show: true,
          placeholder: $localize`Search heat resource types ...`,
        },
        subheader: {
          objectNamePlural: $localize`heat resource types`,
          objectName: $localize`heat resource type`,
          objectList: data => data.heatResourceTypes as FleioObjectsList<IBaseFleioObjectModel>,
        },
      } as IRouteConfig,
    },
    runGuardsAndResolvers: 'always',
  },
  {
    path: ':id',
    component: HeatResourceTypeDetailsComponent,
    resolve: {
      heatResourceType: HeatResourceTypeResolver,
    },
    data: {
      config: {
        getBreadCrumbDetail: (data) => `${data.heatResourceType.name}`,
      } as IRouteConfig,
    },
    runGuardsAndResolvers: 'always',
  },
];

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