@infrab4a/connect-angular 3.7.0-beta.0 → 3.7.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.
@@ -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, userEmail)];
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.';
@@ -585,7 +583,7 @@
585
583
  lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
586
584
  var _a;
587
585
  if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
588
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
586
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
589
587
  }
590
588
  return true;
591
589
  });
@@ -637,56 +635,31 @@
637
635
  var _a;
638
636
  if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
639
637
  return true;
640
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
638
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
641
639
  });
642
640
  return [2 /*return*/, hasCategories.length ? true : false];
643
641
  }
644
642
  });
645
643
  });
646
644
  };
647
- CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, userEmail) {
648
- return __awaiter(this, void 0, void 0, function () {
649
- var couponRuleSubscription, sub, activeSubs;
650
- return __generator(this, function (_d) {
651
- switch (_d.label) {
652
- case 0:
653
- // Verifica se o email do usuário é coorporativo
654
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
655
- throw new InvalidCouponError('Você não é colaborador.');
656
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
657
- if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
658
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
659
- couponRuleSubscription = coupon.exclusivityType === i1$1.Exclusivities.ACTIVE_SUBSCRIBER ||
660
- coupon.exclusivityType === i1$1.Exclusivities.INACTIVE_SUBSCRIBER ||
661
- coupon.exclusivityType === i1$1.Exclusivities.NON_SUBSCRIBER;
662
- if (!(couponRuleSubscription && userEmail)) return [3 /*break*/, 2];
663
- return [4 /*yield*/, this.subscriptionRepository
664
- .find({
665
- filters: {
666
- user: {
667
- email: { operator: i1$1.Where.EQUALS, value: userEmail },
668
- },
669
- },
670
- })
671
- .then(function (sub) { return sub.data; })];
672
- case 1:
673
- sub = _d.sent();
674
- activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter(function (s) { return s.status === i1$1.Status.ACTIVE; });
675
- switch (coupon.exclusivityType) {
676
- case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
677
- return [2 /*return*/, activeSubs.length > 0];
678
- case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
679
- return [2 /*return*/, activeSubs.length === 0];
680
- case i1$1.Exclusivities.NON_SUBSCRIBER:
681
- return [2 /*return*/, sub.length === 0];
682
- default:
683
- return [2 /*return*/, false];
684
- }
685
- _d.label = 2;
686
- case 2: return [2 /*return*/, true];
687
- }
688
- });
689
- });
645
+ CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, user) {
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;
690
663
  };
