diff --git a/src/controllers/branch/branch-controller.ts b/src/controllers/branch/branch-controller.ts index a255e56..3dac955 100644 --- a/src/controllers/branch/branch-controller.ts +++ b/src/controllers/branch/branch-controller.ts @@ -216,7 +216,7 @@ export class BranchController extends Controller { include: { province: true, district: true, subDistrict: true }, data: { ...rest, - isHeadOffice: headOfficeId === null, + isHeadOffice: headOfficeId !== undefined ? headOfficeId === null : undefined, province: { connect: provinceId ? { id: provinceId } : undefined, disconnect: provinceId === null || undefined, @@ -262,6 +262,13 @@ export class BranchController extends Controller { throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.", "data_exists"); } - return await prisma.branch.delete({ where: { id: branchId } }); + return await prisma.branch.delete({ + include: { + province: true, + district: true, + subDistrict: true, + }, + where: { id: branchId }, + }); } }