// 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 { Router } from '@angular/router';
import { ConsumerUserFormComponent } from '../components/form.component';
import { superAdminConsumersNamedRoutes } from '../constants';
import { IAdminConsumerResponse } from '../models';
import { ConsumersService } from '../services/main.service';

@Component({
  selector: 'superAdmin-consumers',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, ConsumerUserFormComponent],
})
export class ConsumersComponent extends AbstractList<IAdminConsumerResponse> {
  private readonly service = inject(ConsumersService);
  private readonly router = inject(Router);

  override setColumns(): void {
    this.columns = [
      // { field: 'id', header: 'شناسه', type: 'id' },
      { field: 'name', header: 'نام' },
      { field: 'business_counts', header: 'تعداد فعالیت اقتصادی' },
      {
        field: 'partner',
        header: 'ایجاد شده توسط',
        type: 'nested',
        nestedOption: { path: 'partner.name' },
      },

      {
        field: 'status',
        header: 'وضعیت',
        type: 'nested',
        nestedOption: { path: 'status.translate' },
      },
      // {
      //   field: 'license_expires_at',
      //   header: 'تاریخ انقضا لایسنس',
      //   customDataModel(item) {
      //     if (item.license_info) {
      //       return formatJalali(item.license_info.expires_at);
      //     }
      //     return 'بدون لایسنس';
      //   },
      // },
      {
        field: 'created_at',
        header: 'تاریخ ایجاد',
        type: 'date',
      },
    ];
  }

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

  toSinglePage(consumer: IAdminConsumerResponse) {
    this.router.navigateByUrl(superAdminConsumersNamedRoutes.consumer.meta.pagePath!(consumer.id));
  }
}
