fix: relation

This commit is contained in:
Methapon2001 2024-06-14 09:45:23 +07:00
parent 5b6c7e7ac8
commit ddec8275d8

View file

@ -304,19 +304,19 @@ export class EmployeeController extends Controller {
include: { customer: true }, include: { customer: true },
}), }),
]); ]);
if (body.provinceId && !province) if (body.provinceId !== province?.id)
throw new HttpError( throw new HttpError(
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
"Province cannot be found.", "Province cannot be found.",
"missing_or_invalid_parameter", "missing_or_invalid_parameter",
); );
if (body.districtId && !district) if (body.districtId !== district?.id)
throw new HttpError( throw new HttpError(
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
"District cannot be found.", "District cannot be found.",
"missing_or_invalid_parameter", "missing_or_invalid_parameter",
); );
if (body.subDistrictId && !subDistrict) if (body.subDistrictId !== subDistrict?.id)
throw new HttpError( throw new HttpError(
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
"Sub-district cannot be found.", "Sub-district cannot be found.",
@ -395,7 +395,11 @@ export class EmployeeController extends Controller {
}, },
employeeCheckup: { employeeCheckup: {
createMany: { createMany: {
data: employeeCheckup || [], data:
employeeCheckup?.map((v) => ({
...v,
provinceId: !!v.provinceId ? null : v.provinceId,
})) || [],
}, },
}, },
employeeOtherInfo: { employeeOtherInfo: {