@sentecacommerce-theme/lib 0.12.96 → 0.12.100

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.
@@ -158,7 +158,8 @@ function _objectSpread(target) {
158
158
  mode: 'cors',
159
159
  cache: 'no-cache',
160
160
  headers: {
161
- 'Content-Type': 'application/json'
161
+ 'Content-Type': 'application/json',
162
+ 'senteca-locale': global.location.pathname.split('/')[1] || ''
162
163
  },
163
164
  body: JSON.stringify(payload)
164
165
  });
@@ -44,14 +44,16 @@ var getSDKConfig = function() {
44
44
  var defaultConfig = getOptions(options);
45
45
  var headers = ((ref = _sdk.HttpClient.defaultConfig) === null || ref === void 0 ? void 0 : ref.options.headers) || (defaultConfig === null || defaultConfig === void 0 ? void 0 : defaultConfig.headers) || {};
46
46
  var config = new _sdk.Configuration(_objectSpread({}, ((ref1 = _sdk.HttpClient.defaultConfig) === null || ref1 === void 0 ? void 0 : ref1.options) || defaultConfig, options, {
47
- headers: _objectSpread({}, headers, options.headers || {})
47
+ headers: _objectSpread({}, headers, options.headers || {}, {
48
+ 'senteca-locale': (0, _utils).getLocaleFromPath()
49
+ })
48
50
  }));
49
51
  return config;
50
52
  };
51
53
  exports.getSDKConfig = getSDKConfig;
52
54
  var getOptions = function() {
53
55
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
54
- if (typeof window === 'undefined') {
56
+ if (!(0, _utils).canUseDOM()) {
55
57
  // eslint-disable-next-line @typescript-eslint/no-var-requires
56
58
  var nodeFetch = require('node-fetch');
57
59
  var ref;
@@ -10,6 +10,7 @@ var _utils = require("../../utils");
10
10
  var _getSDKConfig = require("../getSDKConfig");
11
11
  var _utils1 = require("./utils");
12
12
  var _promoCode = require("../../api.v2/core/misc/promo-code");
13
+ var _ = require("../..");
13
14
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
15
  try {
15
16
  var info = gen[key](arg);
@@ -122,6 +123,7 @@ var MyCartApiFactory = function() {
122
123
  }(),
123
124
  useGet: function() {
124
125
  var queryCache = (0, _reactQuery).useQueryCache();
126
+ var isLoading = (0, _).useIsAuthenticated().isLoading;
125
127
  return (0, _reactQuery).useQuery(myCartCacheKeys.useGet, _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
126
128
  var data;
127
129
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
@@ -140,12 +142,14 @@ var MyCartApiFactory = function() {
140
142
  }
141
143
  }, _callee);
142
144
  })), {
145
+ enabled: !isLoading,
143
146
  retry: false,
144
- refetchOnMount: false,
147
+ refetchOnMount: true,
145
148
  refetchOnWindowFocus: false
146
149
  });
147
150
  },
148
151
  useGetCompact: function() {
152
+ var isLoading = (0, _).useIsAuthenticated().isLoading;
149
153
  return (0, _reactQuery).useQuery(myCartCacheKeys.useGetCompact, _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
150
154
  var compactBasket;
151
155
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
@@ -158,7 +162,9 @@ var MyCartApiFactory = function() {
158
162
  return _ctx.stop();
159
163
  }
160
164
  }, _callee);
161
- })));
165
+ })), {
166
+ enabled: !isLoading
167
+ });
162
168
  },
