@infrab4a/connect-angular 3.6.0-beta.2 → 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.
- package/bundles/infrab4a-connect-angular.umd.js +101 -61
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/angular-connect.module.js +5 -5
- package/esm2015/angular-hasura-graphql.module.js +74 -8
- package/esm2015/services/coupon.service.js +26 -41
- package/esm2015/services/shipping.service.js +7 -8
- package/fesm2015/infrab4a-connect-angular.js +105 -55
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +2 -2
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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({
|
|
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)
|
|
@@ -1846,10 +1820,10 @@
|
|
|
1846
1820
|
},
|
|
1847
1821
|
{
|
|
1848
1822
|
provide: i1$1.CategoryHasuraGraphQLRepository,
|
|
1849
|
-
useFactory: function (options, productRepository) {
|
|
1850
|
-
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);
|
|
1851
1825
|
},
|
|
1852
|
-
deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
|
|
1826
|
+
deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
|
|
1853
1827
|
},
|
|
1854
1828
|
{
|
|
1855
1829
|
provide: 'ProductRepository',
|
|
@@ -1873,6 +1847,39 @@
|
|
|
1873
1847
|
},
|
|
1874
1848
|
deps: [HASURA_OPTIONS],
|
|
1875
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
|
+
},
|
|
1876
1883
|
] });
|
|
1877
1884
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
|
|
1878
1885
|
type: i0.NgModule,
|
|
@@ -1884,10 +1891,10 @@
|
|
|
1884
1891
|
},
|
|
1885
1892
|
{
|
|
1886
1893
|
provide: i1$1.CategoryHasuraGraphQLRepository,
|
|
1887
|
-
useFactory: function (options, productRepository) {
|
|
1888
|
-
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);
|
|
1889
1896
|
},
|
|
1890
|
-
deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
|
|
1897
|
+
deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository, i1$1.CategoryFilterHasuraGraphQLRepository],
|
|
1891
1898
|
},
|
|
1892
1899
|
{
|
|
1893
1900
|
provide: 'ProductRepository',
|
|
@@ -1911,6 +1918,39 @@
|
|
|
1911
1918
|
},
|
|
1912
1919
|
deps: [HASURA_OPTIONS],
|
|
1913
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
|
+
},
|
|
1914
1954
|
],
|
|
1915
1955
|
}]
|
|
1916
1956
|
}] });
|
|
@@ -1936,7 +1976,7 @@
|
|
|
1936
1976
|
CouponService,
|
|
1937
1977
|
HomeShopService,
|
|
1938
1978
|
OrderService,
|
|
1939
|
-
ShippingService
|
|
1979
|
+
ShippingService,
|
|
1940
1980
|
], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1941
1981
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
|
|
1942
1982
|
type: i0.NgModule,
|
|
@@ -1950,7 +1990,7 @@
|
|
|
1950
1990
|
CouponService,
|
|
1951
1991
|
HomeShopService,
|
|
1952
1992
|
OrderService,
|
|
1953
|
-
ShippingService
|
|
1993
|
+
ShippingService,
|
|
1954
1994
|
],
|
|
1955
1995
|
}]
|
|
1956
1996
|
}] });
|