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 { IAdminPartnerChargeAccountRawResponse } from '../../models';
import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.service';

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

  private readonly service = inject(AdminPartnerChargeAccountService);

  override setColumns(): void {
    this.columns = [
      { field: 'tracking_code', header: 'کد پیگیری' },
      { field: 'charged_license_count', header: 'تعداد شارژ کاربر', type: 'number' },
      { field: 'remained_license_count', header: 'شارژ باقی مانده', type: 'number' },
      {
        field: 'activation_count',
        header: 'مقدار مصرف شده',
        type: 'number',
      },
      {
        field: 'activation_expires_at',
        header: 'تاریخ انقضا فروش',
        type: 'date',
        dateOption: {
          expiredMode: true,
        },
      },
    ];
  }

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