From 97cc610171be0b6396a0b8c6a7132d83ce1f4699 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:43:44 +0700 Subject: [PATCH] refactor: do not update status if not created --- src/controllers/branch-controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index bb0ba51..f988da4 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -210,7 +210,10 @@ export class BranchController extends Controller { }); if (headOfficeId) { - await prisma.branch.update({ where: { id: headOfficeId }, data: { status: Status.ACTIVE } }); + await prisma.branch.updateMany({ + where: { id: headOfficeId, status: Status.CREATED }, + data: { status: Status.ACTIVE }, + }); } this.setStatus(HttpStatus.CREATED);