@infrab4a/connect-angular 2.0.6-beta.3 → 2.0.6-beta.4

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.
@@ -450,7 +450,12 @@
450
450
  nickname: { operator: i2.Where.EQUALS, value: nickname },
451
451
  active: { operator: i2.Where.EQUALS, value: true },
452
452
  },
453
- })).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription); }), operators.concatMap(function (coupon) { return _this.checkCouponUseAndLimit(coupon, userEmail, checkout); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }), operators.map(function (coupon) { return coupon; }));
453
+ })).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription); }), operators.concatMap(function (coupon) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_d) {
454
+ switch (_d.label) {
455
+ case 0: return [4 /*yield*/, this.checkCouponUseAndLimit(coupon, userEmail, checkout)];
456
+ case 1: return [2 /*return*/, _d.sent()];
457
+ }
458
+ }); }); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }), operators.map(function (coupon) { return coupon; }));
454
459
  };
455
460
  CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan, checkout, isSubscription) {
456
461
  // Caso não ache nenhum cupom, retorna erro
@@ -600,33 +605,32 @@
600
605
  var hasCategories;
601
606
  var _this = this;
602
607
  return __generator(this, function (_d) {
603
- if (coupon.productsCategories && coupon.productsCategories.length) {
604
- hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
605
- var _a;
606
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
607
- return i.categories.some(function (c) { return __awaiter(_this, void 0, void 0, function () {
608
- var categoria;
609
- return __generator(this, function (_d) {
610
- switch (_d.label) {
611
- case 0: return [4 /*yield*/, this.categoryRepository.get({ id: c })];
612
- case 1:
613
- categoria = _d.sent();
614
- console.log(categoria);
615
- console.log(coupon.productsCategories.includes(categoria.id), coupon.productsCategories.includes(categoria.firestoreId), i.isGift);
616
- console.log('validation', (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift);
617
- return [2 /*return*/, (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift];
618
- }
619
- });
620
- }); });
621
- }
622
- return true;
623
- });
624
- return [2 /*return*/, hasCategories.length ? true : false];
625
- }
626
- else {
608
+ if (!coupon.productsCategories && !coupon.productsCategories.length) {
609
+ console.log('não possui categories');
627
610
  return [2 /*return*/, true];
628
611
  }
629
- return [2 /*return*/];
612
+ hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
613
+ var _a;
614
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length)) {
615
+ console.log('produto não tem categorias');
616
+ return true;
617
+ }
618
+ return i.categories.some(function (c) { return __awaiter(_this, void 0, void 0, function () {
619
+ var categoria;
620
+ return __generator(this, function (_d) {
621
+ switch (_d.label) {
622
+ case 0: return [4 /*yield*/, this.categoryRepository.get({ id: c })];
623
+ case 1:
624
+ categoria = _d.sent();
625
+ console.log(categoria);
626
+ console.log(coupon.productsCategories.includes(categoria.id), coupon.productsCategories.includes(categoria.firestoreId), i.isGift);
627
+ console.log('validation', (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift);
628
+ return [2 /*return*/, (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift];
629
+ }
630
+ });
631
+ }); });
632
+ });
633
+ return [2 /*return*/, hasCategories.length ? true : false];
630
634
  });
631
635
  });
632
636
  };