@infrab4a/connect-angular 3.7.8-beta.1 → 3.7.8-beta.3

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.
@@ -822,7 +822,7 @@
822
822
  this.generateCartObject = function (items) { return items.reduce(function (cart, item) {
823
823
  var _h;
824
824
  var _a;
825
- return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i3.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })), _h)));
825
+ return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i3.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })), _h)));
826
826
  }, {}); };
827
827
  this.buildLineItem = function (_h) {
828
828
  var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
@@ -833,7 +833,7 @@
833
833
  case 0: return [4 /*yield*/, this.getProductData(item.id)];
834
834
  case 1:
835
835
  product = _h.sent();
836
- 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;
836
+ 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.id === item.id; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
837
837
  if (this.checkMaxStock(item, quantity || 0))
838
838
  throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
839
839
  image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
@@ -900,7 +900,7 @@
900
900
  var _this = this;
901
901
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
902
902
  var _a;
903
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
903
+ var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
904
904
  if (!i3.isNil(checkoutItem))
905
905
  checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
906
906
  return checkout;
@@ -920,7 +920,7 @@
920
920
  CartService.prototype.removeItem = function (item) {
921
921
  var _this = this;
922
922
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
923
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
923
+ var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.id === item.id; });
924
924
  if (index >= 0)
925
925
  checkout.lineItems.splice(index, 1);
926
926
  return checkout;