@infrab4a/connect-angular 4.14.4-beta.1 → 4.15.0-beta.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/esm2020/angular-firestore.module.mjs +16 -2
- package/esm2020/services/cart.service.mjs +5 -4
- package/esm2020/services/catalog/catalog.service.mjs +18 -72
- package/esm2020/services/coupon.service.mjs +9 -5
- package/fesm2015/infrab4a-connect-angular.mjs +56 -74
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +43 -78
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +0 -4
|
@@ -5,7 +5,7 @@ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular
|
|
|
5
5
|
import * as i2 from '@angular/fire/storage';
|
|
6
6
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
7
7
|
import * as i1$2 from '@infrab4a/connect';
|
|
8
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError,
|
|
8
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
9
9
|
import * as i1 from '@angular/fire/auth';
|
|
10
10
|
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
11
11
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
@@ -421,6 +421,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
421
421
|
},
|
|
422
422
|
deps: ['FirestoreOptions'],
|
|
423
423
|
},
|
|
424
|
+
{
|
|
425
|
+
provide: 'SequenceRepository',
|
|
426
|
+
useFactory: (options) => {
|
|
427
|
+
return new SequenceFirestoreRepository(options);
|
|
428
|
+
},
|
|
429
|
+
deps: ['FirestoreOptions'],
|
|
430
|
+
},
|
|
424
431
|
], imports: [AngularElasticSeachModule,
|
|
425
432
|
provideFirestore((injector) => {
|
|
426
433
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -680,6 +687,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
680
687
|
},
|
|
681
688
|
deps: ['FirestoreOptions'],
|
|
682
689
|
},
|
|
690
|
+
{
|
|
691
|
+
provide: 'SequenceRepository',
|
|
692
|
+
useFactory: (options) => {
|
|
693
|
+
return new SequenceFirestoreRepository(options);
|
|
694
|
+
},
|
|
695
|
+
deps: ['FirestoreOptions'],
|
|
696
|
+
},
|
|
683
697
|
],
|
|
684
698
|
}]
|
|
685
699
|
}] });
|
|
@@ -1148,16 +1162,16 @@ class CouponService {
|
|
|
1148
1162
|
let discount = 0;
|
|
1149
1163
|
if (type == CouponTypes.SHIPPING) {
|
|
1150
1164
|
const subTotal = checkout.shipping.ShippingPrice;
|
|
1151
|
-
const discount =
|
|
1165
|
+
const discount = subTotal * ((value > 100 ? 100 : value) / 100);
|
|
1152
1166
|
return { discount, lineItems: checkout.lineItems };
|
|
1153
1167
|
}
|
|
1154
|
-
|
|
1168
|
+
const lineItensElegibleForDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1155
1169
|
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1156
1170
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1157
1171
|
discount = value > subTotal ? subTotal : value;
|
|
1158
1172
|
}
|
|
1159
1173
|
else {
|
|
1160
|
-
discount =
|
|
1174
|
+
discount = subTotal * ((value > 100 ? 100 : value) / 100);
|
|
1161
1175
|
}
|
|
1162
1176
|
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1163
1177
|
return { discount, lineItems };
|
|
@@ -1167,7 +1181,7 @@ class CouponService {
|
|
|
1167
1181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1168
1182
|
if (!coupon.minSubTotalValue)
|
|
1169
1183
|
return true;
|
|
1170
|
-
|
|
1184
|
+
const lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1171
1185
|
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1172
1186
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1173
1187
|
return true;
|
|
@@ -1306,6 +1320,8 @@ class CouponService {
|
|
|
1306
1320
|
if (type === CouponTypes.ABSOLUTE) {
|
|
1307
1321
|
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1308
1322
|
lineItemsDiscount = lineItems.map((item) => {
|
|
1323
|
+
if (item.isGift)
|
|
1324
|
+
return item;
|
|
1309
1325
|
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1310
1326
|
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1311
1327
|
return Object.assign(Object.assign({}, item), { discount: Number(discountItem.toFixed(2)) });
|
|
@@ -1313,6 +1329,8 @@ class CouponService {
|
|
|
1313
1329
|
}
|
|
1314
1330
|
else {
|
|
1315
1331
|
lineItemsDiscount = lineItems.map((item) => {
|
|
1332
|
+
if (item.isGift)
|
|
1333
|
+
return item;
|
|
1316
1334
|
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1317
1335
|
return Object.assign(Object.assign({}, item), { discount: Number(discountItem.toFixed(2)) });
|
|
1318
1336
|
});
|
|
@@ -1520,14 +1538,16 @@ class CartService {
|
|
|
1520
1538
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1521
1539
|
}
|
|
1522
1540
|
updateUserCart(user) {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1541
|
+
var _a, _b;
|
|
1542
|
+
const isSameUserId = !(user === null || user === void 0 ? void 0 : user.id) || ((_a = this.user) === null || _a === void 0 ? void 0 : _a.id) === (user === null || user === void 0 ? void 0 : user.id);
|
|
1543
|
+
const isSameUser = isSameUserId && !!((_b = this.user) === null || _b === void 0 ? void 0 : _b.isSubscriber) === !!(user === null || user === void 0 ? void 0 : user.isSubscriber);
|
|
1544
|
+
if (isSameUser)
|
|
1545
|
+
return this.getCart();
|
|
1526
1546
|
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
1527
|
-
var
|
|
1547
|
+
var _c, _d;
|
|
1528
1548
|
return yield this.checkoutService
|
|
1529
|
-
.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((
|
|
1530
|
-
? yield Promise.all((
|
|
1549
|
+
.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_c = checkout.lineItems) === null || _c === void 0 ? void 0 : _c.length)
|
|
1550
|
+
? yield Promise.all((_d = checkout.lineItems) === null || _d === void 0 ? void 0 : _d.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; })))
|
|
1531
1551
|
: [] })))
|
|
1532
1552
|
.toPromise();
|
|
1533
1553
|
})), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => (this.user = user)), tap((cart) => this.cartSubject.next(cart)));
|
|
@@ -1768,7 +1788,6 @@ class CatalogService {
|
|
|
1768
1788
|
this.shop = shop;
|
|
1769
1789
|
this.productSearch = productSearch;
|
|
1770
1790
|
this.productsByTerm = {};
|
|
1771
|
-
this.brandsList = {};
|
|
1772
1791
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1773
1792
|
const filters = {};
|
|
1774
1793
|
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
@@ -1821,15 +1840,6 @@ class CatalogService {
|
|
|
1821
1840
|
this.hasProfile = (options) => 'profile' in options;
|
|
1822
1841
|
this.hasTerm = (options) => 'term' in options;
|
|
1823
1842
|
this.hasCategory = (options) => 'category' in options;
|
|
1824
|
-
this.buildIndexBrands = (options) => {
|
|
1825
|
-
if (this.hasCategory(options))
|
|
1826
|
-
return `category-${options.category.id}`;
|
|
1827
|
-
if (this.hasTerm(options))
|
|
1828
|
-
return `term-${options.term}`;
|
|
1829
|
-
if (this.hasProfile(options))
|
|
1830
|
-
return `profile-${options.profile.join(',')}`;
|
|
1831
|
-
return '';
|
|
1832
|
-
};
|
|
1833
1843
|
}
|
|
1834
1844
|
fetchProducts(options) {
|
|
1835
1845
|
var _a, _b, _c;
|
|
@@ -1841,22 +1851,21 @@ class CatalogService {
|
|
|
1841
1851
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1842
1852
|
if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
|
|
1843
1853
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1844
|
-
return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) =>
|
|
1845
|
-
var
|
|
1846
|
-
|
|
1847
|
-
return {
|
|
1854
|
+
return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => {
|
|
1855
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1856
|
+
return ({
|
|
1848
1857
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1849
1858
|
pages: Math.ceil(total / limits.limit),
|
|
1850
1859
|
prices: {
|
|
1851
|
-
price: { min: +((
|
|
1860
|
+
price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
|
|
1852
1861
|
subscriberPrice: {
|
|
1853
|
-
min: +((
|
|
1854
|
-
max: +((
|
|
1862
|
+
min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
|
|
1863
|
+
max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
|
|
1855
1864
|
},
|
|
1856
1865
|
},
|
|
1857
|
-
brands:
|
|
1858
|
-
};
|
|
1859
|
-
})
|
|
1866
|
+
brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
|
|
1867
|
+
});
|
|
1868
|
+
});
|
|
1860
1869
|
});
|
|
1861
1870
|
}
|
|
1862
1871
|
addCustomerToStockNotification(shop, productId, name, email) {
|
|
@@ -1865,7 +1874,6 @@ class CatalogService {
|
|
|
1865
1874
|
});
|
|
1866
1875
|
}
|
|
1867
1876
|
findCatalog(options, limits) {
|
|
1868
|
-
var _a;
|
|
1869
1877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1870
1878
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1871
1879
|
const productsIds = yield this.findCatalogIdsBySearch(options.term);
|
|
@@ -1881,9 +1889,7 @@ class CatalogService {
|
|
|
1881
1889
|
.then((products) => products.data.map((product) => product.id));
|
|
1882
1890
|
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1883
1891
|
}
|
|
1884
|
-
const repoParams = Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.buildMainFilter(options))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.
|
|
1885
|
-
? { distinct: ['brand'] }
|
|
1886
|
-
: {})) });
|
|
1892
|
+
const repoParams = Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.buildMainFilter(options))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) });
|
|
1887
1893
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1888
1894
|
return this.productRepository.findCatalog(repoParams);
|
|
1889
1895
|
return this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
@@ -1902,14 +1908,16 @@ class CatalogService {
|
|
|
1902
1908
|
});
|
|
1903
1909
|
}
|
|
1904
1910
|
findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1905
|
-
var _a, _b;
|
|
1906
1911
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1907
|
-
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1908
1912
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1909
1913
|
const totalResult = yield this.productRepository.findCatalog({
|
|
1910
1914
|
filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds } }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
|
|
1911
1915
|
orderBy: this.buildSortQuery('best-sellers'),
|
|
1912
|
-
options:
|
|
1916
|
+
options: {
|
|
1917
|
+
minimal: ['price'],
|
|
1918
|
+
maximum: ['price'],
|
|
1919
|
+
distinct: ['brand'],
|
|
1920
|
+
},
|
|
1913
1921
|
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1914
1922
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1915
1923
|
const firstProducts = totalResult.data
|
|
@@ -1920,27 +1928,29 @@ class CatalogService {
|
|
|
1920
1928
|
.concat(mostRelevantWithouyStock);
|
|
1921
1929
|
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1922
1930
|
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1923
|
-
yield this.setBrandsList(options, (_b = totalResult.distinct) === null || _b === void 0 ? void 0 : _b.brand);
|
|
1924
1931
|
return {
|
|
1925
1932
|
data: resultFinal,
|
|
1926
1933
|
count: totalResult.count,
|
|
1927
1934
|
maximum: totalResult.maximum,
|
|
1928
1935
|
minimal: totalResult.minimal,
|
|
1929
|
-
distinct:
|
|
1936
|
+
distinct: totalResult.distinct,
|
|
1930
1937
|
};
|
|
1931
1938
|
});
|
|
1932
1939
|
}
|
|
1933
1940
|
findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1934
|
-
var _a, _b
|
|
1941
|
+
var _a, _b;
|
|
1935
1942
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1936
|
-
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1937
1943
|
const totalResult = yield this.productRepository.findCatalog({
|
|
1938
1944
|
fields: ['id', 'stock', 'gender'],
|
|
1939
1945
|
filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
|
|
1940
|
-
options:
|
|
1946
|
+
options: {
|
|
1947
|
+
minimal: ['price'],
|
|
1948
|
+
maximum: ['price'],
|
|
1949
|
+
distinct: ['brand'],
|
|
1950
|
+
},
|
|
1941
1951
|
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1942
|
-
const defaultGender = ((
|
|
1943
|
-
? (
|
|
1952
|
+
const defaultGender = ((_a = options === null || options === void 0 ? void 0 : options.filters) === null || _a === void 0 ? void 0 : _a.gender)
|
|
1953
|
+
? (_b = options === null || options === void 0 ? void 0 : options.filters) === null || _b === void 0 ? void 0 : _b.gender.at(0)
|
|
1944
1954
|
: this.shop === Shops.GLAMSHOP
|
|
1945
1955
|
? 'female'
|
|
1946
1956
|
: 'male';
|
|
@@ -1959,13 +1969,12 @@ class CatalogService {
|
|
|
1959
1969
|
id: { operator: Where.IN, value: orderedId },
|
|
1960
1970
|
},
|
|
1961
1971
|
});
|
|
1962
|
-
yield this.setBrandsList(options, (_d = totalResult.distinct) === null || _d === void 0 ? void 0 : _d.brand);
|
|
1963
1972
|
return {
|
|
1964
1973
|
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1965
1974
|
count: totalResult.count,
|
|
1966
1975
|
maximum: totalResult.maximum,
|
|
1967
1976
|
minimal: totalResult.minimal,
|
|
1968
|
-
distinct:
|
|
1977
|
+
distinct: totalResult.distinct,
|
|
1969
1978
|
};
|
|
1970
1979
|
});
|
|
1971
1980
|
}
|
|
@@ -1978,33 +1987,6 @@ class CatalogService {
|
|
|
1978
1987
|
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1979
1988
|
});
|
|
1980
1989
|
}
|
|
1981
|
-
fetchBrandsOnly(options, productIds = []) {
|
|
1982
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1983
|
-
return this.productRepository
|
|
1984
|
-
.findCatalog({
|
|
1985
|
-
fields: ['id'],
|
|
1986
|
-
filters: Object.assign(Object.assign(Object.assign({}, (!isEmpty(productIds) ? { id: { operator: Where.IN, value: productIds } } : {})), { published: { operator: Where.EQUALS, value: true } }), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
|
|
1987
|
-
options: {
|
|
1988
|
-
distinct: ['brand'],
|
|
1989
|
-
},
|
|
1990
|
-
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1991
|
-
.then((result) => {
|
|
1992
|
-
return result.distinct.brand;
|
|
1993
|
-
});
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
setBrandsList(options, brands) {
|
|
1997
|
-
var _a, _b;
|
|
1998
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1999
|
-
const filterBrands = (_a = options.filters) === null || _a === void 0 ? void 0 : _a.brands;
|
|
2000
|
-
if (isEmpty(brands))
|
|
2001
|
-
(_b = options.filters) === null || _b === void 0 ? true : delete _b.brands;
|
|
2002
|
-
this.brandsList[this.buildIndexBrands(options)] =
|
|
2003
|
-
this.brandsList[this.buildIndexBrands(options)] || brands || (yield this.fetchBrandsOnly(options));
|
|
2004
|
-
this.brandsList[this.buildIndexBrands(options)] = this.brandsList[this.buildIndexBrands(options)].filter(Boolean);
|
|
2005
|
-
options.filters = Object.assign(Object.assign({}, options.filters), { brands: filterBrands });
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
1990
|
}
|
|
2009
1991
|
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2010
1992
|
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|