@infrab4a/connect-angular 2.0.6 → 2.0.8-beta.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.
@@ -521,7 +521,6 @@
521
521
  return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
522
522
  case 3:
523
523
  hasProductCategories = _d.sent();
524
- // Se não tem produtos elegíveis, retorna erro
525
524
  if (!hasProductCategories)
526
525
  throw 'Seu carrinho não possui produtos elegíveis para desconto.';
527
526
  return [2 /*return*/, coupon];
@@ -625,7 +624,7 @@
625
624
  return __generator(this, function (_d) {
626
625
  switch (_d.label) {
627
626
  case 0:
628
- if (!coupon.productsCategories && !coupon.productsCategories.length) {
627
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
629
628
  return [2 /*return*/, true];
630
629
  }
631
630
  return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
@@ -953,15 +952,27 @@
953
952
  };
954
953
  CartService.prototype.updateUserCart = function (user) {
955
954
  var _this = this;
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) {
957
- var _a;
958
- return _this.checkoutService.updateCheckoutLineItems(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
959
- switch (_h.label) {
960
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
961
- case 1: return [2 /*return*/, _h.sent()];
962
- }
963
- }); }); })) || [] })));
964
- }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
955
+ return rxjs.from(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 () {
956
+ var _a, _h, _j, _k, _l, _m, _o, _p, _q;
957
+ var _this = this;
958
+ return __generator(this, function (_r) {
959
+ switch (_r.label) {
960
+ case 0:
961
+ _j = (_h = this.checkoutService).updateCheckoutLineItems;
962
+ _l = (_k = i2.Checkout).toInstance;
963
+ _o = (_m = Object).assign;
964
+ _p = [Object.assign({}, checkout.toPlain())];
965
+ _q = {};
966
+ return [4 /*yield*/, Promise.all((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
967
+ switch (_h.label) {
968
+ case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
969
+ case 1: return [2 /*return*/, (_h.sent()).lineItem];
970
+ }
971
+ }); }); }))];
972
+ case 1: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = (_r.sent()) || [], _q)]))])]).toPromise()];
973
+ }
974
+ });
975
+ }); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
965
976
  };
966
977
  CartService.prototype.clearCart = function () {
967
978
  var _this = this;