From 7d7ac384c3e318beb4df60bdde6675b314d1c672 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:23:12 +0700 Subject: [PATCH] fix: error fk on empty payload registeredBranch field --- src/controllers/customer-controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/customer-controller.ts b/src/controllers/customer-controller.ts index 06e2f20..ca10da2 100644 --- a/src/controllers/customer-controller.ts +++ b/src/controllers/customer-controller.ts @@ -296,13 +296,16 @@ export class CustomerController extends Controller { "relationSubDistrictNotFound", ); } - if (body.registeredBranchId && !branch) { + if (!!body.registeredBranchId && !branch) { throw new HttpError( HttpStatus.BAD_REQUEST, "Branch cannot be found.", "relationBranchNotFound", ); } + if (!body.registeredBranchId) { + body.registeredBranchId = undefined; + } const record = await prisma.$transaction( async (tx) => {