@infrab4a/connect-angular 3.6.0-beta.11 → 3.6.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -987,7 +987,7 @@
|
|
|
987
987
|
};
|
|
988
988
|
CartService.prototype.checkGifts = function (checkout) {
|
|
989
989
|
return __awaiter(this, void 0, void 0, function () {
|
|
990
|
-
var campaigns, notGiftItems, cartTotal, elegibleCampaigns, _loop_1, campaigns_1, campaigns_1_1, campaign, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, e_1_1, e_2_1, gifts;
|
|
990
|
+
var campaigns, notGiftItems, cartTotal, elegibleCampaigns, _loop_1, campaigns_1, campaigns_1_1, campaign, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, e_1_1, e_2_1, productArray, gifts;
|
|
991
991
|
var e_3, _k, e_2, _l, e_1, _m;
|
|
992
992
|
return __generator(this, function (_o) {
|
|
993
993
|
switch (_o.label) {
|
|
@@ -1001,9 +1001,9 @@
|
|
|
1001
1001
|
.then(function (data) { return data.data; })];
|
|
1002
1002
|
case 1:
|
|
1003
1003
|
campaigns = _o.sent();
|
|
1004
|
-
if (!campaigns.length)
|
|
1005
|
-
checkout;
|
|
1006
1004
|
notGiftItems = checkout.lineItems.filter(function (item) { return !item.isGift; });
|
|
1005
|
+
if (!campaigns.length)
|
|
1006
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1007
1007
|
cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1008
1008
|
elegibleCampaigns = [];
|
|
1009
1009
|
_loop_1 = function (campaign) {
|
|
@@ -1047,7 +1047,7 @@
|
|
|
1047
1047
|
finally { if (e_3) throw e_3.error; }
|
|
1048
1048
|
}
|
|
1049
1049
|
if (!elegibleCampaigns.length)
|
|
1050
|
-
return [2 /*return*/, checkout];
|
|
1050
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1051
1051
|
campaingnProducts = [];
|
|
1052
1052
|
_o.label = 2;
|
|
1053
1053
|
case 2:
|
|
@@ -1106,8 +1106,12 @@
|
|
|
1106
1106
|
return [7 /*endfinally*/];
|
|
1107
1107
|
case 16:
|
|
1108
1108
|
if (!campaingnProducts.length)
|
|
1109
|
-
return [2 /*return*/, checkout];
|
|
1110
|
-
|
|
1109
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1110
|
+
productArray = campaingnProducts.reduce(function (acc, curr) { return acc.reduce(function (aAcc, aCurr) { return aAcc + aCurr.price.price; }, 0) >
|
|
1111
|
+
curr.reduce(function (cAcc, cCurr) { return cAcc + cCurr.price.price; }, 0)
|
|
1112
|
+
? acc
|
|
1113
|
+
: curr; });
|
|
1114
|
+
gifts = this.giftToLineItems(productArray);
|
|
1111
1115
|
checkout.lineItems = notGiftItems.concat(gifts);
|
|
1112
1116
|
return [2 /*return*/, checkout];
|
|
1113
1117
|
}
|