// 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 { Component, inject, Input } from '@angular/core';
import { ISalesInvoicesResponse } from '../../models';
import { ConsumerSalesInvoicesService } from '../../services/invoices.service';

@Component({
  selector: 'consumer-salesInvoices-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent],
})
export class ConsumerSalesInvoicesComponent extends AbstractList<ISalesInvoicesResponse> {
  @Input({ required: true }) complexId!: string;
  @Input({ required: true }) posId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = [
    // { field: 'id', header: 'شناسه', type: 'id' },
    { field: 'code', header: 'کد رهگیری' },
    { field: 'total_amount', header: 'مبلغ کل', type: 'price' },
    {
      field: 'items_count',
      header: 'تعداد کالاها',
      customDataModel(item) {
        return `${item.items.length} عدد`;
      },
    },
    {
      field: 'invoice_date',
      header: 'تاریخ',
      type: 'date',
    },
  ];

  private readonly service = inject(ConsumerSalesInvoicesService);

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

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