@sentecacommerce-theme/lib 0.12.103 → 0.13.1

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.
Files changed (80) hide show
  1. package/dist/cjs/analytics/Pixel/mainScript.js +1 -2
  2. package/dist/cjs/api/getSDKConfig.js +2 -4
  3. package/dist/cjs/api/myCartApi/index.js +2 -8
  4. package/dist/cjs/basket/api/mutations/index.js +0 -14
  5. package/dist/cjs/basket/hooks/index.js +0 -12
  6. package/dist/cjs/config/SentecaProvider.js +1 -3
  7. package/dist/cjs/hooks/useAggregateResult/index.js +1 -5
  8. package/dist/cjs/hooks/useAvailability/index.js +1 -1
  9. package/dist/cjs/hooks/useClearAllFilters/index.js +0 -2
  10. package/dist/cjs/hooks/useProduct/index.js +26 -36
  11. package/dist/cjs/hooks/wishlist-hooks/useWishlistItem/index.js +15 -39
  12. package/dist/cjs/listing/api/queries/useListingQuery.js +1 -1
  13. package/dist/cjs/listing/hooks/useListingFilters.js +1 -7
  14. package/dist/cjs/listing/hooks/useListingMeta.js +40 -49
  15. package/dist/cjs/listing/hooks/useSlideFilter.js +4 -27
  16. package/dist/cjs/listing/ssr/prefetchCategories.js +6 -5
  17. package/dist/cjs/listing/ssr/prefetchPredicate.js +4 -4
  18. package/dist/cjs/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
  19. package/dist/cjs/navigation/components/SearchBox/index.js +4 -4
  20. package/dist/cjs/seo/components/TranslationsMeta/index.js +14 -43
  21. package/dist/cjs/seo/components/index.js +0 -12
  22. package/dist/cjs/seo/hooks/useSeoTranslations.js +14 -55
  23. package/dist/cjs/ui/components/GridStyles.js +2 -2
  24. package/dist/cjs/ui/components/RangeSliderInput.js +1 -14
  25. package/dist/cjs/user/api/queries/useGetMyLoyaltyCardQuery.js +3 -49
  26. package/dist/cjs/utils/getSelectedFilters.js +1 -3
  27. package/dist/cjs/utils/index.js +0 -12
  28. package/dist/cjs/utils/isTouchDevice.js +1 -2
  29. package/dist/esm/analytics/Pixel/mainScript.js +1 -2
  30. package/dist/esm/api/getSDKConfig.js +3 -5
  31. package/dist/esm/api/myCartApi/index.js +2 -8
  32. package/dist/esm/basket/api/mutations/index.js +0 -1
  33. package/dist/esm/basket/hooks/index.js +0 -1
  34. package/dist/esm/config/SentecaProvider.js +1 -3
  35. package/dist/esm/hooks/useAggregateResult/index.js +1 -5
  36. package/dist/esm/hooks/useAvailability/index.js +1 -1
  37. package/dist/esm/hooks/useClearAllFilters/index.js +0 -2
  38. package/dist/esm/hooks/useProduct/index.js +18 -28
  39. package/dist/esm/hooks/wishlist-hooks/useWishlistItem/index.js +13 -21
  40. package/dist/esm/listing/api/queries/useListingQuery.js +1 -1
  41. package/dist/esm/listing/hooks/useListingFilters.js +1 -7
  42. package/dist/esm/listing/hooks/useListingMeta.js +40 -49
  43. package/dist/esm/listing/hooks/useSlideFilter.js +4 -27
  44. package/dist/esm/listing/ssr/prefetchCategories.js +7 -6
  45. package/dist/esm/listing/ssr/prefetchPredicate.js +4 -4
  46. package/dist/esm/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
  47. package/dist/esm/navigation/components/SearchBox/index.js +4 -4
  48. package/dist/esm/seo/components/TranslationsMeta/index.js +14 -43
  49. package/dist/esm/seo/components/index.js +0 -1
  50. package/dist/esm/seo/hooks/useSeoTranslations.js +14 -55
  51. package/dist/esm/ui/components/GridStyles.js +2 -2
  52. package/dist/esm/ui/components/RangeSliderInput.js +1 -14
  53. package/dist/esm/user/api/queries/useGetMyLoyaltyCardQuery.js +3 -44
  54. package/dist/esm/utils/getSelectedFilters.js +1 -3
  55. package/dist/esm/utils/index.js +0 -1
  56. package/dist/esm/utils/isTouchDevice.js +1 -2
  57. package/dist/types/basket/api/mutations/index.d.ts +0 -1
  58. package/dist/types/basket/hooks/index.d.ts +0 -1
  59. package/dist/types/hooks/basket-hooks/useBasketLineItem/index.d.ts +2 -1
  60. package/dist/types/hooks/useProduct/index.d.ts +1 -2
  61. package/dist/types/listing/hooks/useSlideFilter.d.ts +0 -4
  62. package/dist/types/listing/types.d.ts +0 -10
  63. package/dist/types/navigation/components/SearchBox/Components/EmptyBox/index.d.ts +4 -5
  64. package/dist/types/navigation/components/SearchBox/index.d.ts +6 -7
  65. package/dist/types/seo/components/index.d.ts +0 -1
  66. package/dist/types/seo/hooks/useSeoTranslations.d.ts +3 -5
  67. package/dist/types/ui/components/GridStyles.d.ts +1 -2
  68. package/dist/types/ui/components/RangeSliderInput.d.ts +1 -2
  69. package/dist/types/utils/index.d.ts +0 -1
  70. package/package.json +4 -4
  71. package/dist/cjs/basket/api/mutations/useChangeGiftVariant.js +0 -116
  72. package/dist/cjs/basket/hooks/useChangeGiftVariant.js +0 -16
  73. package/dist/cjs/utils/getLocaleFromPath.js +0 -13
  74. package/dist/esm/basket/api/mutations/useChangeGiftVariant.js +0 -106
  75. package/dist/esm/basket/hooks/useChangeGiftVariant.js +0 -3
  76. package/dist/esm/utils/getLocaleFromPath.js +0 -8
  77. package/dist/types/basket/api/mutations/useChangeGiftVariant.d.ts +0 -2
  78. package/dist/types/basket/hooks/useChangeGiftVariant.d.ts +0 -2
  79. package/dist/types/seo/components/TranslationsMeta/index.d.ts +0 -1
  80. package/dist/types/utils/getLocaleFromPath.d.ts +0 -1
