// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import {
  IColumn,
  PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject, Input } from '@angular/core';
import { IConsumerAccountResponse } from '../../models';
import { AdminConsumerAccountsService } from '../../services/accounts.service';
import { ConsumerAccountFormComponent } from './form.component';

@Component({
  selector: 'superAdmin-consumer-account-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, ConsumerAccountFormComponent],
})
export class ConsumerAccountListComponent extends AbstractList<IConsumerAccountResponse> {
  @Input({ required: true }) consumerId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = [
    { field: 'id', header: 'شناسه', type: 'id' },
    {
      field: 'username',
      header: 'نام کاربری',
      type: 'nested',
      nestedOption: { path: 'account.username' },
    },
    {
      field: 'role',
      header: 'نوع حساب',
      type: 'nested',
      nestedOption: { path: 'role.translate' },
    },
    {
      field: 'pos',
      header: 'پایانه‌ی مرتبط',
      customDataModel: (item) =>
        `${item.pos.name} (${item.pos.complex.name} - ${item.pos.complex.business_activity.name})`,
    },
    {
      field: 'status',
      header: 'وضعیت',
      type: 'nested',
      nestedOption: { path: 'status.translate' },
    },
    {
      field: 'created_at',
      header: 'تاریخ ایجاد',
      type: 'date',
    },
  ];
  private readonly service = inject(AdminConsumerAccountsService);

  override setColumns(): void {
    this.columns = this.header;
  }

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