163
169
  useIsExisting: function(productId, variantId, collapseKey) {
164
170
  return (0, _reactQuery).useQuery([
@@ -8,6 +8,7 @@ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
8
8
  var _getSDKConfig = require("../api/getSDKConfig");
9
9
  var _reactQuery = require("react-query");
10
10
  var _tokens = require("../utils/tokens");
11
+ var _utils = require("../utils");
11
12
  var _router = require("next/router");
12
13
  function _defineProperty(obj, key, value) {
13
14
  if (key in obj) {
@@ -51,7 +52,8 @@ function SentecaProvider(param) {
51
52
  if (localeData) {
52
53
  options.headers = _objectSpread({}, options.headers || {}, {
53
54
  InterfaceKey: localeData.interfaceKey,
54
- StoreKey: localeData.storeKey
55
+ StoreKey: localeData.storeKey,
56
+ 'senteca-locale': (0, _utils).getLocaleFromPath()
55
57
  });
56
58
  }
57
59
  _sdk.HttpClient.defaultConfig = new _sdk.Configuration(options);
@@ -70,7 +70,7 @@ var useAvailability = function(param) {
70
70
  setStatus(ProductQuantityStatusEnum.OutOfStock);
71
71
  return;
72
72
  }
73
- if ((quantity !== null && quantity !== void 0 ? quantity : 0) < (quantityInBasket || 1)) {
73
+ if (quantity - (quantityInBasket || 0) < 1) {
74
74
  setStatus(ProductQuantityStatusEnum.MaxQuantityReached);
75
75
  return;
76
76
  }
@@ -317,16 +317,26 @@ function ProductProvider(param) {
317
317
  return variants === null || variants === void 0 ? void 0 : variants[id];
318
318
  }
319
319
  function getVariantByCombination(key, value) {
320
- var ref;
321
- var id = (ref = combinations[key]) === null || ref === void 0 ? void 0 : ref.params[value];
322
- return variants === null || variants === void 0 ? void 0 : variants[id];
320
+ var ref42;
321
+ var split = value === null || value === void 0 ? void 0 : value.split(':');
322
+ if ((split === null || split === void 0 ? void 0 : split[0]) === 'collapseKey') {
323
+ var id = Object.keys(variants).find(function(el) {
324
+ var ref;
325
+ return variants[el].collapseKey === (split === null || split === void 0 ? void 0 : split[1]) && ((ref = variants[el].attributes.find(function(attr) {
326
+ return attr.name === 'size';
327
+ })) === null || ref === void 0 ? void 0 : ref.value) === key;
328
+ });
329
+ return variants[id];
330
+ }
331
+ var id3 = (ref42 = combinations[key]) === null || ref42 === void 0 ? void 0 : ref42.params[value];
332
+ return variants === null || variants === void 0 ? void 0 : variants[id3];
323
333
  }
324
334
  function getCustomFieldValue(field) {
325
335
  return customFields === null || customFields === void 0 ? void 0 : customFields[field];
326
336
  }
327
337
  function getCombinationsForAttributeRule(key, id) {
328
- var ref, ref42;
329
- var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (ref42 = ref.values) === null || ref42 === void 0 ? void 0 : ref42[id];
338
+ var ref, ref43;
339
+ var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (ref43 = ref.values) === null || ref43 === void 0 ? void 0 : ref43[id];
330
340
  return result;
331
341
  }
332
342
  var collapsedImages = (0, _utils).createCollapseKeyImagesMap(product);
@@ -60,7 +60,7 @@ function _prefetchCategories() {
60
60
  predicate: predicate,
61
61
  slug: aliasedSlug,
62
62
  aggregates: aggregates,
63
- postFilter: undefined,
63
+ postFilter: (0, _utils).getPostFilters(router),
64
64
  config: config
65
65
  });
66
66
  _ctx.next = 5;
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.getLocaleFromPath = void 0;
5
+ var _canUseDom = require("./canUseDom");
6
+ var getLocaleFromPath = function() {
7
+ if (!(0, _canUseDom).canUseDOM()) return '';
8
+ var locale = window.location.pathname.split('/')[1] || '';
9
+ // the allowed standards: bg bg-BG, en en-US/en-UK
10
+ if (locale.length !== 2 && locale.length !== 5) return '';
11
+ return locale;
12
+ };
13
+ exports.getLocaleFromPath = getLocaleFromPath;
@@ -170,6 +170,18 @@ Object.keys(_adjustColor).forEach(function(key) {
170
170
  }
171
171
  });
172
172
  });
173
+ var _getLocaleFromPath = _interopRequireWildcard(require("./getLocaleFromPath"));
174
+ Object.keys(_getLocaleFromPath).forEach(function(key) {
175
+ if (key === "default" || key === "__esModule") return;
176
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
177
+ if (key in exports && exports[key] === _getLocaleFromPath[key]) return;
178
+ Object.defineProperty(exports, key, {
179
+ enumerable: true,
180
+ get: function() {
181
+ return _getLocaleFromPath[key];
182
+ }
183
+ });
184
+ });
173
185
  var _calcDiscount = _interopRequireWildcard(require("./calcDiscount"));
174
186
  Object.keys(_calcDiscount).forEach(function(key) {
175
187
  if (key === "default" || key === "__esModule") return;
@@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", {
2
2
  value: true
3
3
  });
4
4
  exports.isTouchDevice = isTouchDevice;
5
+ var _canUseDom = require("./canUseDom");
5
6
  function isTouchDevice() {
6
- return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
7
+ return (0, _canUseDom).canUseDOM() && ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
7
8
  }
@@ -246,7 +246,8 @@ function _objectSpread(target) {
246
246
  mode: 'cors',
247
247
  cache: 'no-cache',
248
248
  headers: {
249
- 'Content-Type': 'application/json'
249
+ 'Content-Type': 'application/json',
250
+ 'senteca-locale': global.location.pathname.split('/')[1] || ''
250
251
  },
251
252
  body: JSON.stringify(payload)
252
253
  });
@@ -1,6 +1,6 @@
1
1
  import { Configuration, HttpClient } from '@sentecacommerce/sdk';
2
2
  import Cookies from 'js-cookie';
3
- import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY } from '../utils';
3
+ import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY, getLocaleFromPath, canUseDOM } from '../utils';
4
4
  function _defineProperty(obj, key, value) {
5
5
  if (key in obj) {
6
6
  Object.defineProperty(obj, key, {
@@ -35,13 +35,15 @@ export var getSDKConfig = function() {
35
35
  var defaultConfig = getOptions(options);
36
36
  var headers = ((ref = HttpClient.defaultConfig) === null || ref === void 0 ? void 0 : ref.options.headers) || (defaultConfig === null || defaultConfig === void 0 ? void 0 : defaultConfig.headers) || {};
37
37
  var config = new Configuration(_objectSpread({}, ((ref1 = HttpClient.defaultConfig) === null || ref1 === void 0 ? void 0 : ref1.options) || defaultConfig, options, {
38
- headers: _objectSpread({}, headers, options.headers || {})
38
+ headers: _objectSpread({}, headers, options.headers || {}, {
39
+ 'senteca-locale': getLocaleFromPath()
40
+ })
39
41
  }));
40
42
  return config;
41
43
  };
42
44
  export var getOptions = function() {
43
45
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
44
- if (typeof window === 'undefined') {
46
+ if (!canUseDOM()) {
45
47
  // eslint-disable-next-line @typescript-eslint/no-var-requires
46
48
  var nodeFetch = require('node-fetch');
47
49
  var ref;
@@ -6,6 +6,7 @@ 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 '../..';
9
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
11
  try {
11
12
  var info = gen[key](arg);
@@ -110,6 +111,7 @@ export var MyCartApiFactory = function() {
110
111
  }(),
111
112
  useGet: function() {
112
113
  var queryCache = useQueryCache();
114
+ var isLoading = useIsAuthenticated().isLoading;
113
115
  return useQuery(myCartCacheKeys.useGet, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
114
116
  var data;
115
117
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
@@ -128,12 +130,14 @@ export var MyCartApiFactory = function() {
128
130
  }
129
131
  }, _callee);
130
132
  })), {
133
+ enabled: !isLoading,
131
134
  retry: false,
132
- refetchOnMount: false,
135
+ refetchOnMount: true,
133
136
  refetchOnWindowFocus: false
134
137
  });
135
138
  },
136
139
  useGetCompact: function() {
140
+ var isLoading = useIsAuthenticated().isLoading;
137
141
  return useQuery(myCartCacheKeys.useGetCompact, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
138
142
  var compactBasket;
139
143
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
@@ -146,7 +150,9 @@ export var MyCartApiFactory = function() {
146
150
  return _ctx.stop();
147
151
  }
148
152
  }, _callee);
149
- })));
153
+ })), {
154
+ enabled: !isLoading
155
+ });
150
156
  },