@@ -6,7 +6,6 @@ import { readFromLocalStorage, writeToLocalStorage, getTranslatableField } from
6
6
  import { getSDKConfig } from '../getSDKConfig';
7
7
  import { syncResponse, getLineItemId, onMutate } from './utils';
8
8
  import { queryKey as promoCodeQueryKey } from '../../api.v2/core/misc/promo-code';
9
- import { useIsAuthenticated } from '../..';
10
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
10
  try {
12
11
  var info = gen[key](arg);
@@ -111,7 +110,6 @@ export var MyCartApiFactory = function() {
111
110
  }(),
112
111
  useGet: function() {
113
112
  var queryCache = useQueryCache();
114
- var isLoading = useIsAuthenticated().isLoading;
115
113
  return useQuery(myCartCacheKeys.useGet, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
116
114
  var data;
117
115
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
@@ -130,14 +128,12 @@ export var MyCartApiFactory = function() {
130
128
  }
131
129
  }, _callee);
132
130
  })), {
133
- enabled: !isLoading,
134
131
  retry: false,
135
- refetchOnMount: true,
132
+ refetchOnMount: false,
136
133
  refetchOnWindowFocus: false
137
134
  });
138
135
  },
139
136
  useGetCompact: function() {
140
- var isLoading = useIsAuthenticated().isLoading;
141
137
  return useQuery(myCartCacheKeys.useGetCompact, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
142
138
  var compactBasket;
143
139
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
@@ -150,9 +146,7 @@ export var MyCartApiFactory = function() {
150
146
  return _ctx.stop();
151
147
  }
152
148
  }, _callee);
153
- })), {
154
- enabled: !isLoading
155
- });
149
+ })));
156
150
  },
157
151
  useIsExisting: function(productId, variantId, collapseKey) {
158
152
  return useQuery([
@@ -1,2 +1 @@
1
1
  export * from './useReplaceBasketMutation';
2
- export * from './useChangeGiftVariant';
@@ -1,3 +1,2 @@
1
1
  export * from './useReplaceBasket';
2
2
  export * from './useBasketCrossSaleItems';
3
- export * from './useChangeGiftVariant';
@@ -4,7 +4,6 @@ import fetch from 'node-fetch';
4
4
  import { getOptions } from '../api/getSDKConfig';
5
5
  import { ReactQueryConfigProvider, useQueryCache } from 'react-query';
6
6
  import { removeAnonToken, removeAuthToken } from '../utils/tokens';
7
- import { getLocaleFromPath } from '../utils';
8
7
  import { useRouter } from 'next/router';
9
8
  function _defineProperty(obj, key, value) {
10
9
  if (key in obj) {
@@ -43,8 +42,7 @@ export function SentecaProvider(param) {
43
42
  if (localeData) {
44
43
  options.headers = _objectSpread({}, options.headers || {}, {
45
44
  InterfaceKey: localeData.interfaceKey,
46
- StoreKey: localeData.storeKey,
47
- 'senteca-locale': getLocaleFromPath()
45
+ StoreKey: localeData.storeKey
48
46
  });
49
47
  }
50
48
  HttpClient.defaultConfig = new Configuration(options);
@@ -87,9 +87,7 @@ export var useAggregateResult = function(type, aggregates, slug, predicate, quer
87
87
  aggType: a.filterDefinition,
88
88
  aggKey: filterKey,
89
89
  aggOperator: operatorMap[a.aggregationType]
90
- }, selected, router), undefined, {
91
- shallow: true
92
- });
90
+ }, selected, router));
93
91
  }
94
92
  },
95
93
  ]);
@@ -106,8 +104,6 @@ export var useAggregateResult = function(type, aggregates, slug, predicate, quer
106
104
  query: _objectSpread({}, router.query, {
107
105
  filter: filterByType(router.query.filter, a.filterDefinition)
108
106
  })
109
- }, undefined, {
110
- shallow: true
111
107
  });
112
108
  },
113
109
  type: a.aggregationType
@@ -65,7 +65,7 @@ export var useAvailability = function(param) {
65
65
  setStatus(ProductQuantityStatusEnum.OutOfStock);
66
66
  return;
67
67
  }
68
- if (quantity - (quantityInBasket || 0) < 1) {
68
+ if ((quantity !== null && quantity !== void 0 ? quantity : 0) < (quantityInBasket || 1)) {
69
69
  setStatus(ProductQuantityStatusEnum.MaxQuantityReached);
70
70
  return;
71
71
  }
@@ -35,8 +35,6 @@ export var useClearAllFilters = function() {
35
35
  router.push({
36
36
  pathname: router.pathname,
37
37
  query: query
38
- }, undefined, {
39
- shallow: true
40
38
  });
41
39
  };
42
40
  };
