@infrab4a/connect-angular 3.6.0-beta.3 → 3.6.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,20 +1498,6 @@
1524
1498
  },
1525
1499
  deps: [i1$2.AngularFirestore],
1526
1500
  },
1527
- {
1528
- provide: 'CampaignHashtagRepository',
1529
- useFactory: function (firestore) {
1530
- return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1531
- },
1532
- deps: [i1$2.AngularFirestore],
1533
- },
1534
- {
1535
- provide: 'CampaignDashboardRepository',
1536
- useFactory: function (firestore) {
1537
- return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1538
- },
1539
- deps: [i1$2.AngularFirestore],
1540
- },
1541
1501
  {
1542
1502
  provide: 'EditionRepository',
1543
1503
  useFactory: function (firestore, subscriptionRepository) {
@@ -1594,6 +1554,13 @@
1594
1554
  },
1595
1555
  deps: [i1$2.AngularFirestore],
1596
1556
  },
1557
+ {
1558
+ provide: 'ShopSettingsRepository',
1559
+ useFactory: function (firestore) {
1560
+ return new i1$1.ShopSettingsFirestoreRepository(firestore.firestore);
1561
+ },
1562
+ deps: [i1$2.AngularFirestore],
1563
+ },
1597
1564
  {
1598
1565
  provide: 'SubscriptionPaymentRepository',
1599
1566
  useFactory: function (firestore, subscriptionRepository) {
@@ -1704,20 +1671,6 @@
1704
1671
  },
1705
1672
  deps: [i1$2.AngularFirestore],
1706
1673
  },
1707
- {
1708
- provide: 'CampaignHashtagRepository',
1709
- useFactory: function (firestore) {
1710
- return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1711
- },
1712
- deps: [i1$2.AngularFirestore],
1713
- },
1714
- {
1715
- provide: 'CampaignDashboardRepository',
1716
- useFactory: function (firestore) {
1717
- return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1718
- },
1719
- deps: [i1$2.AngularFirestore],
1720
- },
1721
1674
  {
1722
1675
  provide: 'EditionRepository',
1723
1676
  useFactory: function (firestore, subscriptionRepository) {
@@ -1774,6 +1727,13 @@
1774
1727
  },
1775
1728
  deps: [i1$2.AngularFirestore],
1776
1729
  },
1730
+ {
1731
+ provide: 'ShopSettingsRepository',
1732
+ useFactory: function (firestore) {
1733
+ return new i1$1.ShopSettingsFirestoreRepository(firestore.firestore);
1734
+ },
1735
+ deps: [i1$2.AngularFirestore],
1736
+ },
1777
1737
  {
1778
1738
  provide: 'SubscriptionPaymentRepository',
1779
1739
  useFactory: function (firestore, subscriptionRepository) {
@@ -1860,10 +1820,10 @@
1860
1820
  },
1861
1821
  {
1862
1822
  provide: i1$1.CategoryHasuraGraphQLRepository,
1863
- useFactory: function (options, productRepository) {
1864
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1823
+ useFactory: function (options, productRepository, categoryFilterRepository) {
1824
+ return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1865
1825
  },
1866
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1826
+ deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1867
1827
  },
1868
1828
  {
1869
1829
  provide: 'ProductRepository',
@@ -1887,6 +1847,39 @@
1887
1847
  },
1888
1848
  deps: [HASURA_OPTIONS],
1889
1849
  },
1850
+ {
1851
+ provide: 'CategoryFilterRepository',
1852
+ useExisting: i1$1.CategoryFilterHasuraGraphQLRepository,
1853
+ },
1854
+ {
1855
+ provide: i1$1.CategoryFilterHasuraGraphQLRepository,
1856
+ useFactory: function (options) {
1857
+ return new i1$1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1858
+ },
1859
+ deps: [HASURA_OPTIONS],
1860
+ },
1861
+ {
1862
+ provide: 'FilterOptionRepository',
1863
+ useExisting: i1$1.FilterOptionHasuraGraphQLRepository,
1864
+ },
1865
+ {
1866
+ provide: i1$1.FilterOptionHasuraGraphQLRepository,
1867
+ useFactory: function (options) {
1868
+ return new i1$1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1869
+ },
1870
+ deps: [HASURA_OPTIONS],
1871
+ },
1872
+ {
1873
+ provide: 'FilterRepository',
1874
+ useExisting: i1$1.FilterHasuraGraphQLRepository,
1875
+ },
1876
+ {
1877
+ provide: i1$1.FilterHasuraGraphQLRepository,
1878
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
1879
+ return new i1$1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1880
+ },
1881
+ deps: [HASURA_OPTIONS, i1$1.FilterOptionHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1882
+ },
1890
1883
  ] });
1891
1884
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
1892
1885
  type: i0.NgModule,
@@ -1898,10 +1891,10 @@
1898
1891
  },
1899
1892
  {
1900
1893
  provide: i1$1.CategoryHasuraGraphQLRepository,
1901
- useFactory: function (options, productRepository) {
1902
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1894
+ useFactory: function (options, productRepository, categoryFilterRepository) {
1895
+ return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1903
1896
  },
1904
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1897
+ deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1905
1898
  },
1906
1899
  {
1907
1900
  provide: 'ProductRepository',
@@ -1925,6 +1918,39 @@
1925
1918
  },
1926
1919
  deps: [HASURA_OPTIONS],
1927
1920
  },
1921
+ {
1922
+ provide: 'CategoryFilterRepository',
1923
+ useExisting: i1$1.CategoryFilterHasuraGraphQLRepository,
1924
+ },
1925
+ {
1926
+ provide: i1$1.CategoryFilterHasuraGraphQLRepository,
1927
+ useFactory: function (options) {
1928
+ return new i1$1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1929
+ },
1930
+ deps: [HASURA_OPTIONS],
1931
+ },
1932
+ {
1933
+ provide: 'FilterOptionRepository',
1934
+ useExisting: i1$1.FilterOptionHasuraGraphQLRepository,
1935
+ },
1936
+ {
1937
+ provide: i1$1.FilterOptionHasuraGraphQLRepository,
1938
+ useFactory: function (options) {
1939
+ return new i1$1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1940
+ },
1941
+ deps: [HASURA_OPTIONS],
1942
+ },
1943
+ {
1944
+ provide: 'FilterRepository',
1945
+ useExisting: i1$1.FilterHasuraGraphQLRepository,
1946
+ },
1947
+ {
1948
+ provide: i1$1.FilterHasuraGraphQLRepository,
1949
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
1950
+ return new i1$1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1951
+ },
1952
+ deps: [HASURA_OPTIONS, i1$1.FilterOptionHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
1953
+ },
1928
1954
  ],
1929
1955
  }]
1930
1956
  }] });
@@ -1950,7 +1976,7 @@
1950
1976
  CouponService,
1951
1977
  HomeShopService,
1952
1978
  OrderService,
1953
- ShippingService
1979
+ ShippingService,
1954
1980
  ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1955
1981
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1956
1982
  type: i0.NgModule,
@@ -1964,7 +1990,7 @@
1964
1990
  CouponService,
1965
1991
  HomeShopService,
1966
1992
  OrderService,
1967
- ShippingService
1993
+ ShippingService,
1968
1994
  ],
1969
1995
  }]
1970
1996
  }] });