@infrab4a/connect-angular 3.3.0-beta.2 → 3.3.0-beta.5
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 +48 -53
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/angular-firestore.module.js +22 -4
- package/esm2015/services/cart.service.js +6 -31
- package/fesm2015/infrab4a-connect-angular.js +24 -31
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +1 -1
|
@@ -849,15 +849,15 @@
|
|
|
849
849
|
});
|
|
850
850
|
return cart;
|
|
851
851
|
};
|
|
852
|
-
this.buildLineItem = function (
|
|
853
|
-
var checkout =
|
|
852
|
+
this.buildLineItem = function (_h) {
|
|
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,
|
|
856
|
-
return __generator(this, function (
|
|
857
|
-
switch (
|
|
855
|
+
var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, type, isGift, pricePaid;
|
|
856
|
+
return __generator(this, function (_h) {
|
|
857
|
+
switch (_h.label) {
|
|
858
858
|
case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
|
|
859
859
|
case 1:
|
|
860
|
-
product =
|
|
860
|
+
product = _h.sent();
|
|
861
861
|
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
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.');
|
|
@@ -869,26 +869,6 @@
|
|
|
869
869
|
shop: checkout.shop || this.defaultShop,
|
|
870
870
|
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
871
871
|
});
|
|
872
|
-
console.log('checkout', checkout);
|
|
873
|
-
console.log('teste PricePaid', pricePaid);
|
|
874
|
-
console.log('LineItem return', i2.LineItem.toInstance({
|
|
875
|
-
id: id,
|
|
876
|
-
name: name !== null && name !== void 0 ? name : product.name,
|
|
877
|
-
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
878
|
-
brand: product.brand,
|
|
879
|
-
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
880
|
-
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
881
|
-
stock: stock,
|
|
882
|
-
price: price,
|
|
883
|
-
image: image,
|
|
884
|
-
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
885
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
886
|
-
pricePaid: pricePaid,
|
|
887
|
-
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
888
|
-
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
889
|
-
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
890
|
-
type: type,
|
|
891
|
-
}));
|
|
892
872
|
return [2 /*return*/, {
|
|
893
873
|
checkout: checkout,
|
|
894
874
|
lineItem: i2.LineItem.toInstance({
|
|
@@ -904,9 +884,9 @@
|
|
|
904
884
|
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
905
885
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
906
886
|
pricePaid: pricePaid,
|
|
907
|
-
categories: (
|
|
887
|
+
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
908
888
|
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
909
|
-
costPrice: (
|
|
889
|
+
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
910
890
|
type: type,
|
|
911
891
|
}),
|
|
912
892
|
}];
|
|
@@ -914,8 +894,8 @@
|
|
|
914
894
|
});
|
|
915
895
|
});
|
|
916
896
|
};
|
|
917
|
-
this.getProductPrice = function (
|
|
918
|
-
var product =
|
|
897
|
+
this.getProductPrice = function (_h) {
|
|
898
|
+
var product = _h.product, isSubscriber = _h.isSubscriber;
|
|
919
899
|
var info = product.price;
|
|
920
900
|
if (product.isGift)
|
|
921
901
|
return 0;
|
|
@@ -931,14 +911,13 @@
|
|
|
931
911
|
CartService.prototype.addItem = function (item, quantity) {
|
|
932
912
|
var _this = this;
|
|
933
913
|
if (quantity === void 0) { quantity = 1; }
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
switch (_k.label) {
|
|
914
|
+
return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
|
|
915
|
+
switch (_h.label) {
|
|
937
916
|
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
|
|
938
|
-
case 1: return [2 /*return*/,
|
|
917
|
+
case 1: return [2 /*return*/, _h.sent()];
|
|
939
918
|
}
|
|
940
|
-
}); }); }), operators.mergeMap(function (
|
|
941
|
-
var checkout =
|
|
919
|
+
}); }); }), operators.mergeMap(function (_h) {
|
|
920
|
+
var checkout = _h.checkout, lineItem = _h.lineItem;
|
|
942
921
|
return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
|
|
943
922
|
}), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
944
923
|
};
|
|
@@ -975,32 +954,30 @@
|
|
|
975
954
|
CartService.prototype.updateUserCart = function (user) {
|
|
976
955
|
var _this = this;
|
|
977
956
|
return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
|
|
978
|
-
var _a, _b, _k, _l, _m, _o, _p, _q, _r
|
|
957
|
+
var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
979
958
|
var _this = this;
|
|
980
|
-
return __generator(this, function (
|
|
981
|
-
switch (
|
|
959
|
+
return __generator(this, function (_s) {
|
|
960
|
+
switch (_s.label) {
|
|
982
961
|
case 0:
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
_o = (_m =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
_s = {};
|
|
962
|
+
_j = (_h = this.checkoutService).updateCheckoutLineItems;
|
|
963
|
+
_l = (_k = i2.Checkout).toInstance;
|
|
964
|
+
_o = (_m = Object).assign;
|
|
965
|
+
_p = [Object.assign({}, checkout.toPlain())];
|
|
966
|
+
_q = {};
|
|
989
967
|
if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
|
|
990
|
-
return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
991
|
-
switch (
|
|
968
|
+
return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
|
|
969
|
+
switch (_h.label) {
|
|
992
970
|
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
|
|
993
|
-
case 1: return [2 /*return*/, (
|
|
971
|
+
case 1: return [2 /*return*/, (_h.sent()).lineItem];
|
|
994
972
|
}
|
|
995
973
|
}); }); }))];
|
|
996
974
|
case 1:
|
|
997
|
-
|
|
975
|
+
_r = _s.sent();
|
|
998
976
|
return [3 /*break*/, 3];
|
|
999
977
|
case 2:
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
case 3: return [2 /*return*/,
|
|
1003
|
-
.toPromise()];
|
|
978
|
+
_r = [];
|
|
979
|
+
_s.label = 3;
|
|
980
|
+
case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])]).toPromise()];
|
|
1004
981
|
}
|
|
1005
982
|
});
|
|
1006
983
|
}); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
@@ -1559,6 +1536,15 @@
|
|
|
1559
1536
|
},
|
|
1560
1537
|
deps: [i1$1.AngularFirestore, i2.ProductFirestoreRepository],
|
|
1561
1538
|
},
|
|
1539
|
+
{
|
|
1540
|
+
provide: i0.APP_INITIALIZER,
|
|
1541
|
+
useFactory: function (firestore) { return function () {
|
|
1542
|
+
console.log('testeeee');
|
|
1543
|
+
firestore.firestore.settings({ ignoreUndefinedProperties: true });
|
|
1544
|
+
}; },
|
|
1545
|
+
deps: [i1$1.AngularFirestore],
|
|
1546
|
+
multi: true,
|
|
1547
|
+
},
|
|
1562
1548
|
], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
|
|
1563
1549
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
|
|
1564
1550
|
type: i0.NgModule,
|
|
@@ -1719,6 +1705,15 @@
|
|
|
1719
1705
|
},
|
|
1720
1706
|
deps: [i1$1.AngularFirestore, i2.ProductFirestoreRepository],
|
|
1721
1707
|
},
|
|
1708
|
+
{
|
|
1709
|
+
provide: i0.APP_INITIALIZER,
|
|
1710
|
+
useFactory: function (firestore) { return function () {
|
|
1711
|
+
console.log('testeeee');
|
|
1712
|
+
firestore.firestore.settings({ ignoreUndefinedProperties: true });
|
|
1713
|
+
}; },
|
|
1714
|
+
deps: [i1$1.AngularFirestore],
|
|
1715
|
+
multi: true,
|
|
1716
|
+
},
|
|
1722
1717
|
],
|
|
1723
1718
|
}]
|
|
1724
1719
|
}] });
|