Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PaxList issue - There should be only 1 PaxList inside each RoomConfig #18

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ class Plugin {
})[roomType];
if (RoomType) RoomConfig.RoomType = RoomType;
if (passengers && passengers.length && !noPaxList) {
RoomConfig.PaxList = passengers.map(p => {
const PaxDetails = {
// There should be only 1 PaxList inside each RoomConfig
RoomConfig.PaxList = {};
// Inside PaxList, there should be 1 PaxDetails for each passenger (Pax)
RoomConfig.PaxList.PaxDetails = [];
passengers.forEach((p, index) => {
const EachPaxDetails = {
Forename: this.escapeInvalidXmlChars(p.firstName),
Surname: this.escapeInvalidXmlChars(p.lastName),
PaxType: {
Expand All @@ -225,16 +229,14 @@ class Plugin {
Infant: 'I',
}[p.passengerType] || 'A',
};
if (p.salutation) PaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
if (p.dob) PaxDetails.DateOfBirth = p.dob;
if (p.salutation) EachPaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
if (p.dob) EachPaxDetails.DateOfBirth = p.dob;
if (!R.isNil(p.age) && !isNaN(p.age)) {
if (!(p.passengerType === 'Adult' && p.age === 0)) {
PaxDetails.Age = p.age;
EachPaxDetails.Age = p.age;
}
}
return {
PaxDetails,
};
RoomConfig.PaxList.PaxDetails[index] = EachPaxDetails;
});
}
return { RoomConfig };
Expand Down
Loading