import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterTenantDto } from './dto/filter-tenant.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { TenantReadOrchestrator } from '../domain/usecases/tenant-read.orchestrator';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { Public } from 'src/core/guards';
import { UserEntity } from '../../user/domain/entities/user.entity';

@ApiTags(`${MODULE_NAME.TENANT.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.TENANT}`)
@Public(false)
@ApiBearerAuth('JWT')
export class TenantReadController {
  constructor(private orchestrator: TenantReadOrchestrator) {}

  @Get()
  @Pagination()
  async index(
    @Query() params: FilterTenantDto,
  ): Promise<PaginationResponse<UserEntity>> {
    return await this.orchestrator.index(params);
  }

  @Get(':id')
  async detail(@Param('id') id: string): Promise<UserEntity> {
    return await this.orchestrator.detail(id);
  }
}
