// 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 { Router } from '@angular/router';
import { superAdminConsumerPosesNamedRoutes } from '../../constants/routes/poses';
import { IPosResponse } from '../../models';
import { AdminPosesService } from '../../services/poses.service';
import { ConsumerPosFormComponent } from './form.component';

@Component({
  selector: 'superAdmin-consumer-poses-list',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, ConsumerPosFormComponent],
})
export class ConsumerPosesComponent extends AbstractList<IPosResponse> {
  @Input({ required: true }) consumerId!: string;
  @Input({ required: true }) businessId!: string;
  @Input({ required: true }) complexId!: string;
  @Input() fullHeight?: boolean;
  @Input() header: IColumn[] = [
    // { field: 'id', header: 'شناسه', type: 'id' },
    { field: 'name', header: 'عنوان' },
    { field: 'serial_number', header: 'شماره سریال' },
    { field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
    { field: 'pos_type', header: 'نوع دستگاه' },
    {
      field: 'provider',
      header: 'ارایه‌دهنده',
      type: 'nested',
      nestedOption: { path: 'provider.name' },
    },
    { field: 'status', header: 'وضعیت' },
    {
      field: 'created_at',
      header: 'تاریخ ایجاد',
      type: 'date',
    },
  ];

  private readonly service = inject(AdminPosesService);
  private readonly router = inject(Router);

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

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

  toSinglePage(item: IPosResponse) {
    this.router.navigateByUrl(
      superAdminConsumerPosesNamedRoutes.pos.meta.pagePath!(
        this.consumerId,
        this.businessId,
        this.complexId,
        item.id,
      ),
    );
  }
}
