// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { Maybe } from '@/core';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import {
  IColumn,
  PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { IPaginatedQuery } from '@/core/models/service.model';
import { saleInvoiceListConfig } from '@/shared/constants/list-configs';
import { Component, inject, Input } from '@angular/core';
import { Router } from '@angular/router';
import { consumerSaleInvoicesNamedRoutes } from '../constants/routes';
import { IConsumerSaleInvoicesResponse } from '../models';
import { ConsumerSaleInvoicesService } from '../services/main.service';

@Component({
  selector: 'consumer-saleInvoice-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent],
})
export class ConsumerSaleInvoiceListComponent extends AbstractList<
  IConsumerSaleInvoicesResponse,
  IPaginatedQuery
> {
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = saleInvoiceListConfig.columns;

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

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

  override getDataRequest(payload: Maybe<IPaginatedQuery>) {
    return this.service.getAll(payload || undefined);
  }

  toSinglePage(item: IConsumerSaleInvoicesResponse) {
    this.router.navigateByUrl(consumerSaleInvoicesNamedRoutes.saleInvoice.meta.pagePath!(item.id));
  }
}
