import { Body, Controller, Get, Param, Put } from '@nestjs/common';
import { ItemRateDataOrchestrator } from '../domain/usecases/item-rate-data.orchestrator';
import { ItemRateDto } from './dto/item-rate.dto';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ItemRateEntity } from '../domain/entities/item-rate.entity';
import { Public } from 'src/core/guards';

@ApiTags(`${MODULE_NAME.ITEM_RATE.split('-').join(' ')} - data`)
@Controller(`v1/${MODULE_NAME.ITEM_RATE}`)
@Public(false)
@ApiBearerAuth('JWT')
export class ItemRateDataController {
  constructor(private orchestrator: ItemRateDataOrchestrator) {}

  // untuk sementara, tidak dapat create
  // @Post()
  // async create(@Body() data: ItemRateDto): Promise<ItemRateEntity> {
  //   return await this.orchestrator.create(data);
  // }

  // untuk sementara, tidak dapat delete
  // @Put('/batch-delete')
  // async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
  //   return await this.orchestrator.batchDelete(body.ids);
  // }

  // update endpoint digunakan untuk update single price
  // pada halaman detail item -> list item rates (dapat update single row)
  @Put(':id')
  async update(
    @Param('id') dataId: string,
    @Body() data: ItemRateDto,
  ): Promise<ItemRateEntity> {
    return await this.orchestrator.update(dataId, data);
  }

  // @Delete(':id')
  // async delete(@Param('id') dataId: string): Promise<string> {
  //   return await this.orchestrator.delete(dataId);
  // }
}
