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

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

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

  @Get('formula')
  @Pagination()
  async formula(
    @Query() params: FilterTaxDto,
  ): Promise<PaginationResponse<TaxEntity>> {
    return await this.orchestrator.formula(params);
  }

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