@@ -92,7 +92,7 @@ function _unsupportedIterableToArray(o, minLen) {
92
92
  var ProductStateContext = /*#__PURE__*/ React.createContext(undefined);
93
93
  var CountDispatchContext = /*#__PURE__*/ React.createContext(undefined);
94
94
  export function ProductProvider(param) {
95
- var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName;
95
+ var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId;
96
96
  var getVariantsWithInventory = function getVariantsWithInventory() {
97
97
  var ref9;
98
98
  var variantsWithInventory = product === null || product === void 0 ? void 0 : (ref9 = product.variants) === null || ref9 === void 0 ? void 0 : ref9.reduce(function(map, _, index, arr) {
@@ -221,26 +221,16 @@ export function ProductProvider(param) {
221
221
  return variants === null || variants === void 0 ? void 0 : variants[id];
222
222
  };
223
223
  var getVariantByCombination = function getVariantByCombination(key, value) {
224
- var ref11;
225
- var split = value === null || value === void 0 ? void 0 : value.split(':');
226
- if ((split === null || split === void 0 ? void 0 : split[0]) === 'collapseKey') {
227
- var id = Object.keys(variants).find(function(el) {
228
- var ref;
229
- return variants[el].collapseKey === (split === null || split === void 0 ? void 0 : split[1]) && ((ref = variants[el].attributes.find(function(attr) {
230
- return attr.name === 'size';
231
- })) === null || ref === void 0 ? void 0 : ref.value) === key;
232
- });
233
- return variants[id];
234
- }
235
- var id3 = (ref11 = combinations[key]) === null || ref11 === void 0 ? void 0 : ref11.params[value];
236
- return variants === null || variants === void 0 ? void 0 : variants[id3];
224
+ var ref;
225
+ var id = (ref = combinations[key]) === null || ref === void 0 ? void 0 : ref.params[value];
226
+ return variants === null || variants === void 0 ? void 0 : variants[id];
237
227
  };
238
228
  var getCustomFieldValue = function getCustomFieldValue(field) {
239
229
  return customFields === null || customFields === void 0 ? void 0 : customFields[field];
240
230
  };
241
231
  var getCombinationsForAttributeRule = function getCombinationsForAttributeRule(key, id) {
242
- var ref, ref12;
243
- var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (ref12 = ref.values) === null || ref12 === void 0 ? void 0 : ref12[id];
232
+ var ref, ref11;
233
+ var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (ref11 = ref.values) === null || ref11 === void 0 ? void 0 : ref11[id];
244
234
  return result;
245
235
  };
246
236
  var ref5 = _slicedToArray(React.useState(false), 2), mounted = ref5[0], setMounted = ref5[1];
@@ -248,34 +238,34 @@ export function ProductProvider(param) {
248
238
  var ref3 = _slicedToArray(React.useState(getVariantsWithInventory), 2), variants = ref3[0], setVariants = ref3[1];
249
239
  var ref4 = _slicedToArray(React.useState(getDefaultVariant), 2), selectedVariant = ref4[0], setSelectedVariant = ref4[1];
250
240
  var metaData = React.useMemo(function() {
251
- var ref, ref13, ref14, ref15, ref16, ref17, ref18, ref19, ref20, ref21, ref22, ref23, ref24, ref25, ref26, ref27, ref28, ref29, ref30, ref31, ref32, ref33, ref34, ref35, ref36, ref37, ref38, ref39, ref40, ref41, ref42, ref43, ref44, ref45, ref46, ref47, ref48, ref49;
241
+ var ref, ref12, ref13, ref14, ref15, ref16, ref17, ref18, ref19, ref20, ref21, ref22, ref23, ref24, ref25, ref26, ref27, ref28, ref29, ref30, ref31, ref32, ref33, ref34, ref35, ref36, ref37, ref38, ref39, ref40, ref41, ref42;
252
242
  var rootCategory = product === null || product === void 0 ? void 0 : (ref = product.categories) === null || ref === void 0 ? void 0 : ref[0];
253
243
  var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
254
244
  var metaObj = {
255
245
  _id: product === null || product === void 0 ? void 0 : product._id,
256
- name: includeBrandInName && (product === null || product === void 0 ? void 0 : (ref13 = product.brands) === null || ref13 === void 0 ? void 0 : (ref14 = ref13[0]) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.resource) === null || ref15 === void 0 ? void 0 : ref15.name) ? "".concat(getTranslatableField(product === null || product === void 0 ? void 0 : (ref16 = product.brands) === null || ref16 === void 0 ? void 0 : (ref17 = ref16[0]) === null || ref17 === void 0 ? void 0 : (ref18 = ref17.resource) === null || ref18 === void 0 ? void 0 : ref18.name), " ").concat(getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
246
+ name: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
257
247
  slug: getTranslatableField(product === null || product === void 0 ? void 0 : product.slug),
258
248
  description: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
259
249
  shortDescription: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
260
250
  brand: {
261
- _id: product === null || product === void 0 ? void 0 : (ref19 = product.brands) === null || ref19 === void 0 ? void 0 : (ref20 = ref19[0]) === null || ref20 === void 0 ? void 0 : ref20.resourceId,
262
- name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref21 = product.brands) === null || ref21 === void 0 ? void 0 : (ref22 = ref21[0]) === null || ref22 === void 0 ? void 0 : (ref23 = ref22.resource) === null || ref23 === void 0 ? void 0 : ref23.name),
263
- slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref24 = product.brands) === null || ref24 === void 0 ? void 0 : (ref25 = ref24[0]) === null || ref25 === void 0 ? void 0 : (ref26 = ref25.resource) === null || ref26 === void 0 ? void 0 : ref26.slug),
264
- logo: product === null || product === void 0 ? void 0 : (ref27 = product.brands) === null || ref27 === void 0 ? void 0 : (ref28 = ref27[0]) === null || ref28 === void 0 ? void 0 : (ref29 = ref28.resource) === null || ref29 === void 0 ? void 0 : (ref30 = ref29.assets) === null || ref30 === void 0 ? void 0 : (ref31 = ref30[0]) === null || ref31 === void 0 ? void 0 : (ref32 = ref31.sources) === null || ref32 === void 0 ? void 0 : (ref33 = ref32[0]) === null || ref33 === void 0 ? void 0 : ref33.url
251
+ _id: product === null || product === void 0 ? void 0 : (ref12 = product.brands) === null || ref12 === void 0 ? void 0 : (ref13 = ref12[0]) === null || ref13 === void 0 ? void 0 : ref13.resourceId,
252
+ name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref14 = product.brands) === null || ref14 === void 0 ? void 0 : (ref15 = ref14[0]) === null || ref15 === void 0 ? void 0 : (ref16 = ref15.resource) === null || ref16 === void 0 ? void 0 : ref16.name),
253
+ slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref17 = product.brands) === null || ref17 === void 0 ? void 0 : (ref18 = ref17[0]) === null || ref18 === void 0 ? void 0 : (ref19 = ref18.resource) === null || ref19 === void 0 ? void 0 : ref19.slug),
254
+ logo: product === null || product === void 0 ? void 0 : (ref20 = product.brands) === null || ref20 === void 0 ? void 0 : (ref21 = ref20[0]) === null || ref21 === void 0 ? void 0 : (ref22 = ref21.resource) === null || ref22 === void 0 ? void 0 : (ref23 = ref22.assets) === null || ref23 === void 0 ? void 0 : (ref24 = ref23[0]) === null || ref24 === void 0 ? void 0 : (ref25 = ref24.sources) === null || ref25 === void 0 ? void 0 : (ref26 = ref25[0]) === null || ref26 === void 0 ? void 0 : ref26.url
265
255
  },
266
256
  category: {
267
- _id: product === null || product === void 0 ? void 0 : (ref35 = product.categories) === null || ref35 === void 0 ? void 0 : (ref36 = ref35[(product === null || product === void 0 ? void 0 : (ref34 = product.categories) === null || ref34 === void 0 ? void 0 : ref34.length) - 1]) === null || ref36 === void 0 ? void 0 : ref36.resourceId,
268
- name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref38 = product.categories) === null || ref38 === void 0 ? void 0 : (ref39 = ref38[(product === null || product === void 0 ? void 0 : (ref37 = product.categories) === null || ref37 === void 0 ? void 0 : ref37.length) - 1]) === null || ref39 === void 0 ? void 0 : (ref40 = ref39.resource) === null || ref40 === void 0 ? void 0 : ref40.name),
269
- slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref42 = product.categories) === null || ref42 === void 0 ? void 0 : (ref43 = ref42[(product === null || product === void 0 ? void 0 : (ref41 = product.categories) === null || ref41 === void 0 ? void 0 : ref41.length) - 1]) === null || ref43 === void 0 ? void 0 : (ref44 = ref43.resource) === null || ref44 === void 0 ? void 0 : ref44.slug)
257
+ _id: product === null || product === void 0 ? void 0 : (ref28 = product.categories) === null || ref28 === void 0 ? void 0 : (ref29 = ref28[(product === null || product === void 0 ? void 0 : (ref27 = product.categories) === null || ref27 === void 0 ? void 0 : ref27.length) - 1]) === null || ref29 === void 0 ? void 0 : ref29.resourceId,
258
+ name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref31 = product.categories) === null || ref31 === void 0 ? void 0 : (ref32 = ref31[(product === null || product === void 0 ? void 0 : (ref30 = product.categories) === null || ref30 === void 0 ? void 0 : ref30.length) - 1]) === null || ref32 === void 0 ? void 0 : (ref33 = ref32.resource) === null || ref33 === void 0 ? void 0 : ref33.name),
259
+ slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref35 = product.categories) === null || ref35 === void 0 ? void 0 : (ref36 = ref35[(product === null || product === void 0 ? void 0 : (ref34 = product.categories) === null || ref34 === void 0 ? void 0 : ref34.length) - 1]) === null || ref36 === void 0 ? void 0 : (ref37 = ref36.resource) === null || ref37 === void 0 ? void 0 : ref37.slug)
270
260
  },
