fix: update condition and response relation

This commit is contained in:
Methapon2001 2024-04-03 12:49:20 +07:00
parent 7ba77907d3
commit e7568fa06f

View file

@ -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 },
});
}
}