// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import {
  IColumn,
  PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { complexListConfig } from '@/shared/constants/list-configs';
import { Component, inject, Input } from '@angular/core';
import { Router } from '@angular/router';
import { consumerComplexesNamedRoutes } from '../../constants/routes/complexes';
import { IComplexResponse } from '../../models';
import { ConsumerComplexesService } from '../../services/complexes.service';
import { ConsumerComplexFormComponent } from './form.component';

@Component({
  selector: 'consumer-complex-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, ConsumerComplexFormComponent],
})
export class ConsumerComplexListComponent extends AbstractList<IComplexResponse> {
  @Input({ required: true }) businessId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = complexListConfig.columns;

  private readonly service = inject(ConsumerComplexesService);
  private readonly router = inject(Router);

  override setColumns(): void {
    this.columns = this.header;
  }

  override getDataRequest() {
    return this.service.getAll(this.businessId);
  }

  toSinglePage(item: IComplexResponse) {
    this.router.navigateByUrl(
      consumerComplexesNamedRoutes.complex.meta.pagePath!(this.businessId, item.id),
    );
  }
}
