import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
import { CreateDevTaskDto } from './dto/create-dev-task.dto';
import { UpdateDevTaskDto } from './dto/update-dev-task.dto';
import { DevTaskService } from './dev-task.service';

@Controller('versions/:versionId/dev-tasks')
export class DevTaskController {
  constructor(private readonly devTaskService: DevTaskService) {}

  @Post()
  create(@Param('versionId') versionId: string, @Body() dto: CreateDevTaskDto) {
    return this.devTaskService.create(versionId, dto);
  }

  @Get()
  findAll(@Param('versionId') versionId: string) {
    return this.devTaskService.findAll(versionId);
  }

  @Patch(':id')
  update(@Param('versionId') versionId: string, @Param('id') id: string, @Body() dto: UpdateDevTaskDto) {
    return this.devTaskService.update(versionId, id, dto);
  }

  @Patch(':id/status')
  updateStatus(
    @Param('versionId') versionId: string,
    @Param('id') id: string,
    @Body('status') status: string,
  ) {
    return this.devTaskService.updateStatus(versionId, id, status);
  }

  @Patch(':id/block')
  setBlocked(
    @Param('versionId') versionId: string,
    @Param('id') id: string,
    @Body('blocked') blocked: boolean,
    @Body('reason') reason?: string,
  ) {
    return this.devTaskService.setBlocked(versionId, id, blocked, reason);
  }

  @Patch(':id/transfer')
  transfer(
    @Param('versionId') versionId: string,
    @Param('id') id: string,
    @Body('assigneeId') assigneeId: string,
  ) {
    return this.devTaskService.transfer(versionId, id, assigneeId);
  }

  @Delete(':id')
  remove(@Param('versionId') versionId: string, @Param('id') id: string) {
    return this.devTaskService.remove(versionId, id);
  }
}
