From 96957663e54fcb183b8cd8f0620fd8d2c161326e Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 11 Nov 2024 14:42:31 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A8?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B8=A9=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 22 ++++++++++------ src/controllers/ProfileEmployeeController.ts | 22 ++++++++++------ .../ProfileEmployeeTempController.ts | 25 +++++++++++++++---- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 708b5fc0..eb04316c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -228,14 +228,20 @@ export class ProfileController extends Controller { where: { profileId: id }, order: { lastUpdatedAt: "DESC" }, }); - const Education = educations.map((item) => ({ - institute: item.institute ? item.institute : "-", - date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "-", - degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", - })); + const Education = educations && educations.length > 0 + ? educations.map((item) => ({ + institute: item.institute ? item.institute : "-", + date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "-", + degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", + })) + : [{ + institute: "-", + date: "-", + degree: "-", + }] const mapData = { // Id: profile.id, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 798f7ed1..97b21044 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -231,14 +231,20 @@ export class ProfileEmployeeController extends Controller { where: { profileEmployeeId: id }, order: { lastUpdatedAt: "DESC" }, }); - const Education = educations.map((item) => ({ - Institute: item.institute ? item.institute : "-", - Date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "-", - Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", - })); + const Education = educations && educations.length > 0 + ? educations.map((item) => ({ + institute: item.institute ? item.institute : "-", + date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "-", + degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", + })) + : [{ + institute: "-", + date: "-", + degree: "-", + }] const mapData = { // Id: profile.id, diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index e185420d..a676e793 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -195,6 +195,25 @@ export class ProfileEmployeeTempController extends Controller { let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`; let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`; + const educations = await this.educationRepository.find({ + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, + order: { lastUpdatedAt: "DESC" }, + }); + const Education = educations && educations.length > 0 + ? educations.map((item) => ({ + institute: item.institute ? item.institute : "-", + date: + item.startDate && item.endDate + ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` + : "-", + degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", + })) + : [{ + institute: "-", + date: "-", + degree: "-", + }] const mapData = { Id: profile.id, CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", @@ -214,11 +233,7 @@ export class ProfileEmployeeTempController extends Controller { profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) : "", - Education: - profile.profileEducations.length > 0 && - profile.profileEducations[profile.profileEducations.length - 1].institute != null - ? profile.profileEducations[profile.profileEducations.length - 1].institute - : "", + Education: Education, AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", SalaryDate: profile.profileSalary.length > 0 && profile.profileSalary[0].date != null