// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject } from '@angular/core';
import { ILicenseRawResponse, ILicenseResponse } from '../models';
import { LicensesService } from '../services/main.service';

@Component({
  selector: 'admin-licenses',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent],
})
export class LicensesComponent extends AbstractList<ILicenseResponse> {
  private readonly service = inject(LicensesService);

  override setColumns(): void {
    this.columns = [
      {
        field: 'consumer',
        header: 'مشتری',
        customDataModel(item) {
          return `${item.consumer.first_name} ${item.consumer.last_name}`;
        },
      },
      {
        field: 'partner',
        header: 'ارایه شده توسط',
        customDataModel(item: ILicenseRawResponse) {
          return item.license.charged_license_transaction.partner.name || 'برند نرم‌افزار';
        },
      },
      { field: 'expires_at', header: 'تاریخ انقضا', type: 'date' },
      { field: 'created_at', header: 'تاریخ ایجاد', type: 'date' },
    ];
  }

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