From a0b4bef3a40085c229c351348599d8245accefc4 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Wed, 29 May 2024 14:55:13 +0700 Subject: [PATCH] Update ProfileController.ts --- src/controllers/ProfileController.ts | 126 ++++++++++++++------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 9d68cf03..8dbcbdd7 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -301,71 +301,73 @@ export class ProfileController extends Controller { const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; - const Profile = { - CitizenId: - profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", - Prefix: profiles?.prefix != null ? profiles.prefix : "", - FirstName: profiles?.firstName != null ? profiles.firstName : "", - LastName: profiles?.lastName != null ? profiles.lastName : "", - FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, - BirthDay: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) - : null, - BirthDayText: - profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) - : "", - BirthMonth: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) - : null, // Months are zero-based - BirthYear: profiles?.birthDate - ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) - : null, - BirthYearText: - profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) - : "", - Address: "", - District: "", - Area: "", - Province: "", - Telephone: profiles?.telephoneNumber ?? null, - CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", - CoupleFullName: - profileFamilyCouple?.couplePrefix || - profileFamilyCouple?.coupleFirstName || - profileFamilyCouple?.coupleLastNameOld - ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() + const Profile = [ + { + CitizenId: + profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", + Prefix: profiles?.prefix != null ? profiles.prefix : "", + FirstName: profiles?.firstName != null ? profiles.firstName : "", + LastName: profiles?.lastName != null ? profiles.lastName : "", + FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, + BirthDay: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) : null, - FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", - FatherFullName: - profileFamilyFather?.fatherPrefix || - profileFamilyFather?.fatherFirstName || - profileFamilyFather?.fatherLastName - ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() + BirthDayText: + profiles.birthDate != null + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) + : "", + BirthMonth: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) + : null, // Months are zero-based + BirthYear: profiles?.birthDate + ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) : null, - MotherPrefix: profileFamilyMother?.motherPrefix ?? "", - MotherFullName: - profileFamilyMother?.motherPrefix || - profileFamilyMother?.motherFirstName || - profileFamilyMother?.motherLastName - ? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() + BirthYearText: + profiles.birthDate != null + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString()) + : "", + Address: "", + District: "", + Area: "", + Province: "", + Telephone: profiles?.telephoneNumber ?? null, + CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, + CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", + CoupleFullName: + profileFamilyCouple?.couplePrefix || + profileFamilyCouple?.coupleFirstName || + profileFamilyCouple?.coupleLastNameOld + ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() + : null, + FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", + FatherFullName: + profileFamilyFather?.fatherPrefix || + profileFamilyFather?.fatherFirstName || + profileFamilyFather?.fatherLastName + ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() + : null, + MotherPrefix: profileFamilyMother?.motherPrefix ?? "", + MotherFullName: + profileFamilyMother?.motherPrefix || + profileFamilyMother?.motherFirstName || + profileFamilyMother?.motherLastName + ? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() + : null, + OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, + Division: "", + Institute: "", + StartDate: profiles?.dateStart, + AppointDate: profiles?.dateAppoint, + BirthDate: profiles?.birthDate + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) : null, - OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, - Division: "", - Institute: "", - StartDate: profiles?.dateStart, - AppointDate: profiles?.dateAppoint, - BirthDate: profiles?.birthDate - ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) - : null, - RetireDate: - profiles.dateRetireLaw != null - ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString()) - : "", - // AvatarId: profiles?.avatar ?? null, - }; + RetireDate: + profiles.dateRetireLaw != null + ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString()) + : "", + // AvatarId: profiles?.avatar ?? null, + }, + ]; const certs = await this.certificateRepository.find({ where: { profileId: id },