691
664
  CouponService.prototype.getCouponCategoriesId = function (coupon) {
692
665
  return __awaiter(this, void 0, void 0, function () {
@@ -699,7 +672,9 @@
699
672
  _d.label = 1;
700
673
  case 1:
701
674
  if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
702
- return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
675
+ return [4 /*yield*/, this.categoryRepository.get({
676
+ id: coupon.productsCategories[index],
677
+ })];
703
678
  case 2:
704
679
  c = _d.sent();
705
680
  couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
@@ -1232,9 +1207,8 @@
1232
1207
  var _this = this;
1233
1208
  return rxjs.combineLatest([
1234
1209
  this.homeService.getHomeData(),
1235
- this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1236
- ])
1237
- .pipe(operators.map(function (_a) {
1210
+ this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams),
1211
+ ]).pipe(operators.map(function (_a) {
1238
1212
  var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
1239
1213
  var shippingMethods = shippingMethodsResponse.result;
1240
1214
  if (!shippingMethods.length)
@@ -1524,6 +1498,20 @@
1524
1498
  },
1525
1499
  deps: [i1$2.AngularFirestore],
1526
1500
  },
1501
+ {
1502
+ provide: 'CampaignHashtagRepository',
1503
+ useFactory: function (firestore) {
1504
+ return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1505
+ },
1506
+ deps: [i1$2.AngularFirestore],
1507
+ },
1508
+ {
1509
+ provide: 'CampaignDashboardRepository',
1510
+ useFactory: function (firestore) {
1511
+ return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1512
+ },
1513
+ deps: [i1$2.AngularFirestore],
1514
+ },
1527
1515
  {
1528
1516
  provide: 'EditionRepository',
1529
1517
  useFactory: function (firestore, subscriptionRepository) {
@@ -1697,6 +1685,20 @@
1697
1685
  },
1698
1686
  deps: [i1$2.AngularFirestore],
1699
1687
  },
1688
+ {
1689
+ provide: 'CampaignHashtagRepository',
1690
+ useFactory: function (firestore) {
1691
+ return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1692
+ },
1693
+ deps: [i1$2.AngularFirestore],
1694
+ },
1695
+ {
1696
+ provide: 'CampaignDashboardRepository',
1697
+ useFactory: function (firestore) {
1698
+ return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1699
+ },
1700
+ deps: [i1$2.AngularFirestore],
1701
+ },
1700
1702
  {
1701
1703
  provide: 'EditionRepository',
1702
1704
  useFactory: function (firestore, subscriptionRepository) {
@@ -1846,10 +1848,10 @@
1846
1848
  },
1847
1849
  {
1848
1850
  provide: i1$1.CategoryHasuraGraphQLRepository,
1849
- useFactory: function (options, productRepository) {
1850
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1851
+ useFactory: function (options, productRepository, categoryFilterRepository) {
1852
+ return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1851
1853
  },
1852
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1854
+ deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1853
1855
  },
1854
1856
  {
1855
1857
  provide: 'ProductRepository',
@@ -1873,6 +1875,39 @@
1873
1875
  },
1874
1876
  deps: [HASURA_OPTIONS],
1875
1877
  },
1878
+ {
1879
+ provide: 'CategoryFilterRepository',
1880
+ useExisting: i1$1.CategoryFilterHasuraGraphQLRepository,
1881
+ },
1882
+ {
1883
+ provide: i1$1.CategoryFilterHasuraGraphQLRepository,
1884
+ useFactory: function (options) {
1885
+ return new i1$1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1886
+ },
1887
+ deps: [HASURA_OPTIONS],
1888
+ },
1889
+ {
1890
+ provide: 'FilterOptionRepository',
1891
+ useExisting: i1$1.FilterOptionHasuraGraphQLRepository,
1892
+ },
1893
+ {
1894
+ provide: i1$1.FilterOptionHasuraGraphQLRepository,
1895
+ useFactory: function (options) {
1896
+ return new i1$1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1897
+ },
1898
+ deps: [HASURA_OPTIONS],
1899
+ },
1900
+ {
1901
+ provide: 'FilterRepository',
1902
+ useExisting: i1$1.FilterHasuraGraphQLRepository,
1903
+ },
1904
+ {
1905
+ provide: i1$1.FilterHasuraGraphQLRepository,
1906
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
1907
+ return new i1$1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1908
+ },
1909
+ deps: [HASURA_OPTIONS, i1$1.FilterOptionHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1910
+ },
1876
1911
  ] });
1877
1912
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
1878
1913
  type: i0.NgModule,
@@ -1884,10 +1919,10 @@
1884
1919
  },
1885
1920
  {
1886
1921
  provide: i1$1.CategoryHasuraGraphQLRepository,
1887
- useFactory: function (options, productRepository) {
1888
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1922
+ useFactory: function (options, productRepository, categoryFilterRepository) {
1923
+ return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1889
1924
  },
1890
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1925
+ deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1891
1926
  },
1892
1927
  {
1893
1928
  provide: 'ProductRepository',
@@ -1911,6 +1946,39 @@
1911
1946
  },
1912
1947
  deps: [HASURA_OPTIONS],
1913
1948
  },
1949
+ {
1950
+ provide: 'CategoryFilterRepository',
1951
+ useExisting: i1$1.CategoryFilterHasuraGraphQLRepository,
1952
+ },
1953
+ {
1954
+ provide: i1$1.CategoryFilterHasuraGraphQLRepository,
1955
+ useFactory: function (options) {
1956
+ return new i1$1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1957
+ },
1958
+ deps: [HASURA_OPTIONS],
1959
+ },
1960
+ {
1961
+ provide: 'FilterOptionRepository',
1962
+ useExisting: i1$1.FilterOptionHasuraGraphQLRepository,
1963
+ },
1964
+ {
1965
+ provide: i1$1.FilterOptionHasuraGraphQLRepository,
1966
+ useFactory: function (options) {
1967
+ return new i1$1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1968
+ },
1969
+ deps: [HASURA_OPTIONS],
1970
+ },
1971
+ {
1972
+ provide: 'FilterRepository',
1973
+ useExisting: i1$1.FilterHasuraGraphQLRepository,
1974
+ },
1975
+ {
1976
+ provide: i1$1.FilterHasuraGraphQLRepository,
1977
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
1978
+ return new i1$1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1979
+ },
1980
+ deps: [HASURA_OPTIONS, i1$1.FilterOptionHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1981
+ },
1914
1982
  ],
1915
1983
  }]
1916
1984
  }] });
@@ -1936,7 +2004,7 @@
1936
2004
  CouponService,
1937
2005
  HomeShopService,
1938
2006
  OrderService,
1939
- ShippingService
2007
+ ShippingService,
1940
2008
  ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1941
2009
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1942
2010
  type: i0.NgModule,
@@ -1950,7 +2018,7 @@
1950
2018
  CouponService,
1951
2019
  HomeShopService,
1952
2020
  OrderService,
1953
- ShippingService
2021
+ ShippingService,
1954
2022
  ],
1955
2023
  }]
1956
2024
  }] });