@infrab4a/connect-angular 5.0.0-beta.67 → 5.0.0-beta.69
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 +30 -8
- package/esm2022/angular-vertex-search.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/persistence.const.mjs +1 -1
- package/esm2022/consts/storage-base-url.const.mjs +1 -1
- package/esm2022/consts/vertex-config.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/persistence/cookie-data-persistence.mjs +1 -1
- package/esm2022/persistence/data-persistence.mjs +1 -1
- package/esm2022/persistence/index.mjs +1 -1
- package/esm2022/services/auth.service.mjs +1 -1
- package/esm2022/services/cart.service.mjs +1 -5
- 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 +72 -18
- 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 +3 -5
- package/esm2022/services/checkout-subscription.service.mjs +1 -1
- package/esm2022/services/checkout.service.mjs +1 -1
- package/esm2022/services/coupon.service.mjs +17 -11
- 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 +117 -41
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +4 -0
|
@@ -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, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } 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, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, isEmpty, 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';
|
|
@@ -813,12 +813,23 @@ class AngularHasuraGraphQLModule {
|
|
|
813
813
|
provide: 'CategoryCollectionChildrenRepository',
|
|
814
814
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
815
815
|
},
|
|
816
|
+
{
|
|
817
|
+
provide: CategoryProductHasuraGraphQLRepository,
|
|
818
|
+
useFactory: (options) => {
|
|
819
|
+
return new CategoryProductHasuraGraphQLRepository(options);
|
|
820
|
+
},
|
|
821
|
+
deps: ['HasuraConfig'],
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
provide: 'CategoryProductRepository',
|
|
825
|
+
useExisting: CategoryProductHasuraGraphQLRepository,
|
|
826
|
+
},
|
|
816
827
|
{
|
|
817
828
|
provide: WishlistHasuraGraphQLRepository,
|
|
818
|
-
useFactory: (options,
|
|
819
|
-
return new WishlistHasuraGraphQLRepository(options,
|
|
829
|
+
useFactory: (options, categoryProductRepository) => {
|
|
830
|
+
return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
|
|
820
831
|
},
|
|
821
|
-
deps: ['HasuraConfig',
|
|
832
|
+
deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
|
|
822
833
|
},
|
|
823
834
|
{
|
|
824
835
|
provide: 'WishlistRepository',
|
|
@@ -950,12 +961,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
950
961
|
provide: 'CategoryCollectionChildrenRepository',
|
|
951
962
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
952
963
|
},
|
|
964
|
+
{
|
|
965
|
+
provide: CategoryProductHasuraGraphQLRepository,
|
|
966
|
+
useFactory: (options) => {
|
|
967
|
+
return new CategoryProductHasuraGraphQLRepository(options);
|
|
968
|
+
},
|
|
969
|
+
deps: ['HasuraConfig'],
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
provide: 'CategoryProductRepository',
|
|
973
|
+
useExisting: CategoryProductHasuraGraphQLRepository,
|
|
974
|
+
},
|
|
953
975
|
{
|
|
954
976
|
provide: WishlistHasuraGraphQLRepository,
|
|
955
|
-
useFactory: (options,
|
|
956
|
-
return new WishlistHasuraGraphQLRepository(options,
|
|
977
|
+
useFactory: (options, categoryProductRepository) => {
|
|
978
|
+
return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
|
|
957
979
|
},
|
|
958
|
-
deps: ['HasuraConfig',
|
|
980
|
+
deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
|
|
959
981
|
},
|
|
960
982
|
{
|
|
961
983
|
provide: 'WishlistRepository',
|
|
@@ -1137,7 +1159,7 @@ class CouponService {
|
|
|
1137
1159
|
let discount = 0;
|
|
1138
1160
|
if (type == CouponTypes.SHIPPING) {
|
|
1139
1161
|
const subTotal = checkout.shipping.ShippingPrice;
|
|
1140
|
-
const discount = subTotal * ((value > 100 ? 100 : value) / 100);
|
|
1162
|
+
const discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
|
|
1141
1163
|
return { discount, lineItems: checkout.lineItems };
|
|
1142
1164
|
}
|
|
1143
1165
|
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
@@ -1146,7 +1168,7 @@ class CouponService {
|
|
|
1146
1168
|
discount = value > subTotal ? subTotal : value;
|
|
1147
1169
|
}
|
|
1148
1170
|
else {
|
|
1149
|
-
discount = subTotal * ((value > 100 ? 100 : value) / 100);
|
|
1171
|
+
discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
|
|
1150
1172
|
}
|
|
1151
1173
|
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1152
1174
|
return { discount, lineItems };
|
|
@@ -1165,10 +1187,12 @@ class CouponService {
|
|
|
1165
1187
|
return true;
|
|
1166
1188
|
}
|
|
1167
1189
|
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
1168
|
-
const hasCategories = checkout.lineItems?.filter((
|
|
1169
|
-
if (
|
|
1190
|
+
const hasCategories = checkout.lineItems?.filter((item) => {
|
|
1191
|
+
if (item.isGift)
|
|
1192
|
+
return false;
|
|
1193
|
+
if (!item.categories || !item.categories?.length)
|
|
1170
1194
|
return true;
|
|
1171
|
-
return
|
|
1195
|
+
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1172
1196
|
});
|
|
1173
1197
|
return hasCategories.length ? true : false;
|
|
1174
1198
|
}
|
|
@@ -1211,20 +1235,24 @@ class CouponService {
|
|
|
1211
1235
|
let lineItensDiscount = [];
|
|
1212
1236
|
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
1213
1237
|
if (productsCategories && productsCategories.length) {
|
|
1214
|
-
lineItensDiscount = checkout.lineItems?.filter((
|
|
1215
|
-
if (
|
|
1216
|
-
return
|
|
1238
|
+
lineItensDiscount = checkout.lineItems?.filter((item) => {
|
|
1239
|
+
if (item.isGift)
|
|
1240
|
+
return false;
|
|
1241
|
+
if (item.categories?.length) {
|
|
1242
|
+
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1217
1243
|
}
|
|
1218
1244
|
return true;
|
|
1219
1245
|
});
|
|
1220
1246
|
}
|
|
1221
1247
|
else {
|
|
1222
|
-
lineItensDiscount = checkout.lineItems;
|
|
1248
|
+
lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
|
|
1223
1249
|
}
|
|
1224
1250
|
return lineItensDiscount;
|
|
1225
1251
|
}
|
|
1226
1252
|
calcCheckoutSubtotal(lineItens, user) {
|
|
1227
|
-
return (lineItens
|
|
1253
|
+
return (lineItens
|
|
1254
|
+
?.filter((item) => !item.isGift)
|
|
1255
|
+
.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1228
1256
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1229
1257
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
1230
1258
|
}
|
|
@@ -1489,10 +1517,6 @@ class CartService {
|
|
|
1489
1517
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1490
1518
|
}
|
|
1491
1519
|
updateUserCart(user) {
|
|
1492
|
-
const isSameUserId = !user?.id || this.user?.id === user?.id;
|
|
1493
|
-
const isSameUser = isSameUserId && !!this.user?.isSubscriber === !!user?.isSubscriber;
|
|
1494
|
-
if (isSameUser)
|
|
1495
|
-
return this.getCart();
|
|
1496
1520
|
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1497
1521
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1498
1522
|
...checkout.toPlain(),
|
|
@@ -1726,6 +1750,7 @@ class CatalogService {
|
|
|
1726
1750
|
this.shop = shop;
|
|
1727
1751
|
this.productSearch = productSearch;
|
|
1728
1752
|
this.productsByTerm = {};
|
|
1753
|
+
this.brandsList = {};
|
|
1729
1754
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1730
1755
|
const filters = {};
|
|
1731
1756
|
if (clubDiscount?.length)
|
|
@@ -1778,6 +1803,15 @@ class CatalogService {
|
|
|
1778
1803
|
this.hasProfile = (options) => 'profile' in options;
|
|
1779
1804
|
this.hasTerm = (options) => 'term' in options;
|
|
1780
1805
|
this.hasCategory = (options) => 'category' in options;
|
|
1806
|
+
this.buildIndexBrands = (options) => {
|
|
1807
|
+
if (this.hasCategory(options))
|
|
1808
|
+
return `category-${options.category.id}`;
|
|
1809
|
+
if (this.hasTerm(options))
|
|
1810
|
+
return `term-${options.term}`;
|
|
1811
|
+
if (this.hasProfile(options))
|
|
1812
|
+
return `profile-${options.profile.join(',')}`;
|
|
1813
|
+
return '';
|
|
1814
|
+
};
|
|
1781
1815
|
}
|
|
1782
1816
|
async fetchProducts(options) {
|
|
1783
1817
|
const limits = this.buildLimitQuery(options);
|
|
@@ -1787,18 +1821,21 @@ class CatalogService {
|
|
|
1787
1821
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1788
1822
|
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1789
1823
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1790
|
-
return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) =>
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
min: +minimal?.price?.
|
|
1797
|
-
|
|
1824
|
+
return await this.findCatalog(options, limits).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1825
|
+
await this.setBrandsList(options, distinct?.brand);
|
|
1826
|
+
return {
|
|
1827
|
+
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1828
|
+
pages: Math.ceil(total / limits.limit),
|
|
1829
|
+
prices: {
|
|
1830
|
+
price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
|
|
1831
|
+
subscriberPrice: {
|
|
1832
|
+
min: +minimal?.price?.subscriberPrice?.toFixed(2),
|
|
1833
|
+
max: +maximum?.price?.subscriberPrice?.toFixed(2),
|
|
1834
|
+
},
|
|
1798
1835
|
},
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
})
|
|
1836
|
+
brands: this.brandsList[this.buildIndexBrands(options)],
|
|
1837
|
+
};
|
|
1838
|
+
});
|
|
1802
1839
|
}
|
|
1803
1840
|
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1804
1841
|
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
@@ -1831,7 +1868,9 @@ class CatalogService {
|
|
|
1831
1868
|
options: {
|
|
1832
1869
|
minimal: ['price'],
|
|
1833
1870
|
maximum: ['price'],
|
|
1834
|
-
...(!this.
|
|
1871
|
+
...(!this.brandsList[this.buildIndexBrands(options)] && isEmpty(options.filters?.brands)
|
|
1872
|
+
? { distinct: ['brand'] }
|
|
1873
|
+
: {}),
|
|
1835
1874
|
},
|
|
1836
1875
|
};
|
|
1837
1876
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
@@ -1849,6 +1888,7 @@ class CatalogService {
|
|
|
1849
1888
|
.then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
|
|
1850
1889
|
}
|
|
1851
1890
|
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1891
|
+
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1852
1892
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1853
1893
|
const totalResult = await this.productRepository.findCatalog({
|
|
1854
1894
|
filters: {
|
|
@@ -1859,7 +1899,7 @@ class CatalogService {
|
|
|
1859
1899
|
options: {
|
|
1860
1900
|
minimal: ['price'],
|
|
1861
1901
|
maximum: ['price'],
|
|
1862
|
-
distinct: ['brand'],
|
|
1902
|
+
...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
1863
1903
|
},
|
|
1864
1904
|
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1865
1905
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
@@ -1871,15 +1911,20 @@ class CatalogService {
|
|
|
1871
1911
|
.concat(mostRelevantWithouyStock);
|
|
1872
1912
|
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1873
1913
|
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1914
|
+
await this.setBrandsList(options, totalResult.distinct?.brand);
|
|
1874
1915
|
return {
|
|
1875
1916
|
data: resultFinal,
|
|
1876
1917
|
count: totalResult.count,
|
|
1877
1918
|
maximum: totalResult.maximum,
|
|
1878
1919
|
minimal: totalResult.minimal,
|
|
1879
|
-
distinct:
|
|
1920
|
+
distinct: {
|
|
1921
|
+
...totalResult.distinct,
|
|
1922
|
+
brand: this.brandsList[this.buildIndexBrands(options)],
|
|
1923
|
+
},
|
|
1880
1924
|
};
|
|
1881
1925
|
}
|
|
1882
1926
|
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1927
|
+
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1883
1928
|
const totalResult = await this.productRepository.findCatalog({
|
|
1884
1929
|
fields: ['id', 'stock', 'gender'],
|
|
1885
1930
|
filters: {
|
|
@@ -1890,7 +1935,7 @@ class CatalogService {
|
|
|
1890
1935
|
options: {
|
|
1891
1936
|
minimal: ['price'],
|
|
1892
1937
|
maximum: ['price'],
|
|
1893
|
-
distinct: ['brand'],
|
|
1938
|
+
...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
1894
1939
|
},
|
|
1895
1940
|
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1896
1941
|
const defaultGender = options?.filters?.gender
|
|
@@ -1913,12 +1958,16 @@ class CatalogService {
|
|
|
1913
1958
|
id: { operator: Where.IN, value: orderedId },
|
|
1914
1959
|
},
|
|
1915
1960
|
});
|
|
1961
|
+
await this.setBrandsList(options, totalResult.distinct?.brand);
|
|
1916
1962
|
return {
|
|
1917
1963
|
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1918
1964
|
count: totalResult.count,
|
|
1919
1965
|
maximum: totalResult.maximum,
|
|
1920
1966
|
minimal: totalResult.minimal,
|
|
1921
|
-
distinct:
|
|
1967
|
+
distinct: {
|
|
1968
|
+
...totalResult.distinct,
|
|
1969
|
+
brand: this.brandsList[this.buildIndexBrands(options)],
|
|
1970
|
+
},
|
|
1922
1971
|
};
|
|
1923
1972
|
}
|
|
1924
1973
|
async findCatalogIdsBySearch(term, preview = false) {
|
|
@@ -1928,6 +1977,35 @@ class CatalogService {
|
|
|
1928
1977
|
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1929
1978
|
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1930
1979
|
}
|
|
1980
|
+
async fetchBrandsOnly(options, productIds = []) {
|
|
1981
|
+
return this.productRepository
|
|
1982
|
+
.findCatalog({
|
|
1983
|
+
fields: ['id'],
|
|
1984
|
+
filters: {
|
|
1985
|
+
...(!isEmpty(productIds) ? { id: { operator: Where.IN, value: productIds } } : {}),
|
|
1986
|
+
published: { operator: Where.EQUALS, value: true },
|
|
1987
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1988
|
+
},
|
|
1989
|
+
options: {
|
|
1990
|
+
distinct: ['brand'],
|
|
1991
|
+
},
|
|
1992
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1993
|
+
.then((result) => {
|
|
1994
|
+
return result.distinct.brand;
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
async setBrandsList(options, brands) {
|
|
1998
|
+
const filterBrands = options.filters?.brands;
|
|
1999
|
+
if (isEmpty(brands))
|
|
2000
|
+
delete options.filters?.brands;
|
|
2001
|
+
this.brandsList[this.buildIndexBrands(options)] =
|
|
2002
|
+
this.brandsList[this.buildIndexBrands(options)] || brands || (await this.fetchBrandsOnly(options));
|
|
2003
|
+
this.brandsList[this.buildIndexBrands(options)] = this.brandsList[this.buildIndexBrands(options)].filter(Boolean);
|
|
2004
|
+
options.filters = {
|
|
2005
|
+
...options.filters,
|
|
2006
|
+
brands: filterBrands,
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
1931
2009
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1932
2010
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1933
2011
|
}
|
|
@@ -2123,7 +2201,7 @@ class WishlistService {
|
|
|
2123
2201
|
await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
|
|
2124
2202
|
if (!hasProduct) {
|
|
2125
2203
|
wishlist.products = [...wishlist.products, productId];
|
|
2126
|
-
|
|
2204
|
+
await this.wishlistRepository.addProduct(wishlistId, productId);
|
|
2127
2205
|
}
|
|
2128
2206
|
return wishlist;
|
|
2129
2207
|
}
|
|
@@ -2135,9 +2213,7 @@ class WishlistService {
|
|
|
2135
2213
|
const wishlistData = await this.findById(wishlistId);
|
|
2136
2214
|
const productData = await this.findProductById(productId);
|
|
2137
2215
|
await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
|
|
2138
|
-
|
|
2139
|
-
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2140
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2216
|
+
await this.wishlistRepository.removeProduct(wishlistId, productId);
|
|
2141
2217
|
}
|
|
2142
2218
|
return wishlist;
|
|
2143
2219
|
}
|