@infrab4a/connect-angular 2.0.12 → 3.0.0
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 +6 -18
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/services/cart.service.js +7 -18
- package/esm2015/services/home-shop.service.js +2 -3
- package/fesm2015/infrab4a-connect-angular.js +5 -17
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +2 -2
- package/services/cart.service.d.ts +1 -2
|
@@ -852,7 +852,7 @@
|
|
|
852
852
|
this.buildLineItem = function (_h) {
|
|
853
853
|
var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
|
|
854
854
|
return __awaiter(_this, void 0, void 0, function () {
|
|
855
|
-
var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku,
|
|
855
|
+
var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, isGift, pricePaid;
|
|
856
856
|
return __generator(this, function (_h) {
|
|
857
857
|
switch (_h.label) {
|
|
858
858
|
case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
|
|
@@ -862,7 +862,7 @@
|
|
|
862
862
|
if (this.checkMaxStock(item, quantity || 0))
|
|
863
863
|
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
864
864
|
image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
865
|
-
id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku
|
|
865
|
+
id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
|
|
866
866
|
isGift = item.isGift || null;
|
|
867
867
|
pricePaid = this.getProductPrice({
|
|
868
868
|
product: item,
|
|
@@ -887,7 +887,6 @@
|
|
|
887
887
|
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
888
888
|
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
889
889
|
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
890
|
-
type: type,
|
|
891
890
|
}),
|
|
892
891
|
}];
|
|
893
892
|
}
|
|
@@ -895,8 +894,8 @@
|
|
|
895
894
|
});
|
|
896
895
|
};
|
|
897
896
|
this.getProductPrice = function (_h) {
|
|
898
|
-
var product = _h.product,
|
|
899
|
-
var info = product.
|
|
897
|
+
var product = _h.product, isSubscriber = _h.isSubscriber;
|
|
898
|
+
var info = product.price;
|
|
900
899
|
if (product.isGift)
|
|
901
900
|
return 0;
|
|
902
901
|
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
@@ -939,8 +938,8 @@
|
|
|
939
938
|
/**
|
|
940
939
|
* @deprecated The method should not be used
|
|
941
940
|
*/
|
|
942
|
-
CartService.prototype.getVariantPriceDiscount = function (item
|
|
943
|
-
return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.
|
|
941
|
+
CartService.prototype.getVariantPriceDiscount = function (item) {
|
|
942
|
+
return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
|
|
944
943
|
};
|
|
945
944
|
CartService.prototype.removeItem = function (item) {
|
|
946
945
|
var _this = this;
|
|
@@ -993,16 +992,6 @@
|
|
|
993
992
|
var _this = this;
|
|
994
993
|
return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
|
|
995
994
|
};
|
|
996
|
-
CartService.prototype.getSubTotalDiscount = function (coupon) {
|
|
997
|
-
return function (subTotalPrice) {
|
|
998
|
-
switch (coupon.type) {
|
|
999
|
-
case i2.CouponTypes.ABSOLUTE:
|
|
1000
|
-
return subTotalPrice - coupon.discount;
|
|
1001
|
-
case i2.CouponTypes.PERCENTAGE:
|
|
1002
|
-
return subTotalPrice * (1 - coupon.discount / 100);
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
};
|
|
1006
995
|
return CartService;
|
|
1007
996
|
}());
|
|
1008
997
|
CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
@@ -1123,7 +1112,6 @@
|
|
|
1123
1112
|
'name',
|
|
1124
1113
|
'weight',
|
|
1125
1114
|
'rate',
|
|
1126
|
-
'type'
|
|
1127
1115
|
])); }),
|
|
1128
1116
|
}); };
|
|
1129
1117
|
}
|