import { Body, Controller, Post, Put } from '@nestjs/common';
import { SalesPriceFormulaDataOrchestrator } from '../domain/usecases/sales-price-formula-data.orchestrator';
import {
  SalesPriceFormulaDto,
  TransactionSettingDto,
} from './dto/sales-price-formula.dto';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import {
  SalesPriceFormulaEntity,
  TransactionSetting,
} from '../domain/entities/sales-price-formula.entity';
import { Public } from 'src/core/guards';

@ApiTags(`sales price formulas - data`)
@Controller(['v1/sales-price-formula', 'v1/transaction-setting'])
@Public(false)
@ApiBearerAuth('JWT')
export class SalesPriceFormulaDataController {
  constructor(private orchestrator: SalesPriceFormulaDataOrchestrator) {}

  @Post()
  async create(
    @Body() data: SalesPriceFormulaDto,
  ): Promise<SalesPriceFormulaEntity> {
    return await this.orchestrator.update(data);
  }

  @Public(true)
  @Put()
  async updateTransactionSetting(
    @Body() data: TransactionSettingDto,
  ): Promise<TransactionSetting> {
    return await this.orchestrator.updateTransactionSetting(data);
  }
}