151
157
  useIsExisting: function(productId, variantId, collapseKey) {
152
158
  return useQuery([
@@ -4,6 +4,7 @@ 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';
7
8
  import { useRouter } from 'next/router';
8
9
  function _defineProperty(obj, key, value) {
9
10
  if (key in obj) {
@@ -42,7 +43,8 @@ export function SentecaProvider(param) {
42
43
  if (localeData) {
43
44
  options.headers = _objectSpread({}, options.headers || {}, {
44
45
  InterfaceKey: localeData.interfaceKey,
45
- StoreKey: localeData.storeKey
46
+ StoreKey: localeData.storeKey,
47
+ 'senteca-locale': getLocaleFromPath()
46
48
  });
47
49
  }
48
50
  HttpClient.defaultConfig = new Configuration(options);
@@ -65,7 +65,7 @@ export var useAvailability = function(param) {
65
65
  setStatus(ProductQuantityStatusEnum.OutOfStock);
66
66
  return;
67
67
  }
68
- if ((quantity !== null && quantity !== void 0 ? quantity : 0) < (quantityInBasket || 1)) {
68
+ if (quantity - (quantityInBasket || 0) < 1) {
69
69
  setStatus(ProductQuantityStatusEnum.MaxQuantityReached);
70
70
  return;
71
71
  }
@@ -221,16 +221,26 @@ 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 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];
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];
227
237
  };
228
238
  var getCustomFieldValue = function getCustomFieldValue(field) {
229
239
  return customFields === null || customFields === void 0 ? void 0 : customFields[field];
230
240
  };
231
241
  var getCombinationsForAttributeRule = function getCombinationsForAttributeRule(key, 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];
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];
234
244
  return result;
235
245
  };
236
246
  var ref5 = _slicedToArray(React.useState(false), 2), mounted = ref5[0], setMounted = ref5[1];
@@ -238,7 +248,7 @@ export function ProductProvider(param) {
238
248
  var ref3 = _slicedToArray(React.useState(getVariantsWithInventory), 2), variants = ref3[0], setVariants = ref3[1];
239
249
  var ref4 = _slicedToArray(React.useState(getDefaultVariant), 2), selectedVariant = ref4[0], setSelectedVariant = ref4[1];
240
250
  var metaData = React.useMemo(function() {
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;
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;
242
252
  var rootCategory = product === null || product === void 0 ? void 0 : (ref = product.categories) === null || ref === void 0 ? void 0 : ref[0];
243
253
  var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
244
254
  var metaObj = {
@@ -248,24 +258,24 @@ export function ProductProvider(param) {
248
258
  description: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
249
259
  shortDescription: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
250
260
  brand: {
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
261
+ _id: 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 : ref14.resourceId,
262
+ name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref15 = product.brands) === null || ref15 === void 0 ? void 0 : (ref16 = ref15[0]) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.resource) === null || ref17 === void 0 ? void 0 : ref17.name),
263
+ slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref18 = product.brands) === null || ref18 === void 0 ? void 0 : (ref19 = ref18[0]) === null || ref19 === void 0 ? void 0 : (ref20 = ref19.resource) === null || ref20 === void 0 ? void 0 : ref20.slug),
264
+ logo: 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 : (ref24 = ref23.assets) === null || ref24 === void 0 ? void 0 : (ref25 = ref24[0]) === null || ref25 === void 0 ? void 0 : (ref26 = ref25.sources) === null || ref26 === void 0 ? void 0 : (ref27 = ref26[0]) === null || ref27 === void 0 ? void 0 : ref27.url
255
265
  },
256
266
  category: {
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)
267
+ _id: product === null || product === void 0 ? void 0 : (ref29 = product.categories) === null || ref29 === void 0 ? void 0 : (ref30 = ref29[(product === null || product === void 0 ? void 0 : (ref28 = product.categories) === null || ref28 === void 0 ? void 0 : ref28.length) - 1]) === null || ref30 === void 0 ? void 0 : ref30.resourceId,
268
+ name: getTranslatableField(product === null || product === void 0 ? void 0 : (ref32 = product.categories) === null || ref32 === void 0 ? void 0 : (ref33 = ref32[(product === null || product === void 0 ? void 0 : (ref31 = product.categories) === null || ref31 === void 0 ? void 0 : ref31.length) - 1]) === null || ref33 === void 0 ? void 0 : (ref34 = ref33.resource) === null || ref34 === void 0 ? void 0 : ref34.name),
269
+ slug: getTranslatableField(product === null || product === void 0 ? void 0 : (ref36 = product.categories) === null || ref36 === void 0 ? void 0 : (ref37 = ref36[(product === null || product === void 0 ? void 0 : (ref35 = product.categories) === null || ref35 === void 0 ? void 0 : ref35.length) - 1]) === null || ref37 === void 0 ? void 0 : (ref38 = ref37.resource) === null || ref38 === void 0 ? void 0 : ref38.slug)
260
270
  },
261
271
  rootCategory: {
262
272
  _id: rootCategoryId,
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)
273
+ name: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref39 = rootCategory.resource) === null || ref39 === void 0 ? void 0 : ref39.name),
274
+ slug: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (ref40 = rootCategory.resource) === null || ref40 === void 0 ? void 0 : ref40.slug)
265
275
  },