271
261
  rootCategory: {
272
262
  _id: rootCategoryId,
273
- name: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref45 = rootCategory.resource) === null || ref45 === void 0 ? void 0 : ref45.name),
274
- slug: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref46 = rootCategory.resource) === null || ref46 === void 0 ? void 0 : ref46.slug)
263
+ name: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref38 = rootCategory.resource) === null || ref38 === void 0 ? void 0 : ref38.name),
264
+ slug: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref39 = rootCategory.resource) === null || ref39 === void 0 ? void 0 : ref39.slug)
275
265
  },
276
266
  categories: formatCategories(product === null || product === void 0 ? void 0 : product.categories, rootCategoryId),
277
267
  reviewRatingStatistics: product === null || product === void 0 ? void 0 : product.reviewRatingStatistics,
278
- content: Boolean(selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref47 = selectedVariant.content) === null || ref47 === void 0 ? void 0 : ref47.map(createProductContent).length) ? selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref48 = selectedVariant.content) === null || ref48 === void 0 ? void 0 : ref48.map(createProductContent) : product === null || product === void 0 ? void 0 : (ref49 = product.content) === null || ref49 === void 0 ? void 0 : ref49.map(createProductContent),
268
+ content: Boolean(selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref40 = selectedVariant.content) === null || ref40 === void 0 ? void 0 : ref40.map(createProductContent).length) ? selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref41 = selectedVariant.content) === null || ref41 === void 0 ? void 0 : ref41.map(createProductContent) : product === null || product === void 0 ? void 0 : (ref42 = product.content) === null || ref42 === void 0 ? void 0 : ref42.map(createProductContent),
279
269
  assets: assetsFieldsToMap(product === null || product === void 0 ? void 0 : product.assets)
