@infrab4a/connect-angular 3.5.2 → 3.5.3-beta.1

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.
@@ -516,13 +516,11 @@
516
516
  // Verifica o limite de uso geral por usuario
517
517
  if (coupon.useLimit && orders.data.length >= coupon.useLimit)
518
518
  throw new InvalidCouponError('Limite de uso atingido.');
519
- return [4 /*yield*/, this.userValidationAndSubscriptionStatus(coupon, checkout.user)];
520
- case 2:
521
- validUser = _d.sent();
519
+ validUser = this.userValidationAndSubscriptionStatus(coupon, checkout.user);
522
520
  if (!validUser)
523
521
  throw new InvalidCouponError('Usuário não elegível.');
524
522
  return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
525
- case 3:
523
+ case 2:
526
524
  hasProductCategories = _d.sent();
527
525
  if (!hasProductCategories)
528
526
  throw 'Seu carrinho não possui produtos elegíveis para desconto.';
@@ -645,27 +643,23 @@
645
643
  });
646
644
  };
647
645
  CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, user) {
648
- return __awaiter(this, void 0, void 0, function () {
649
- return __generator(this, function (_d) {
650
- // Verifica se o email do usuário é coorporativo
651
- if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
652
- throw new InvalidCouponError('Você não é colaborador.');
653
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
654
- if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
655
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
656
- switch (coupon.exclusivityType) {
657
- case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
658
- return [2 /*return*/, user.isSubscriber ? true : false];
659
- case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
660
- return [2 /*return*/, user.isSubscriber ? false : true];
661
- case i1$1.Exclusivities.NON_SUBSCRIBER:
662
- return [2 /*return*/, user.isSubscriber ? false : true];
663
- default:
664
- return [2 /*return*/, false];
665
- }
666
- return [2 /*return*/];
667
- });
668
- });
646
+ if (coupon.exclusivityType === i1$1.Exclusivities.ALL_USERS)
647
+ return true;
648
+ // Verifica se o email do usuário é coorporativo
649
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
650
+ throw new InvalidCouponError('Você não é colaborador.');
651
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
652
+ if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
653
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
654
+ switch (coupon.exclusivityType) {
655
+ case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
656
+ return user.isSubscriber ? true : false;
657
+ case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
658
+ return user.isSubscriber ? false : true;
659
+ case i1$1.Exclusivities.NON_SUBSCRIBER:
660
+ return user.isSubscriber ? false : true;
661
+ }
662
+ return true;
669
663
  };
670
664
  CouponService.prototype.getCouponCategoriesId = function (coupon) {
671
665
  return __awaiter(this, void 0, void 0, function () {