266
276
  categories: formatCategories(product === null || product === void 0 ? void 0 : product.categories, rootCategoryId),
267
277
  reviewRatingStatistics: product === null || product === void 0 ? void 0 : product.reviewRatingStatistics,
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),
278
+ content: Boolean(selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref41 = selectedVariant.content) === null || ref41 === void 0 ? void 0 : ref41.map(createProductContent).length) ? selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref42 = selectedVariant.content) === null || ref42 === void 0 ? void 0 : ref42.map(createProductContent) : product === null || product === void 0 ? void 0 : (ref43 = product.content) === null || ref43 === void 0 ? void 0 : ref43.map(createProductContent),
269
279
  assets: assetsFieldsToMap(product === null || product === void 0 ? void 0 : product.assets)
270
280
  };
271
281
  return metaObj;
@@ -51,7 +51,7 @@ function _prefetchCategories() {
51
51
  predicate: predicate,
52
52
  slug: aliasedSlug,
53
53
  aggregates: aggregates,
54
- postFilter: undefined,
54
+ postFilter: getPostFilters(router),
55
55
  config: config
56
56
  });
57
57
  _ctx.next = 5;
@@ -0,0 +1,8 @@
1
+ import { canUseDOM } from './canUseDom';
2
+ export var getLocaleFromPath = function() {
3
+ if (!canUseDOM()) return '';
4
+ var locale = window.location.pathname.split('/')[1] || '';
5
+ // the allowed standards: bg bg-BG, en en-US/en-UK
6
+ if (locale.length !== 2 && locale.length !== 5) return '';
7
+ return locale;
8
+ };
@@ -13,6 +13,7 @@ export * from './getTranslatableField';
13
13
  export * from './formatAsCurrency';
