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

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,12 +450,7 @@
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 __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; }));
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; }));
459
454
  };
460
455
  CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan, checkout, isSubscription) {
461
456
  // Caso não ache nenhum cupom, retorna erro
@@ -609,27 +604,42 @@
609
604
  console.log('não possui categories');
610
605
  return [2 /*return*/, true];
611
606
  }
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
- });
607
+ hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) { return __awaiter(_this, void 0, void 0, function () {
608
+ var _b, couponCategories, index, c;
609
+ return __generator(this, function (_d) {
610
+ switch (_d.label) {
611
+ case 0:
612
+ if (!i.categories || !((_b = i.categories) === null || _b === void 0 ? void 0 : _b.length)) {
613
+ console.log('produto não tem categorias');
614
+ return [2 /*return*/, true];
615
+ }
616
+ couponCategories = [];
617
+ index = 0;
618
+ _d.label = 1;
619
+ case 1:
620
+ if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
621
+ return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
622
+ case 2:
623
+ c = _d.sent();
624
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
625
+ _d.label = 3;
626
+ case 3:
627
+ index++;
628
+ return [3 /*break*/, 1];
629
+ case 4:
630
+ console.log('couponCategories', couponCategories.length, couponCategories);
631
+ return [2 /*return*/, i.categories.some(function (c) {
632
+ console.log('some 1 ', c);
633
+ return couponCategories.some(function (cat) {
634
+ console.log('some 2', cat, cat.id == c, cat.firestoreId);
635
+ if (cat.id == c || cat.firestoreId)
636
+ return true;
637
+ });
638
+ })];
639
+ }
640
+ });
641
+ }); });
642
+ console.log('final return', hasCategories, hasCategories.length);
633
643
  return [2 /*return*/, hasCategories.length ? true : false];
634
644
  });
635
645
  });