@infrab4a/connect-angular 4.14.4 → 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 -1
- package/esm2020/services/catalog/catalog.service.mjs +18 -72
- package/esm2020/services/coupon.service.mjs +9 -5
- package/fesm2015/infrab4a-connect-angular.mjs +56 -71
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +43 -75
- 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,11 +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) {
|
|
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();
|
|
1523
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* () {
|
|
1524
|
-
var
|
|
1547
|
+
var _c, _d;
|
|
1525
1548
|
return yield this.checkoutService
|
|
1526
|
-
.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((
|
|
1527
|
-
? 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; })))
|
|
1528
1551
|
: [] })))
|
|
1529
1552
|
.toPromise();
|
|
1530
1553
|
})), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => (this.user = user)), tap((cart) => this.cartSubject.next(cart)));
|
|
@@ -1765,7 +1788,6 @@ class CatalogService {
|
|
|
1765
1788
|
this.shop = shop;
|
|
1766
1789
|
this.productSearch = productSearch;
|
|
1767
1790
|
this.productsByTerm = {};
|
|
1768
|
-
this.brandsList = {};
|
|
1769
1791
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1770
1792
|
const filters = {};
|
|
1771
1793
|
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
@@ -1818,15 +1840,6 @@ class CatalogService {
|
|
|
1818
1840
|
this.hasProfile = (options) => 'profile' in options;
|
|
1819
1841
|
this.hasTerm = (options) => 'term' in options;
|
|
1820
1842
|
this.hasCategory = (options) => 'category' in options;
|
|
1821
|
-
this.buildIndexBrands = (options) => {
|
|
1822
|
-
if (this.hasCategory(options))
|
|
1823
|
-
return `category-${options.category.id}`;
|
|
1824
|
-
if (this.hasTerm(options))
|
|
1825
|
-
return `term-${options.term}`;
|
|
1826
|
-
if (this.hasProfile(options))
|
|
1827
|
-
return `profile-${options.profile.join(',')}`;
|
|
1828
|
-
return '';
|
|
1829
|
-
};
|
|
1830
1843
|
}
|
|
1831
1844
|
fetchProducts(options) {
|
|
1832
1845
|
var _a, _b, _c;
|
|
@@ -1838,22 +1851,21 @@ class CatalogService {
|
|
|
1838
1851
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1839
1852
|
if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
|
|
1840
1853
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1841
|
-
return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) =>
|
|
1842
|
-
var
|
|
1843
|
-
|
|
1844
|
-
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 ({
|
|
1845
1857
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1846
1858
|
pages: Math.ceil(total / limits.limit),
|
|
1847
1859
|
prices: {
|
|
1848
|
-
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)) },
|
|
1849
1861
|
subscriberPrice: {
|
|
1850
|
-
min: +((
|
|
1851
|
-
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)),
|
|
1852
1864
|
},
|
|
1853
1865
|
},
|
|
1854
|
-
brands:
|
|
1855
|
-
};
|
|
1856
|
-
})
|
|
1866
|
+
brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
|
|
1867
|
+
});
|
|
1868
|
+
});
|
|
1857
1869
|
});
|
|
1858
1870
|
}
|
|
1859
1871
|
addCustomerToStockNotification(shop, productId, name, email) {
|
|
@@ -1862,7 +1874,6 @@ class CatalogService {
|
|
|
1862
1874
|
});
|
|
1863
1875
|
}
|
|
1864
1876
|
findCatalog(options, limits) {
|
|
1865
|
-
var _a;
|
|
1866
1877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1867
1878
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1868
1879
|
const productsIds = yield this.findCatalogIdsBySearch(options.term);
|
|
@@ -1878,9 +1889,7 @@ class CatalogService {
|
|
|
1878
1889
|
.then((products) => products.data.map((product) => product.id));
|
|
1879
1890
|
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1880
1891
|
}
|
|
1881
|
-
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.
|
|
1882
|
-
? { distinct: ['brand'] }
|
|
1883
|
-
: {})) });
|
|
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'] } : {})) });
|
|
1884
1893
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1885
1894
|
return this.productRepository.findCatalog(repoParams);
|
|
1886
1895
|
return this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
@@ -1899,14 +1908,16 @@ class CatalogService {
|
|
|
1899
1908
|
});
|
|
1900
1909
|
}
|
|
1901
1910
|
findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1902
|
-
var _a, _b;
|
|
1903
1911
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1904
|
-
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1905
1912
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1906
1913
|
const totalResult = yield this.productRepository.findCatalog({
|
|
1907
1914
|
filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds } }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
|
|
1908
1915
|
orderBy: this.buildSortQuery('best-sellers'),
|
|
1909
|
-
options:
|
|
1916
|
+
options: {
|
|
1917
|
+
minimal: ['price'],
|
|
1918
|
+
maximum: ['price'],
|
|
1919
|
+
distinct: ['brand'],
|
|
1920
|
+
},
|
|
1910
1921
|
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1911
1922
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1912
1923
|
const firstProducts = totalResult.data
|
|
@@ -1917,27 +1928,29 @@ class CatalogService {
|
|
|
1917
1928
|
.concat(mostRelevantWithouyStock);
|
|
1918
1929
|
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1919
1930
|
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1920
|
-
yield this.setBrandsList(options, (_b = totalResult.distinct) === null || _b === void 0 ? void 0 : _b.brand);
|
|
1921
1931
|
return {
|
|
1922
1932
|
data: resultFinal,
|
|
1923
1933
|
count: totalResult.count,
|
|
1924
1934
|
maximum: totalResult.maximum,
|
|
1925
1935
|
minimal: totalResult.minimal,
|
|
1926
|
-
distinct:
|
|
1936
|
+
distinct: totalResult.distinct,
|
|
1927
1937
|
};
|
|
1928
1938
|
});
|
|
1929
1939
|
}
|
|
1930
1940
|
findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1931
|
-
var _a, _b
|
|
1941
|
+
var _a, _b;
|
|
1932
1942
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1933
|
-
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1934
1943
|
const totalResult = yield this.productRepository.findCatalog({
|
|
1935
1944
|
fields: ['id', 'stock', 'gender'],
|
|
1936
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) || {})),
|
|
1937
|
-
options:
|
|
1946
|
+
options: {
|
|
1947
|
+
minimal: ['price'],
|
|
1948
|
+
maximum: ['price'],
|
|
1949
|
+
distinct: ['brand'],
|
|
1950
|
+
},
|
|
1938
1951
|
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1939
|
-
const defaultGender = ((
|
|
1940
|
-
? (
|
|
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)
|
|
1941
1954
|
: this.shop === Shops.GLAMSHOP
|
|
1942
1955
|
? 'female'
|
|
1943
1956
|
: 'male';
|
|
@@ -1956,13 +1969,12 @@ class CatalogService {
|
|
|
1956
1969
|
id: { operator: Where.IN, value: orderedId },
|
|
1957
1970
|
},
|
|
1958
1971
|
});
|
|
1959
|
-
yield this.setBrandsList(options, (_d = totalResult.distinct) === null || _d === void 0 ? void 0 : _d.brand);
|
|
1960
1972
|
return {
|
|
1961
1973
|
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1962
1974
|
count: totalResult.count,
|
|
1963
1975
|
maximum: totalResult.maximum,
|
|
1964
1976
|
minimal: totalResult.minimal,
|
|
1965
|
-
distinct:
|
|
1977
|
+
distinct: totalResult.distinct,
|
|
1966
1978
|
};
|
|
1967
1979
|
});
|
|
1968
1980
|
}
|
|
@@ -1975,33 +1987,6 @@ class CatalogService {
|
|
|
1975
1987
|
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1976
1988
|
});
|
|
1977
1989
|
}
|
|
1978
|
-
fetchBrandsOnly(options, productIds = []) {
|
|
1979
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1980
|
-
return this.productRepository
|
|
1981
|
-
.findCatalog({
|
|
1982
|
-
fields: ['id'],
|
|
1983
|
-
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) || {})),
|
|
1984
|
-
options: {
|
|
1985
|
-
distinct: ['brand'],
|
|
1986
|
-
},
|
|
1987
|
-
}, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1988
|
-
.then((result) => {
|
|
1989
|
-
return result.distinct.brand;
|
|
1990
|
-
});
|
|
1991
|
-
});
|
|
1992
|
-
}
|
|
1993
|
-
setBrandsList(options, brands) {
|
|
1994
|
-
var _a, _b;
|
|
1995
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1996
|
-
const filterBrands = (_a = options.filters) === null || _a === void 0 ? void 0 : _a.brands;
|
|
1997
|
-
if (isEmpty(brands))
|
|
1998
|
-
(_b = options.filters) === null || _b === void 0 ? true : delete _b.brands;
|
|
1999
|
-
this.brandsList[this.buildIndexBrands(options)] =
|
|
2000
|
-
this.brandsList[this.buildIndexBrands(options)] || brands || (yield this.fetchBrandsOnly(options));
|
|
2001
|
-
this.brandsList[this.buildIndexBrands(options)] = this.brandsList[this.buildIndexBrands(options)].filter(Boolean);
|
|
2002
|
-
options.filters = Object.assign(Object.assign({}, options.filters), { brands: filterBrands });
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
1990
|
}
|
|
2006
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 });
|
|
2007
1992
|
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|