@infrab4a/connect-angular 4.3.1 → 4.3.3-beta.3
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/esm2022/angular-connect.module.mjs +1 -1
- package/esm2022/angular-elastic-search.module.mjs +1 -1
- package/esm2022/angular-firebase-auth.module.mjs +1 -1
- package/esm2022/angular-firestore.module.mjs +1 -1
- package/esm2022/angular-hasura-graphql.module.mjs +1 -1
- package/esm2022/consts/category-structure.mjs +1 -1
- package/esm2022/consts/default-shop.const.mjs +1 -1
- package/esm2022/consts/es-config.const.mjs +1 -1
- package/esm2022/consts/firebase-const.mjs +1 -1
- package/esm2022/consts/hasura-options.const.mjs +1 -1
- package/esm2022/consts/index.mjs +1 -1
- package/esm2022/consts/storage-base-url.const.mjs +1 -1
- package/esm2022/helpers/index.mjs +1 -1
- package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +1 -1
- package/esm2022/index.mjs +1 -1
- package/esm2022/services/auth.service.mjs +1 -1
- package/esm2022/services/cart.service.mjs +8 -3
- package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/adapters/index.mjs +1 -1
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/catalog.service.mjs +19 -8
- package/esm2022/services/catalog/category.service.mjs +1 -1
- package/esm2022/services/catalog/enums/index.mjs +1 -1
- package/esm2022/services/catalog/enums/product-sorts.enum.mjs +1 -1
- package/esm2022/services/catalog/index.mjs +1 -1
- package/esm2022/services/catalog/models/category-with-tree.model.mjs +1 -1
- package/esm2022/services/catalog/models/index.mjs +1 -1
- package/esm2022/services/catalog/types/index.mjs +1 -1
- package/esm2022/services/catalog/types/product-sort.type.mjs +1 -1
- package/esm2022/services/catalog/wishlist.service.mjs +2 -2
- package/esm2022/services/checkout-subscription.service.mjs +1 -1
- package/esm2022/services/checkout.service.mjs +1 -1
- package/esm2022/services/coupon.service.mjs +20 -3
- package/esm2022/services/helpers/index.mjs +1 -1
- package/esm2022/services/helpers/util.helper.mjs +1 -1
- package/esm2022/services/home-shop.service.mjs +1 -1
- package/esm2022/services/index.mjs +1 -1
- package/esm2022/services/order.service.mjs +1 -1
- package/esm2022/services/shipping.service.mjs +1 -1
- package/esm2022/services/types/index.mjs +1 -1
- package/esm2022/services/types/required-checkout-data.type.mjs +1 -1
- package/esm2022/services/types/required-checkout-subscription-data.type.mjs +1 -1
- package/esm2022/services/types/shipping-methods.type.mjs +1 -1
- package/esm2022/types/firebase-app-config.type.mjs +1 -1
- package/esm2022/types/index.mjs +1 -1
- package/fesm2022/infrab4a-connect-angular.mjs +43 -10
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +7 -4
- package/services/coupon.service.d.ts +1 -0
|
@@ -1001,6 +1001,11 @@ class CouponService {
|
|
|
1001
1001
|
if (!validUser)
|
|
1002
1002
|
throw 'Usuário não elegível.';
|
|
1003
1003
|
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
1004
|
+
if (couponUseLimits.firstOrder) {
|
|
1005
|
+
const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
|
|
1006
|
+
if (couponUseLimits.firstOrder && ordersUser.length >= 1)
|
|
1007
|
+
throw 'Limite de uso atingido';
|
|
1008
|
+
}
|
|
1004
1009
|
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
1005
1010
|
const orders = await this.getOrdersWithCoupon(coupon);
|
|
1006
1011
|
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
@@ -1074,9 +1079,11 @@ class CouponService {
|
|
|
1074
1079
|
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
1075
1080
|
return true;
|
|
1076
1081
|
let userTypes = [];
|
|
1077
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
1082
|
+
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
1083
|
+
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
1078
1084
|
userTypes.push(Exclusivities.COLLABORATORS);
|
|
1079
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
1085
|
+
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
1086
|
+
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
1080
1087
|
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
1081
1088
|
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
1082
1089
|
user.isSubscriber &&
|
|
@@ -1134,6 +1141,16 @@ class CouponService {
|
|
|
1134
1141
|
})
|
|
1135
1142
|
.then((result) => result.data);
|
|
1136
1143
|
}
|
|
1144
|
+
async getOrdersFromUser(email) {
|
|
1145
|
+
return await this.orderRepository
|
|
1146
|
+
.find({
|
|
1147
|
+
filters: {
|
|
1148
|
+
user: { email: { operator: Where.EQUALS, value: email } },
|
|
1149
|
+
payment: { status: 'paid' },
|
|
1150
|
+
},
|
|
1151
|
+
})
|
|
1152
|
+
.then((result) => result.data);
|
|
1153
|
+
}
|
|
1137
1154
|
countOrdersWithUser(orders, email) {
|
|
1138
1155
|
return orders.filter((o) => o.user.email == email).length;
|
|
1139
1156
|
}
|
|
@@ -1401,14 +1418,17 @@ class CartService {
|
|
|
1401
1418
|
},
|
|
1402
1419
|
})
|
|
1403
1420
|
.then((data) => data.data);
|
|
1421
|
+
console.log('campaigns', campaigns.length);
|
|
1404
1422
|
if (!campaigns.length)
|
|
1405
1423
|
return { ...checkout, lineItems: notGiftItems };
|
|
1406
1424
|
const elegibleCampaigns = [];
|
|
1407
1425
|
for (const campaign of campaigns) {
|
|
1408
1426
|
const today = new Date().getTime();
|
|
1427
|
+
console.log(campaign.name, campaign.startDate.getTime() <= today, campaign.endDate.getTime() >= today);
|
|
1409
1428
|
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1410
1429
|
continue;
|
|
1411
1430
|
if (campaign.activeCategory) {
|
|
1431
|
+
console.log('activeCategory', campaign.activeCategory);
|
|
1412
1432
|
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1413
1433
|
const categoriesCampaingFullTree = [];
|
|
1414
1434
|
for (const id of categoriesCampaing) {
|
|
@@ -1434,6 +1454,7 @@ class CartService {
|
|
|
1434
1454
|
}
|
|
1435
1455
|
}
|
|
1436
1456
|
}
|
|
1457
|
+
console.log('elegibleCampaigns', elegibleCampaigns.length, elegibleCampaigns);
|
|
1437
1458
|
if (!elegibleCampaigns.length)
|
|
1438
1459
|
return { ...checkout, lineItems: notGiftItems };
|
|
1439
1460
|
const campaingnProducts = [];
|
|
@@ -1450,6 +1471,7 @@ class CartService {
|
|
|
1450
1471
|
}
|
|
1451
1472
|
campaingnProducts.push(elegibleProducts);
|
|
1452
1473
|
}
|
|
1474
|
+
console.log('campaingnProducts', campaingnProducts.length, campaingnProducts);
|
|
1453
1475
|
if (!campaingnProducts.length)
|
|
1454
1476
|
return { ...checkout, lineItems: notGiftItems };
|
|
1455
1477
|
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
@@ -1559,11 +1581,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1559
1581
|
}] }] });
|
|
1560
1582
|
|
|
1561
1583
|
class CatalogService {
|
|
1562
|
-
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1584
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex, categoryRepository) {
|
|
1563
1585
|
this.productRepository = productRepository;
|
|
1564
1586
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1565
1587
|
this.shop = shop;
|
|
1566
1588
|
this.productIndex = productIndex;
|
|
1589
|
+
this.categoryRepository = categoryRepository;
|
|
1567
1590
|
this.productsByTerm = {};
|
|
1568
1591
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1569
1592
|
const filters = {};
|
|
@@ -1635,8 +1658,16 @@ class CatalogService {
|
|
|
1635
1658
|
}));
|
|
1636
1659
|
}
|
|
1637
1660
|
async findCatalog(options, limits) {
|
|
1638
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1639
|
-
|
|
1661
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1662
|
+
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1663
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1664
|
+
}
|
|
1665
|
+
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1666
|
+
const productsIds = options.category.products?.length
|
|
1667
|
+
? options.category.products
|
|
1668
|
+
: await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
|
|
1669
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1670
|
+
}
|
|
1640
1671
|
const repoParams = {
|
|
1641
1672
|
filters: {
|
|
1642
1673
|
...(await this.buildMainFilter(options)),
|
|
@@ -1664,8 +1695,7 @@ class CatalogService {
|
|
|
1664
1695
|
.search(term, 999, this.shop)
|
|
1665
1696
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1666
1697
|
}
|
|
1667
|
-
async
|
|
1668
|
-
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1698
|
+
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1669
1699
|
const totalResult = await this.productRepository.findCatalog({
|
|
1670
1700
|
fields: ['id', 'stock'],
|
|
1671
1701
|
filters: {
|
|
@@ -1711,7 +1741,7 @@ class CatalogService {
|
|
|
1711
1741
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1712
1742
|
}));
|
|
1713
1743
|
}
|
|
1714
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1744
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1715
1745
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1716
1746
|
}
|
|
1717
1747
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1725,7 +1755,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1725
1755
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1726
1756
|
type: Inject,
|
|
1727
1757
|
args: [DEFAULT_SHOP]
|
|
1728
|
-
}] }, { type: i1$2.ProductsIndex }
|
|
1758
|
+
}] }, { type: i1$2.ProductsIndex }, { type: undefined, decorators: [{
|
|
1759
|
+
type: Inject,
|
|
1760
|
+
args: ['CategoryRepository']
|
|
1761
|
+
}] }] });
|
|
1729
1762
|
|
|
1730
1763
|
class CategoryService {
|
|
1731
1764
|
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
@@ -1797,7 +1830,7 @@ class WishlistService {
|
|
|
1797
1830
|
this.categoryRepository = categoryRepository;
|
|
1798
1831
|
this.shop = shop;
|
|
1799
1832
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1800
|
-
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1833
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex, categoryRepository);
|
|
1801
1834
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1802
1835
|
}
|
|
1803
1836
|
getCatalogService() {
|