280
270
  };
281
271
  return metaObj;
@@ -1,7 +1,7 @@
1
- import React, { useEffect } from 'react';
2
- import { useBoolean, wishlistApi } from '../../../';
1
+ import React from 'react';
2
+ import { wishlistApi } from '../../../';
3
3
  import { usePrefetchProduct, getTranslatableField } from '../../../';
4
- import { createMappedAttributes } from '../../basket-hooks/useBasketLineItem/utils';
4
+ import { getTimeStamp, createMappedAttributes } from '../../basket-hooks/useBasketLineItem/utils';
5
5
  import { customFieldsToMap } from '../../../utils';
6
6
  function _arrayLikeToArray(arr, len) {
7
7
  if (len == null || len > arr.length) len = arr.length;
@@ -51,19 +51,15 @@ function _unsupportedIterableToArray(o, minLen) {
51
51
  }
52
52
  export var useWishlistItem = function(props) {
53
53
  var ref16;
54
- var item = props.item, expiry = props.expiry;
55
- var ref1 = _slicedToArray(useBoolean(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
54
+ var ref1 = _slicedToArray(React.useState(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
56
55
  var ref2 = _slicedToArray(wishlistApi.useSync(), 1), syncWishlist = ref2[0];
57
56
  var ref3 = usePrefetchProduct(getTranslatableField(props === null || props === void 0 ? void 0 : (ref16 = props.item) === null || ref16 === void 0 ? void 0 : ref16.productSlug)), onMouseDown = ref3.onMouseDown, onMouseEnter = ref3.onMouseEnter, onMouseLeave = ref3.onMouseLeave;
58
- useEffect(function() {
59
- if (expiry) {
60
- if (Date.now() > expiry + (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
61
- setIsExpired.on();
62
- }
63
- }
64
- }, []);
65
57
  var data = React.useMemo(function() {
66
58
  var ref, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15;
59
+ var item = props.item;
60
+ if (props.expiry && getTimeStamp(props.expiry) < (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
61
+ setIsExpired(true);
62
+ }
67
63
  var offer = item === null || item === void 0 ? void 0 : (ref = item.productVariant) === null || ref === void 0 ? void 0 : ref.offer;
68
64
  var mappedAttributes = createMappedAttributes(item === null || item === void 0 ? void 0 : (ref4 = item.productVariant) === null || ref4 === void 0 ? void 0 : ref4.attributes) || {};
69
65
  var mappedCustomField = customFieldsToMap(item.custom);
@@ -103,15 +99,11 @@ export var useWishlistItem = function(props) {
103
99
  }
104
100
  };
105
101
  }, [
106
- item
107
- ]);
108
- useEffect(function() {
109
- if (isExpired) {
110
- syncWishlist();
111
- setIsExpired.off();
112
- }
113
- }, [
114
- isExpired
102
+ props.item
115
103
  ]);
104
+ if (isExpired) {
105
+ syncWishlist();
106
+ setIsExpired(false);
107
+ }
116
108
  return data;
117
109
  };
@@ -126,7 +126,7 @@ export var useListingQuery = function() {
126
126
  predicate: predicate,
127
127
  sort: sort,
128
128
  postFilter: postFilter,
129
- slug: aliasedSlug,
129
+ slug: slug,
130
130
  offset: offset
131
131
  });
132
132
  return useQuery(queryKeys, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
@@ -125,8 +125,6 @@ export function ListingFiltersProvider(param) {
125
125
  query: _objectSpread({}, router.query, {
126
126
  filter: filterByType(router.query.filter, filter)
127
127
  })
128
- }, undefined, {
129
- shallow: true
130
128
  });
131
129
  },
132
130
  type: type
@@ -146,8 +144,6 @@ export function ListingFiltersProvider(param) {
146
144
  router.push({
147
145
  pathname: router.pathname,
148
146
  query: query
149
- }, undefined, {
150
- shallow: true
151
147
  });
152
148
  };
153
149
  var selectedFilters = React.useMemo(function() {
@@ -190,9 +186,7 @@ function generateFilters(param) {
190
186
  aggType: filter,
191
187
  aggKey: filterKey,
192
188
  aggOperator: filtersOperatorsMap[type]
193
- }, Boolean(selected), router), undefined, {
194
- shallow: true
195
- });
189
+ }, Boolean(selected), router));
196
190
  }
197
191
  };
198
192
  });
@@ -4,6 +4,7 @@ import { customFieldsToMap, escape, getTranslatableField } from '../../utils';
4
4
  import { assetsFieldsToMap } from '../../utils/assetsToMap';
5
5
  import { useRouter } from 'next/router';
6
6
  import { getListingPageType } from '../utils';
7
+ import { ListingTypesEnum } from '../types';
7
8
  import { useListingAlias } from '../../index';
8
9
  import { useListingFilters } from './useListingFilters';
