Skip to content

Commit

Permalink
Fix PaxList issue - There should be only 1 PaxList inside each RoomCo…
Browse files Browse the repository at this point in the history
…nfig

Insdie PaxList there should be one PaxDetails for each passenger (Pax)
  • Loading branch information
shintre committed Aug 24, 2024
1 parent 6ea4854 commit 278c84f
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 278c84f

Please sign in to comment.