import { Injectable } from '@nestjs/common';
import { IndexFaqManager } from './managers/index-faq.manager';
import { FaqReadService } from '../../data/services/faq-read.service';
import { FaqEntity } from '../entities/faq.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailFaqManager } from './managers/detail-faq.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class FaqReadOrchestrator extends BaseReadOrchestrator<FaqEntity> {
  constructor(
    private indexManager: IndexFaqManager,
    private detailManager: DetailFaqManager,
    private serviceData: FaqReadService,
  ) {
    super();
  }

  async index(params): Promise<PaginationResponse<FaqEntity>> {
    this.indexManager.setFilterParam(params);
    this.indexManager.setService(this.serviceData, TABLE_NAME.FAQ);
    await this.indexManager.execute();
    return this.indexManager.getResult();
  }

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