import { Controller, Get, Post, Patch, Body, Param } from '@nestjs/common';
import { PropostasService } from './propostas.service';

@Controller()
export class PropostasController {
  constructor(private svc: PropostasService) {}

  @Get('propostas') findAll() { return this.svc.findAll(); }
  @Get('propostas/:id') findOne(@Param('id') id: string) { return this.svc.findOne(id); }
  @Post('propostas') create(@Body() body: any) { return this.svc.create(body); }
  @Patch('propostas/:id') update(@Param('id') id: string, @Body() body: any) { return this.svc.update(id, body); }
  @Post('propostas/:id/selecionar') selecionar(@Param('id') id: string) { return this.svc.selecionar(id); }

  @Get('demandas/:demandaId/propostas') byDemanda(@Param('demandaId') id: string) { return this.svc.findByDemanda(id); }
  @Post('demandas/:demandaId/propostas') createForDemanda(@Param('demandaId') demandaId: string, @Body() body: any) {
    return this.svc.create({ ...body, demanda_id: demandaId });
  }
}
