import { Injectable } from '@nestjs/common';
import { IndexItemRateManager } from './managers/index-item-rate.manager';
import { ItemRateReadService } from '../../data/services/item-rate-read.service';
import { ItemRateEntity } from '../entities/item-rate.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailItemRateManager } from './managers/detail-item-rate.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ItemReadService } from 'src/modules/item-related/item/data/services/item-read.service';
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';

@Injectable()
export class ItemRateReadOrchestrator extends BaseReadOrchestrator<ItemRateEntity> {
  constructor(
    private indexManager: IndexItemRateManager,
    private detailManager: DetailItemRateManager,
    private serviceData: ItemRateReadService,
    private itemServiceRead: ItemReadService,
  ) {
    super();
  }

  // untuk sementara function ini tidak terpakai
  async index(params): Promise<PaginationResponse<ItemRateEntity>> {
    // this.indexManager.setFilterParam(params);
    // this.indexManager.setService(this.itemServiceRead, TABLE_NAME.ITEM_RATE);
    // await this.indexManager.execute();
    // return this.indexManager.getResult();
    return;
  }

  async indexItem(params): Promise<PaginationResponse<ItemEntity>> {
    params.ia_all = true;

    this.indexManager.setFilterParam(params);
    this.indexManager.setService(this.itemServiceRead, TABLE_NAME.ITEM);
    await this.indexManager.execute();
    return this.indexManager.getResult();
  }

  async detail(dataId: string): Promise<ItemRateEntity> {
    this.detailManager.setData(dataId);
    this.detailManager.setService(this.serviceData, TABLE_NAME.ITEM_RATE);
    await this.detailManager.execute();
    return this.detailManager.getResult();
  }
}
