fix: error fk on empty payload registeredBranch field

This commit is contained in:
Methapon2001 2024-07-23 11:23:12 +07:00
parent e509cd1fd5
commit 7d7ac384c3

View file

@ -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) => {