fix: error required args

This commit is contained in:
Methapon Metanipat 2024-09-19 14:25:41 +07:00
parent 065163dac8
commit 463e28c089

View file

@ -90,9 +90,9 @@ export class CustomerBranchCitizenController extends Controller {
async create(@Path() branchId: string, @Body() body: CustomerBranchCitizenPayload) {
const { provinceId, districtId, subDistrictId, ...rest } = body;
const [province, district, subDistrict] = await prisma.$transaction([
prisma.province.findUnique({ where: { id: body.provinceId ?? undefined } }),
prisma.district.findUnique({ where: { id: body.districtId ?? undefined } }),
prisma.subDistrict.findUnique({ where: { id: body.subDistrictId ?? undefined } }),
prisma.province.findFirst({ where: { id: body.provinceId ?? undefined } }),
prisma.district.findFirst({ where: { id: body.districtId ?? undefined } }),
prisma.subDistrict.findFirst({ where: { id: body.subDistrictId ?? undefined } }),
]);
if (body.provinceId && !province) throw relationError("Province");
if (body.districtId && !district) throw relationError("District");