import { Body, Controller, Get, Param, Patch, Query, Req, UseGuards } from '@nestjs/common'; import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; import { LabOrgGuard } from '../../common/guards/lab-org.guard'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { ListLabTasksDto, UpdateLabTaskDto } from './dto/tasks.dto'; import { TasksService } from './tasks.service'; @ApiTags('tasks') @ApiBearerAuth('JWT-auth') @UseGuards(JwtAuthGuard, LabOrgGuard) @Controller('tasks') export class TasksController { constructor(private readonly tasksService: TasksService) {} @Get() @ApiOperation({ summary: 'List lab tasks (owner: all, staff: assigned only)' }) list(@Query() query: ListLabTasksDto, @Req() req) { const organizationId = this.tasksService.getOrganizationIdFromUser(req.user); return this.tasksService.list(organizationId, req.user.id, query, req.user.language); } @Patch(':taskId') @ApiOperation({ summary: 'Update task status' }) updateStatus( @Param('taskId') taskId: string, @Body() dto: UpdateLabTaskDto, @Req() req, ) { const organizationId = this.tasksService.getOrganizationIdFromUser(req.user); return this.tasksService.updateStatus( taskId, dto, organizationId, req.user.id, req.user.language, ); } }