import { Injectable } from '@nestjs/common';
import { IndexTenantManager } from './managers/index-tenant.manager';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailTenantManager } from './managers/detail-tenant.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
import { UserReadService } from 'src/modules/user-related/user/data/services/user-read.service';

@Injectable()
export class TenantReadOrchestrator extends BaseReadOrchestrator<UserEntity> {
  constructor(
    private indexManager: IndexTenantManager,
    private detailManager: DetailTenantManager,
    private serviceData: UserReadService,
  ) {
    super();
  }

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

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