diff --git a/src/controllers/employee-controller.ts b/src/controllers/employee-controller.ts index 24408ae..69ec871 100644 --- a/src/controllers/employee-controller.ts +++ b/src/controllers/employee-controller.ts @@ -304,19 +304,19 @@ export class EmployeeController extends Controller { include: { customer: true }, }), ]); - if (body.provinceId && !province) + if (body.provinceId !== province?.id) throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", "missing_or_invalid_parameter", ); - if (body.districtId && !district) + if (body.districtId !== district?.id) throw new HttpError( HttpStatus.BAD_REQUEST, "District cannot be found.", "missing_or_invalid_parameter", ); - if (body.subDistrictId && !subDistrict) + if (body.subDistrictId !== subDistrict?.id) throw new HttpError( HttpStatus.BAD_REQUEST, "Sub-district cannot be found.", @@ -395,7 +395,11 @@ export class EmployeeController extends Controller { }, employeeCheckup: { createMany: { - data: employeeCheckup || [], + data: + employeeCheckup?.map((v) => ({ + ...v, + provinceId: !!v.provinceId ? null : v.provinceId, + })) || [], }, }, employeeOtherInfo: {