Update ProfileController.ts

This commit is contained in:
AnandaTon 2024-05-29 14:55:13 +07:00
parent 13e565d2d4
commit a0b4bef3a4

View file

@ -301,71 +301,73 @@ export class ProfileController extends Controller {
const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; const _child3 = child3 ? `${child3.orgChild3Name}/` : "";
const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
const Profile = { const Profile = [
CitizenId: {
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", CitizenId:
Prefix: profiles?.prefix != null ? profiles.prefix : "", profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
FirstName: profiles?.firstName != null ? profiles.firstName : "", Prefix: profiles?.prefix != null ? profiles.prefix : "",
LastName: profiles?.lastName != null ? profiles.lastName : "", FirstName: profiles?.firstName != null ? profiles.firstName : "",
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, LastName: profiles?.lastName != null ? profiles.lastName : "",
BirthDay: profiles?.birthDate FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) BirthDay: profiles?.birthDate
: null, ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
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()
: null, : null,
FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", BirthDayText:
FatherFullName: profiles.birthDate != null
profileFamilyFather?.fatherPrefix || ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
profileFamilyFather?.fatherFirstName || : "",
profileFamilyFather?.fatherLastName BirthMonth: profiles?.birthDate
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() ? 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, : null,
MotherPrefix: profileFamilyMother?.motherPrefix ?? "", BirthYearText:
MotherFullName: profiles.birthDate != null
profileFamilyMother?.motherPrefix || ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
profileFamilyMother?.motherFirstName || : "",
profileFamilyMother?.motherLastName Address: "",
? `${profileFamilyMother?.motherPrefix ?? ""} ${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() 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, : null,
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, RetireDate:
Division: "", profiles.dateRetireLaw != null
Institute: "", ? Extension.ToThaiNumber(profiles.dateRetireLaw.toString())
StartDate: profiles?.dateStart, : "",
AppointDate: profiles?.dateAppoint, // AvatarId: profiles?.avatar ?? null,
BirthDate: profiles?.birthDate },
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) ];
: null,
RetireDate:
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(profiles.dateRetireLaw.toString())
: "",
// AvatarId: profiles?.avatar ?? null,
};
const certs = await this.certificateRepository.find({ const certs = await this.certificateRepository.find({
where: { profileId: id }, where: { profileId: id },