// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import { consumerListConfig } from '@/shared/constants/list-configs';
import { Component, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
import { CreateConsumerWrapperComponent } from '../components/createConsumerWrapper/create-consumer-wrapper.component';
import { ConsumerUserFormDialogComponent } from '../components/form-dialog.component';
import { partnerConsumersNamedRoutes } from '../constants';
import { IPartnerConsumerResponse } from '../models';
import { ConsumersService } from '../services/main.service';

@Component({
  selector: 'partner-consumers',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, ConsumerUserFormDialogComponent, CreateConsumerWrapperComponent],
})
export class ConsumersComponent extends AbstractList<IPartnerConsumerResponse> {
  private readonly service = inject(ConsumersService);
  private readonly router = inject(Router);
  visibleCreateForm = signal(false);

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

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

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

  toSinglePage(consumer: IPartnerConsumerResponse) {
    this.router.navigateByUrl(partnerConsumersNamedRoutes.consumer.meta.pagePath!(consumer.id));
  }
}
