// 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, signal } from '@angular/core';
import { Router } from '@angular/router';
import { partnerConsumerComplexesNamedRoutes } from '../../constants/routes/complexes';
import { IComplexResponse } from '../../models';
import { PartnerComplexesService } from '../../services/complexes.service';
import { ConsumerComplexesCreateWrapperComponent } from './create-wrapper/create-wrapper.component';
import { ConsumerComplexFormDialogComponent } from './form-dialog.component';

@Component({
  selector: 'partner-consumer-complexes-list',
  templateUrl: './list.component.html',
  imports: [
    PageDataListComponent,
    ConsumerComplexFormDialogComponent,
    ConsumerComplexesCreateWrapperComponent,
  ],
})
export class ConsumerComplexesComponent extends AbstractList<IComplexResponse> {
  @Input() consumerId!: string;
  @Input() businessId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = complexListConfig.columns;

  private readonly service = inject(PartnerComplexesService);
  private readonly router = inject(Router);
  visibleCreateForm = signal(false);

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

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

  override openAddForm() {
    this.visibleCreateForm.set(true);
  }

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