14
14
  export * from './createCatalogBreadcrumb';
15
15
  export * from './adjustColor';
16
+ export * from './getLocaleFromPath';
16
17
  export * from './calcDiscount';
17
18
  export * from './canUseDom';
18
19
  export * from './getFirst';
@@ -1,3 +1,4 @@
1
+ import { canUseDOM } from "./canUseDom";
1
2
  export function isTouchDevice() {
2
- return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
3
+ return canUseDOM() && ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
3
4
  }
@@ -0,0 +1 @@
1
+ export declare const getLocaleFromPath: () => string;
@@ -13,6 +13,7 @@ export * from './getTranslatableField';
13
13
  export * from './formatAsCurrency';
14
14
  export * from './createCatalogBreadcrumb';
15
15
  export * from './adjustColor';
16
+ export * from './getLocaleFromPath';
16
17
  export * from './calcDiscount';
17
18
  export * from './canUseDom';
18
19
  export * from './getFirst';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.12.96",
4
+ "version": "0.12.100",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "857da38c2eb402b3d8a51ad70ffbb5dc770febff",
34
+ "gitHead": "154b2ef905a065ffd2705510e779c4101004a42d",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.12.96",
40
- "@sentecacommerce-theme/cms": "^0.12.96",
39
+ "@sentecacommerce-theme/base": "^0.12.100",
40
+ "@sentecacommerce-theme/cms": "^0.12.100",
41
41
  "@sentecacommerce/sdk": "2.0.161",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",