@infrab4a/connect-angular 3.3.0-beta.1 → 3.3.0-beta.2

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.
@@ -849,15 +849,15 @@
849
849
  });
850
850
  return cart;
851
851
  };
852
- this.buildLineItem = function (_h) {
853
- var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
852
+ this.buildLineItem = function (_k) {
853
+ var checkout = _k.checkout, item = _k.item, quantity = _k.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, type, isGift, pricePaid;
856
- return __generator(this, function (_h) {
857
- switch (_h.label) {
855
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, type, isGift, pricePaid;
856
+ return __generator(this, function (_k) {
857
+ switch (_k.label) {
858
858
  case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
859
859
  case 1:
860
- product = _h.sent();
860
+ product = _k.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,7 +869,26 @@
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);
872
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
+ }));
873
892
  return [2 /*return*/, {
874
893
  checkout: checkout,
875
894
  lineItem: i2.LineItem.toInstance({
@@ -885,9 +904,9 @@
885
904
  weight: weight !== null && weight !== void 0 ? weight : product.weight,
886
905
  quantity: (item.quantity || 0) + (quantity || 0),
887
906
  pricePaid: pricePaid,
888
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
907
+ categories: (_h = product.categories) !== null && _h !== void 0 ? _h : [],
889
908
  isGift: isGift !== null && isGift !== void 0 ? isGift : null,
890
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
909
+ costPrice: (_j = product.costPrice) !== null && _j !== void 0 ? _j : 0,
891
910
  type: type,
892
911
  }),
893
912
  }];
@@ -895,8 +914,8 @@
895
914
  });
896
915
  });
897
916
  };
898
- this.getProductPrice = function (_h) {
899
- var product = _h.product, isSubscriber = _h.isSubscriber;
917
+ this.getProductPrice = function (_k) {
918
+ var product = _k.product, isSubscriber = _k.isSubscriber;
900
919
  var info = product.price;
901
920
  if (product.isGift)
902
921
  return 0;
@@ -913,13 +932,13 @@
913
932
  var _this = this;
914
933
  if (quantity === void 0) { quantity = 1; }
915
934
  console.log('teste');
916
- return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
917
- switch (_h.label) {
935
+ return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_k) {
936
+ switch (_k.label) {
918
937
  case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
919
- case 1: return [2 /*return*/, _h.sent()];
938
+ case 1: return [2 /*return*/, _k.sent()];
920
939
  }
921
- }); }); }), operators.mergeMap(function (_h) {
922
- var checkout = _h.checkout, lineItem = _h.lineItem;
940
+ }); }); }), operators.mergeMap(function (_k) {
941
+ var checkout = _k.checkout, lineItem = _k.lineItem;
923
942
  return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
924
943
  }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
925
944
  };
@@ -956,31 +975,31 @@
956
975
  CartService.prototype.updateUserCart = function (user) {
957
976
  var _this = this;
958
977
  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 () {
959
- var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
978
+ var _a, _b, _k, _l, _m, _o, _p, _q, _r, _s, _t;
960
979
  var _this = this;
961
- return __generator(this, function (_s) {
962
- switch (_s.label) {
980
+ return __generator(this, function (_u) {
981
+ switch (_u.label) {
963
982
  case 0:
964
- _j = (_h = this.checkoutService)
983
+ _l = (_k = this.checkoutService)
965
984
  .updateCheckoutLineItems;
966
- _l = (_k = i2.Checkout).toInstance;
967
- _o = (_m = Object).assign;
968
- _p = [Object.assign({}, checkout.toPlain())];
969
- _q = {};
985
+ _o = (_m = i2.Checkout).toInstance;
986
+ _q = (_p = Object).assign;
987
+ _r = [Object.assign({}, checkout.toPlain())];
988
+ _s = {};
970
989
  if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
971
- 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) {
972
- switch (_h.label) {
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 (_k) {
991
+ switch (_k.label) {
973
992
  case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
974
- case 1: return [2 /*return*/, (_h.sent()).lineItem];
993
+ case 1: return [2 /*return*/, (_k.sent()).lineItem];
975
994
  }
976
995
  }); }); }))];
977
996
  case 1:
978
- _r = _s.sent();
997
+ _t = _u.sent();
979
998
  return [3 /*break*/, 3];
980
999
  case 2:
981
- _r = [];
982
- _s.label = 3;
983
- case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])])
1000
+ _t = [];
1001
+ _u.label = 3;
1002
+ case 3: return [2 /*return*/, _l.apply(_k, [_o.apply(_m, [_q.apply(_p, _r.concat([(_s.lineItems = _t, _s)]))])])
984
1003
  .toPromise()];
985
1004
  }
986
1005
  });