import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Put,
} from '@nestjs/common';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import { WebBidsService } from '../../services/web-bids.service';
import { Bid } from '../../entities/bid.entity';
import { DeletesDto } from '../../dto/deletes.dto';
import { CreateWebBidDto } from '../../dto/web-bid/create-web-bid';
import { WebBid } from '../../entities/wed-bid.entity';
import { UpdateWebBidDto } from '../../dto/web-bid/update-web-bid';

@Controller('admin/web-bids')
export class AdminWebBidsController {
  constructor(private readonly webBidsService: WebBidsService) {}

  @Get()
  async index(@Paginate() query: PaginateQuery) {
    return await this.webBidsService.index(query);
  }

  @Get('test')
  async test(@Paginate() query: PaginateQuery) {
    return await this.webBidsService.getDataClient();
  }

  @Post()
  async create(@Body() data: CreateWebBidDto) {
    return await this.webBidsService.create(data);
  }

  @Put(':id')
  async update(@Param('id') id: WebBid['id'], @Body() data: UpdateWebBidDto) {
    return await this.webBidsService.update(id, data);
  }

  @Delete(':id')
  async delete(@Param('id') id: WebBid['id']) {
    return await this.webBidsService.delete(id);
  }

  @Post('deletes')
  async deletes(@Body() data: DeletesDto) {
    return await this.webBidsService.deletes(data.ids);
  }
}
