import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import pageParamsUtils from '@/utils/page-params.utils';
import { Component, computed, inject, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { StockKeepingUnitFormComponent } from '../../components/stockKeepingUnits/form.component';
import { IStockKeepingUnitResponse } from '../../models';
import { StockKeepingUnitsService } from '../../services/stockKeepingUnits.service';

@Component({
  selector: 'superAdmin-stockKeepingUnits',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, StockKeepingUnitFormComponent],
})
export class StockKeepingUnitsComponent extends AbstractList<IStockKeepingUnitResponse> {
  private readonly route = inject(ActivatedRoute);
  pageParams = computed(() => pageParamsUtils(this.route));
  readonly guildId = signal<string>(this.pageParams()['guildId']!);

  private readonly service = inject(StockKeepingUnitsService);

  override setColumns(): void {
    this.columns = [
      { field: 'code', header: 'کد' },
      { field: 'name', header: 'عنوان' },
      { field: 'VAT', header: 'مالیات ارزش افزوده' },
    ];
  }

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