Skip to content

Commit fb9664d

Browse files
committed
Make send email to partner and guest as custom parameters
1 parent a789359 commit fb9664d

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

index.js

+24-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const CUSTOM_FIELD_IDS = {
2121
ORIGINCOUNTRY: 7,
2222
TRAVELAGENCY: 8,
2323
FAMILS: 9,
24+
SEND_EMAIL_TO_PARTNER: 10,
25+
SEND_EMAIL_TO_GUEST: 11
2426
}
2527
const EQUIPMENT_FIELD_IDS = {
2628
EBIKE: 1001,
@@ -416,6 +418,8 @@ class Plugin {
416418
let originCountry = "";
417419
let travelAgency = "";
418420
let famils = 0;
421+
let sendEmailToPartner = 0;
422+
let sendEmailToGuest = 0;
419423

420424
if (customFieldValues && customFieldValues.length) {
421425
console.log("Len: " + customFieldValues.length);
@@ -424,7 +428,7 @@ class Plugin {
424428
console.log('unit.value: ', unit.value);
425429
switch(parseInt(unit.field.id)) {
426430
case CUSTOM_FIELD_IDS.ORIGINCOUNTRY:
427-
originCountry = !isNilOrEmpty(unit.value) ? unit.value : "";
431+
originCountry = !isNilOrEmpty(unit.value) ? ORIGIN_COUNTRIES[unit.value] : "";
428432
break;
429433
case CUSTOM_FIELD_IDS.TRAVELAGENCY:
430434
travelAgency = !isNilOrEmpty(unit.value) ? unit.value : "";
@@ -433,6 +437,14 @@ class Plugin {
433437
let booleanFamils = !isNilOrEmpty(unit.value) ? unit.value : "";
434438
famils = booleanFamils === true ? 1 : 0;
435439
break;
440+
case CUSTOM_FIELD_IDS.SEND_EMAIL_TO_PARTNER:
441+
let booleanEmailToPartner = !isNilOrEmpty(unit.value) ? unit.value : "";
442+
sendEmailToPartner = booleanEmailToPartner === true ? 1 : 0;
443+
break;
444+
case CUSTOM_FIELD_IDS.SEND_EMAIL_TO_GUEST:
445+
let booleanEmailToGuest = !isNilOrEmpty(unit.value) ? unit.value : "";
446+
sendEmailToGuest = booleanEmailToGuest === true ? 1 : 0;
447+
break;
436448
}
437449
})
438450

@@ -616,8 +628,8 @@ class Plugin {
616628
paymentType: "Invoice",
617629
bookingPartnerId: bookingPartnerId,
618630
bookingRefID: reference,
619-
sendEmailToPartner: 0,
620-
sendEmailToGuest: 1
631+
sendEmailToPartner: sendEmailToPartner,
632+
sendEmailToGuest: sendEmailToGuest
621633
// settlementMethod,
622634
};
623635
booking = R.path(['data'], await axios({
@@ -900,21 +912,24 @@ class Plugin {
900912
let customFieldsToShow = [];
901913
// The custom field's type. Supported types: yes-no, short, long, count, and extended-option.
902914

915+
let index = 0;
916+
903917
customFieldsToShow.push ({
904918
id: CUSTOM_FIELD_IDS.ORIGINCOUNTRY,
905919
title: "Entry Origin Country",
906920
subtitle: "Enter the traveler's country of origin",
907921
type: "extended-option",
908922
isPerUnitItem: false,
909-
options: ORIGIN_COUNTRIES.reduce(function(map, obj) {
910-
map[value] = obj;
911-
map[label] = obj;
912-
return map;
913-
}, {}),
923+
options: ORIGIN_COUNTRIES.map(name => ({
924+
value: index++,
925+
label: name,
926+
})),
914927
})
915928

916929
addCustomField(CUSTOM_FIELD_IDS.TRAVELAGENCY, "Entry Travel Agency", "Enter the travel agency name", "short");
917-
addCustomField(CUSTOM_FIELD_IDS.FAMILS, "Is it famils booking?", "Entry whether this is a famil booking", "yes-no");
930+
addCustomField(CUSTOM_FIELD_IDS.FAMILS, "Is this a famil booking?", "Entry whether this is a famil booking", "yes-no");
931+
addCustomField(CUSTOM_FIELD_IDS.SEND_EMAIL_TO_PARTNER, "Send confirmation email to partner?", "Entry whether your want to send booking cofirmation email to partner.", "yes-no");
932+
addCustomField(CUSTOM_FIELD_IDS.SEND_EMAIL_TO_GUEST, "Send confirmation email to guest?", "Entry whether your want to send booking cofirmation email to guest.", "yes-no");
918933

919934
selectedUnits.forEach(function (unit, d) {
920935
console.log('unit.unitId: ', String(unit.unitId));

0 commit comments

Comments
 (0)