// 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, Input } from '@angular/core';
import { IPartnerActivatedLicenseResponse } from '../../models';
import { AdminPartnerActivatedLicensesService } from '../../services/licenses.service';

@Component({
  selector: 'admin-partner-licenses',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent],
})
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivatedLicenseResponse> {
  @Input({ required: true }) partnerId!: string;

  private readonly service = inject(AdminPartnerActivatedLicensesService);

  override setColumns(): void {
    this.columns = [
      // { field: 'id', header: 'شناسه', type: 'id' },
      {
        field: 'consumer',
        header: 'مشتری',
        customDataModel(item: IPartnerActivatedLicenseResponse) {
          return `${item.business_activity.consumer_name} (${item.business_activity.name})`;
        },
      },
      {
        field: 'license',
        header: 'تعداد کاربر مجاز',
        type: 'nested',
        nestedOption: { path: 'license.accounts_limit', type: 'number' },
      },
      { field: 'expires_at', header: 'تاریخ انقضا لایسنس', type: 'date' },
    ];
  }

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