@infrab4a/connect-angular 2.0.6-beta.8 → 2.0.6
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.
- package/bundles/infrab4a-connect-angular.umd.js +10 -23
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/services/checkout.service.js +2 -2
- package/esm2015/services/coupon.service.js +5 -23
- package/fesm2015/infrab4a-connect-angular.js +5 -23
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +1 -1
- package/services/checkout.service.d.ts +1 -1
- package/services/coupon.service.d.ts +1 -1
|
@@ -521,10 +521,9 @@
|
|
|
521
521
|
return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
|
|
522
522
|
case 3:
|
|
523
523
|
hasProductCategories = _d.sent();
|
|
524
|
-
console.log('hasProductCategories', hasProductCategories);
|
|
525
524
|
// Se não tem produtos elegíveis, retorna erro
|
|
526
525
|
if (!hasProductCategories)
|
|
527
|
-
throw
|
|
526
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
528
527
|
return [2 /*return*/, coupon];
|
|
529
528
|
}
|
|
530
529
|
});
|
|
@@ -562,7 +561,7 @@
|
|
|
562
561
|
case 3:
|
|
563
562
|
discount = _e.sent();
|
|
564
563
|
return [3 /*break*/, 4];
|
|
565
|
-
case 4: return [2 /*return*/,
|
|
564
|
+
case 4: return [2 /*return*/, discount];
|
|
566
565
|
}
|
|
567
566
|
});
|
|
568
567
|
});
|
|
@@ -627,34 +626,17 @@
|
|
|
627
626
|
switch (_d.label) {
|
|
628
627
|
case 0:
|
|
629
628
|
if (!coupon.productsCategories && !coupon.productsCategories.length) {
|
|
630
|
-
console.log('não possui categories');
|
|
631
629
|
return [2 /*return*/, true];
|
|
632
630
|
}
|
|
633
631
|
return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
|
|
634
632
|
case 1:
|
|
635
633
|
couponCategories = _d.sent();
|
|
636
|
-
console.log('couponCategories', couponCategories.length, couponCategories);
|
|
637
634
|
hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
638
635
|
var _a;
|
|
639
|
-
|
|
640
|
-
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
641
|
-
console.log('produto não tem categorias');
|
|
636
|
+
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
642
637
|
return true;
|
|
643
|
-
}
|
|
644
|
-
return i.categories.some(function (c) {
|
|
645
|
-
console.log('entrou no some 1', c);
|
|
646
|
-
return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); });
|
|
647
|
-
});
|
|
648
|
-
// return i.categories.some(async (c) => {
|
|
649
|
-
// console.log('some category c', c)
|
|
650
|
-
// const categoria: Category & { firestoreId?: string } = await this.categoryRepository.get({id: c})
|
|
651
|
-
// console.log(categoria)
|
|
652
|
-
// console.log(coupon.productsCategories.includes(categoria.id), coupon.productsCategories.includes(categoria.firestoreId), i.isGift)
|
|
653
|
-
// console.log('validation', (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift)
|
|
654
|
-
// return (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift
|
|
655
|
-
// })
|
|
638
|
+
return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
|
|
656
639
|
});
|
|
657
|
-
console.log('final return', hasCategories, hasCategories.length);
|
|
658
640
|
return [2 /*return*/, hasCategories.length ? true : false];
|
|
659
641
|
}
|
|
660
642
|
});
|
|
@@ -786,7 +768,12 @@
|
|
|
786
768
|
};
|
|
787
769
|
CheckoutService.prototype.calcDiscount = function (coupon) {
|
|
788
770
|
var _this = this;
|
|
789
|
-
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return _this
|
|
771
|
+
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
772
|
+
switch (_b.label) {
|
|
773
|
+
case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
|
|
774
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
775
|
+
}
|
|
776
|
+
}); }); }));
|
|
790
777
|
};
|
|
791
778
|
CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
|
|
792
779
|
var _this = this;
|