9
10
  import { useListingCategories } from './useListingCategories';
@@ -22,33 +23,6 @@ function _iterableToArray(iter) {
22
23
  function _nonIterableSpread() {
23
24
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
24
25
  }
25
- function _objectWithoutProperties(source, excluded) {
26
- if (source == null) return {};
27
- var target = _objectWithoutPropertiesLoose(source, excluded);
28
- var key, i;
29
- if (Object.getOwnPropertySymbols) {
30
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
31
- for(i = 0; i < sourceSymbolKeys.length; i++){
32
- key = sourceSymbolKeys[i];
33
- if (excluded.indexOf(key) >= 0) continue;
34
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
35
- target[key] = source[key];
36
- }
37
- }
38
- return target;
39
- }
40
- function _objectWithoutPropertiesLoose(source, excluded) {
41
- if (source == null) return {};
42
- var target = {};
43
- var sourceKeys = Object.keys(source);
44
- var key, i;
45
- for(i = 0; i < sourceKeys.length; i++){
46
- key = sourceKeys[i];
47
- if (excluded.indexOf(key) >= 0) continue;
48
- target[key] = source[key];
49
- }
50
- return target;
51
- }
52
26
  function _toConsumableArray(arr) {
53
27
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
54
28
  }
@@ -106,57 +80,74 @@ export var useListingMeta = function() {
106
80
  return result;
107
81
  };
108
82
  function processDisplayName(slug, config, name, breadcrumb, router, aggData, categoriesData) {
109
- var ref, ref5;
110
83
  var listingName = getTranslatableField(name);
111
84
  var brandName = getBrandName(router, aggData);
112
85
  var categoryName = getCategoryName(router, categoriesData);
113
86
  var type = getListingPageType(router, slug, config);
114
- var getTitle = config.getTitle, rest = _objectWithoutProperties(config, [
115
- "getTitle"
116
- ]);
117
- var title = getTitle === null || getTitle === void 0 ? void 0 : getTitle(type, rest, {
118
- category: categoryName,
119
- brand: brandName,
120
- defaultName: listingName,
121
- attribute: (ref = config.titleAliases) === null || ref === void 0 ? void 0 : ref[slug],
122
- childAttribute: getTranslatableField(breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.label),
123
- search: router === null || router === void 0 ? void 0 : (ref5 = router.query) === null || ref5 === void 0 ? void 0 : ref5.search,
124
- isWithAttribute: Boolean(router === null || router === void 0 ? void 0 : router.query.cat)
125
- });
126
- return title || listingName;
87
+ if (type === ListingTypesEnum.AttrPage) {
88
+ return "Всичко за ".concat(config.titleAliases[slug]);
89
+ }
90
+ if (router === null || router === void 0 ? void 0 : router.query.cat) {
91
+ var attribute = getTranslatableField(breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.label);
92
+ if (type === ListingTypesEnum.Category) {
93
+ if (!brandName) {
94
+ return "".concat(listingName, " за ").concat(attribute);
95
+ }
96
+ return "".concat(listingName, " за ").concat(attribute, " от ").concat(brandName);
97
+ }
98
+ if (type === ListingTypesEnum.Brand) {
99
+ if (!categoryName) {
100
+ return "Всички продукти от ".concat(listingName, " за ").concat(attribute);
101
+ }
102
+ return "".concat(categoryName, " от ").concat(listingName, " за ").concat(attribute);
103
+ }
104
+ }
105
+ if (type === ListingTypesEnum.Category && brandName) {
106
+ return "".concat(listingName, " от ").concat(brandName);
107
+ }
108
+ if (type === ListingTypesEnum.Brand) {
109
+ if (!categoryName) {
110
+ return "Всички продукти от ".concat(listingName);
111
+ }
112
+ return "".concat(categoryName, " от ").concat(listingName);
113
+ }
114
+ if (type === ListingTypesEnum.Search && (router === null || router === void 0 ? void 0 : router.query.search)) {
115
+ return "".concat(listingName, " от \"").concat(router.query.search, "\"");
116
+ }
117
+ return listingName;
127
118
  }
128
119
  function getFilterByType(filterType, router) {
129
120
  var filterId = '';
130
121
  if (Array.isArray(router === null || router === void 0 ? void 0 : router.query.filter)) {
131
- var ref, ref6;
122
+ var ref, ref5;
132
123
  var filters = (ref = router === null || router === void 0 ? void 0 : router.query.filter) === null || ref === void 0 ? void 0 : ref.filter(function(x) {
133
124
  return x === null || x === void 0 ? void 0 : x.includes(filterType);
134
125
  });
135
126
  if ((filters === null || filters === void 0 ? void 0 : filters.length) && filters.length > 1) {
136
127
  return '';
137
128
  }
138
- var filterTerm = (ref6 = /\d+/.exec((filters === null || filters === void 0 ? void 0 : filters[0]) || '')) === null || ref6 === void 0 ? void 0 : ref6[0];
129
+ var filterTerm = (ref5 = /\d+/.exec((filters === null || filters === void 0 ? void 0 : filters[0]) || '')) === null || ref5 === void 0 ? void 0 : ref5[0];
139
130
  if (!filterTerm) return '';
140
131
  filterId = filterTerm;
141
132
  } else {
142
- var ref7, ref8, ref9;
143
- var isFiltered = router === null || router === void 0 ? void 0 : (ref7 = router.query) === null || ref7 === void 0 ? void 0 : (ref8 = ref7.filter) === null || ref8 === void 0 ? void 0 : ref8.includes(filterType);
133
+ var ref6, ref7, ref8;
134
+ var isFiltered = router === null || router === void 0 ? void 0 : (ref6 = router.query) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.filter) === null || ref7 === void 0 ? void 0 : ref7.includes(filterType);
144
135
  if (!isFiltered) {
145
136
  return '';
146
137
  }
147
- filterId = (ref9 = /(\w+)-(\d+)/.exec(router === null || router === void 0 ? void 0 : router.query.filter)) === null || ref9 === void 0 ? void 0 : ref9[0];
138
+ filterId = (ref8 = /(\w+)-(\d+)/.exec(router === null || router === void 0 ? void 0 : router.query.filter)) === null || ref8 === void 0 ? void 0 : ref8[0];
148
139
  }
149
140
  return filterId;
150
141
  }
