From da3f57870e801c2eb5f4285d57ff4472a7e1b2a3 Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Sat, 11 Jul 2026 12:00:11 +0330 Subject: [PATCH] YARA-917 --- .../expert-insurer.controller.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/expert-insurer/expert-insurer.controller.ts b/src/expert-insurer/expert-insurer.controller.ts index ce51129..9d11423 100644 --- a/src/expert-insurer/expert-insurer.controller.ts +++ b/src/expert-insurer/expert-insurer.controller.ts @@ -99,20 +99,32 @@ export class ExpertInsurerController { @Put("branches/:branchId/status") @ApiParam({ name: "branchId" }) - @ApiQuery({ name: "isActive", type: Boolean }) + @ApiBody({ + schema: { + type: "object", + properties: { isActive: { type: "boolean" } }, + required: ["isActive"], + }, + }) async setBranchStatus( @CurrentUser() insurer, @Param("branchId") branchId: string, - @Query("isActive") isActive: string, + @Body("isActive") isActive: unknown, ) { if (!insurer) { throw new UnauthorizedException("Could not identify the current user."); } - const normalized = String(isActive).trim().toLowerCase(); - if (!["true", "false", "1", "0", "yes", "no"].includes(normalized)) { - throw new BadRequestException("isActive must be true/false"); + // Accept native boolean (JSON body) or string coercion (legacy query/form usage) + let active: boolean; + if (typeof isActive === "boolean") { + active = isActive; + } else { + const normalized = String(isActive ?? "").trim().toLowerCase(); + if (!["true", "false", "1", "0", "yes", "no"].includes(normalized)) { + throw new BadRequestException("isActive must be a boolean"); + } + active = ["true", "1", "yes"].includes(normalized); } - const active = ["true", "1", "yes"].includes(normalized); return this.expertInsurerService.setBranchActive( insurer.clientKey, branchId,