import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject } from '@angular/core';
import { ILicenseResponse } from '../models';
import { PartnerLicensesService } from '../services/main.service';
import { AdminAgentsFilterComponent } from './filter-form.component';

@Component({
  selector: 'partner-license-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, AdminAgentsFilterComponent],
})
export class PartnerLicenseListComponent extends AbstractList<ILicenseResponse> {
  private readonly service = inject(PartnerLicensesService);

  override setColumns(): void {
    this.columns = [
      // { field: 'id', header: 'شناسه', type: 'id' },
      {
        field: 'business_activity',
        header: 'عنوان مشتری',
        type: 'nested',
        nestedOption: {
          path: 'business_activity.consumer.name',
        },
      },
      {
        field: 'business_activity',
        header: 'عنوان فعالیت اقتصادی',
        type: 'nested',
        nestedOption: {
          path: 'business_activity.name',
        },
      },
      {
        field: 'account_allocation_count',
        header: 'محدودیت کاربر',
      },
      { field: 'expires_at', header: 'تاریخ انقضا', type: 'date' },
      { field: 'created_at', header: 'تاریخ ایجاد', type: 'date' },
    ];
  }

  override getDataRequest() {
    return this.service.getAll({
      page: this.responseMetaData()?.page || 1,
      pageSize: this.responseMetaData()?.perPage || 10,
    });
  }
}