151
142
  function getBrandName(router, filtersData) {
152
- var ref, ref10, ref11;
143
+ var ref, ref9, ref10;
153
144
  var brandId = getFilterByType('brand', router);
154
145
  var brand = (ref = filtersData === null || filtersData === void 0 ? void 0 : filtersData.find(function(x) {
155
146
  return x.name === 'Brands';
156
- })) === null || ref === void 0 ? void 0 : (ref10 = ref.items) === null || ref10 === void 0 ? void 0 : ref10.find(function(x) {
147
+ })) === null || ref === void 0 ? void 0 : (ref9 = ref.items) === null || ref9 === void 0 ? void 0 : ref9.find(function(x) {
157
148
  return x.data.key === brandId;
158
149
  });
159
- return getTranslatableField(brand === null || brand === void 0 ? void 0 : (ref11 = brand.meta) === null || ref11 === void 0 ? void 0 : ref11.name);
150
+ return getTranslatableField(brand === null || brand === void 0 ? void 0 : (ref10 = brand.meta) === null || ref10 === void 0 ? void 0 : ref10.name);
160
151
  }
161
152
  function getCategoryName(router, categories) {
162
153
  var categoryId = getFilterByType('category', router);
@@ -52,7 +52,7 @@ function _unsupportedIterableToArray(o, minLen) {
52
52
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
53
53
  }
54
54
  export var useSlideFilter = function(filterName, min, max) {
55
- var ref3;
55
+ var ref;
56
56
  var router = useRouter();
57
57
  var meta = useListingConfig().meta;
58
58
  var slug = useListingAlias(meta).slug;
@@ -67,7 +67,7 @@ export var useSlideFilter = function(filterName, min, max) {
67
67
  }
68
68
  if (allFilters.includes(filterQuery)) return allFilters;
69
69
  };
70
- var filter = (ref3 = getFilter()) === null || ref3 === void 0 ? void 0 : ref3.replace(filterQuery, '');
70
+ var filter = (ref = getFilter()) === null || ref === void 0 ? void 0 : ref.replace(filterQuery, '');
71
71
  var ref1 = _slicedToArray(filter ? filter.split(',') : [
72
72
  min,
73
73
  max
@@ -77,38 +77,16 @@ export var useSlideFilter = function(filterName, min, max) {
77
77
  to: +to || max
78
78
  }), 2), state = ref2[0], setState = ref2[1];
79
79
  var timeoutRef = useRef();
80
- var getFormattedPriceRange = function(data) {
80
+ var updateValue = useCallback(function(data) {
81
81
  var formattedFrom = Math.min(Math.max(data.from, min), data.to);
82
82
  var formattedTo = Math.max(data.from, Math.min(data.to, max));
83
- return {
84
- formattedFrom: formattedFrom,
85
- formattedTo: formattedTo
86
- };
87
- };
88
- var updateValue = useCallback(function(data) {
89
- var ref = getFormattedPriceRange(data), formattedFrom = ref.formattedFrom, formattedTo = ref.formattedTo;
90
- setState({
91
- from: formattedFrom,
92
- to: formattedTo
93
- });
94
- }, [
95
- filterName,
96
- max,
97
- min,
98
- router,
99
- slug
100
- ]);
101
- var applyFilter = useCallback(function(data) {
102
- var ref = getFormattedPriceRange(data), formattedFrom = ref.formattedFrom, formattedTo = ref.formattedTo;
103
83
  clearTimeout(timeoutRef.current);
104
84
  timeoutRef.current = setTimeout(function() {
105
85
  router.push(createAggregateQuery(getListingPageType(router, slug, meta), router.query.slug, {
106
86
  aggType: filterName,
107
87
  aggKey: "".concat(formattedFrom, ",").concat(formattedTo),
108
88
  aggOperator: filtersOperatorsMap.stats
109
- }, false, router, true), undefined, {
110
- shallow: true
111
- });
89
+ }, false, router, true));
112
90
  }, 500);
113
91
  setState({
114
92
  from: formattedFrom,
@@ -123,7 +101,6 @@ export var useSlideFilter = function(filterName, min, max) {
123
101
  ]);
124
102
  return {
125
103
  value: state,
126
- applyFilter: applyFilter,
127
104
  updateValue: updateValue
128
105
  };
129
106
  };
@@ -1,6 +1,6 @@
1
1
  import regeneratorRuntime from "regenerator-runtime";
2
2
  import { CatalogAggregate } from '@sentecacommerce/sdk';
3
- import { getListingAlias, getPostFilters } from '../utils';
3
+ import { getSlug, getListingAlias, getPostFilters } from '../utils';
4
4
  import { prepareAggregateQuery, AggregateRequestEnum, generateAggregateKey } from '../api';
5
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6
6
  try {
@@ -36,7 +36,7 @@ export function prefetchCategories(queryCache, router, predicate, aggregates, co
36
36
  }
37
37
  function _prefetchCategories() {
38
38
  _prefetchCategories = _asyncToGenerator(regeneratorRuntime.mark(function _callee(queryCache, router, predicate, aggregates, config) {
39
- var aggregateKeys, aliasedSlug, query, response;
39
+ var aggregateKeys, aliasedSlug, slug, query, response;
40
40
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
41
41
  while(1)switch(_ctx.prev = _ctx.next){
42
42
  case 0:
@@ -45,18 +45,19 @@ function _prefetchCategories() {
45
45
  router: router,
46
46
  config: config
47
47
  });
48
+ slug = getSlug(router, aliasedSlug);
48
49
  query = prepareAggregateQuery({
49
50
  request: AggregateRequestEnum.Categories,
50
51
  router: router,
51
52
  predicate: predicate,
52
53
  slug: aliasedSlug,
53
54
  aggregates: aggregates,
54
- postFilter: getPostFilters(router),
55
+ postFilter: undefined,
55
56
  config: config
56
57
  });
57
- _ctx.next = 5;
58
+ _ctx.next = 6;
58
59
  return CatalogAggregate(query);
59
- case 5:
60
+ case 6:
60
61
  response = _ctx.sent;
61
62
  queryCache.setQueryData([
62
63
  AggregateRequestEnum.Categories,
@@ -67,7 +68,7 @@ function _prefetchCategories() {
67
68
  staleTime: 30000
68
69
  });
69
70
  return _ctx.abrupt("return", response);
70
- case 8:
71
+ case 9:
71
72
  case "end":
72
73
  return _ctx.stop();
73
74
  }
@@ -35,20 +35,20 @@ export function prefetchPredicate(queryCache, router, config) {
35
35
  }
36
36
  function _prefetchPredicate() {
37
37
  _prefetchPredicate = _asyncToGenerator(regeneratorRuntime.mark(function _callee(queryCache, router, config) {
38
- var aliasedSlug, slug, data, attribute;
38
+ var attribute, aliasedSlug, slug, data;
39
39
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
40
40
  while(1)switch(_ctx.prev = _ctx.next){
41
41
  case 0:
42
+ attribute = router.query.cat && router.query.slug;
42
43
  aliasedSlug = getListingAlias({
43
44
  router: router,
44
45
  config: config
45
46
  });
46
47
  slug = getSlug(router, aliasedSlug);
47
- _ctx.next = 4;
48
+ _ctx.next = 5;
48
49
  return processPredicateRequest(slug, router, aliasedSlug);
49
- case 4:
50
+ case 5:
50
51
  data = _ctx.sent;
51
- attribute = router.query.cat && aliasedSlug;
52
52
  queryCache.setQueryData([
53
53
  ListingQueryKeysEnum.usePredicate,
54
54
  slug,
@@ -80,38 +80,38 @@ export var EmptyBox = function(param) {
80
80
  textColor: textColor || '',
81
81
  onClose: onClose
82
82
  })), /*#__PURE__*/ React.createElement(SuggestedSearches, null, canDisplayPopular && /*#__PURE__*/ React.createElement(PopularSearches, {
83
- title: (labels === null || labels === void 0 ? void 0 : labels.popularSearches) || '',
83
+ title: (labels === null || labels === void 0 ? void 0 : labels.popularSearchesLabel) || '',
84
84
  onClose: onClose,
85
85
  textColor: textColor || '',
86
86
  labelsColor: labelsColor || ''
87
87
  }), withRecent && canDisplayRecent && /*#__PURE__*/ React.createElement(RecentSearches, {
88
- title: (labels === null || labels === void 0 ? void 0 : labels.recentSearches) || '',
88
+ title: (labels === null || labels === void 0 ? void 0 : labels.recentSearchesLabel) || '',
89
89
  data: searchHistory,
90
90
  onClose: onClose,
91
91
  textColor: textColor || '',
92
92
  labelsColor: labelsColor || ''
93
93
  }))) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Container, {
94
94
  labelsColor: labelsColor,
95
- title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
95
+ title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
96
96
  onlyMobile: true
97
97
  }, /*#__PURE__*/ React.createElement(NoResultsDesc, {
98
98
  className: "SEARCH_BOX_NO_RESULT"
99
- }, labels === null || labels === void 0 ? void 0 : labels.noResults)), /*#__PURE__*/ React.createElement(PromoCol, {
99
+ }, "No results found")), /*#__PURE__*/ React.createElement(PromoCol, {
100
100
  backgroundColor: backgroundColor
101
101
  }, /*#__PURE__*/ React.createElement(Products, {
102
102
  data: promoOffers,
103
103
  textColor: textColor || '',
104
104
  labelsColor: labelsColor || '',
105
105
  onClose: onClose,
106
- title: (labels === null || labels === void 0 ? void 0 : labels.promoOffers) || '',
106
+ title: (labels === null || labels === void 0 ? void 0 : labels.promoOffersLabel) || '',
107
107
  offers: true
108
108
  })), /*#__PURE__*/ React.createElement(Container, {
109
109
  labelsColor: labelsColor,
110
- title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
110
+ title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
111
111
  onlyDesktop: true
112
112
  }, /*#__PURE__*/ React.createElement(NoResultsDesc, {
113
113
  className: "SEARCH_BOX_NO_RESULT"
114
- }, labels === null || labels === void 0 ? void 0 : labels.noResults))))));
114
+ }, "No results found"))))));
115
115
  };
116
116
  var Wrapper = styled.div.attrs({
117
117
  className: 'd-flex flex-column flex-lg-row mx-lg-auto '