// 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 { businessActivityListConfig } from '@/shared/constants/list-configs';
import { Component, inject, Input, signal } from '@angular/core';
import { Router } from '@angular/router';
import { partnerConsumerBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
import { IBusinessActivityResponse } from '../../models';
import { PartnerConsumerBusinessActivitiesService } from '../../services/businessActivities.service';
import { ConsumerBusinessActivitiesCreateWrapperComponent } from './create-wrapper/create-wrapper.component';
import { ConsumerBusinessActivitiesFormDialogComponent } from './form-dialog.component';

@Component({
  selector: 'partner-consumer-businessActivities-list',
  templateUrl: './list.component.html',
  imports: [
    PageDataListComponent,
    ConsumerBusinessActivitiesFormDialogComponent,
    ConsumerBusinessActivitiesCreateWrapperComponent,
  ],
})
export class ConsumerBusinessActivitiesComponent extends AbstractList<IBusinessActivityResponse> {
  @Input({ required: true }) consumerId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = businessActivityListConfig.columns;

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

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

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

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

  toSinglePage(item: IBusinessActivityResponse) {
    this.router.navigateByUrl(
      partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
        this.consumerId,
        item.id,
      ),
    );
  }
}
