@sentecacommerce-theme/lib 0.12.98 → 0.12.99
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/dist/cjs/hooks/useAvailability/index.js +1 -1
- package/dist/cjs/hooks/useProduct/index.js +15 -5
- package/dist/cjs/listing/ssr/prefetchCategories.js +1 -1
- package/dist/esm/hooks/useAvailability/index.js +1 -1
- package/dist/esm/hooks/useProduct/index.js +26 -16
- package/dist/esm/listing/ssr/prefetchCategories.js +1 -1
- package/package.json +4 -4
@@ -70,7 +70,7 @@ var useAvailability = function(param) {
|
|
70
70
|
setStatus(ProductQuantityStatusEnum.OutOfStock);
|
71
71
|
return;
|
72
72
|
}
|
73
|
-
if (
|
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
|
321
|
-
var
|
322
|
-
|
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,
|
329
|
-
var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (
|
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);
|
@@ -65,7 +65,7 @@ export var useAvailability = function(param) {
|
|
65
65
|
setStatus(ProductQuantityStatusEnum.OutOfStock);
|
66
66
|
return;
|
67
67
|
}
|
68
|
-
if (
|
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
|
225
|
-
var
|
226
|
-
|
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,
|
233
|
-
var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (
|
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,
|
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 : (
|
252
|
-
name: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
253
|
-
slug: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
254
|
-
logo: product === null || product === void 0 ? void 0 : (
|
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 : (
|
258
|
-
name: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
259
|
-
slug: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
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 : (
|
264
|
-
slug: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (
|
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 : (
|
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;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.99",
|
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": "
|
34
|
+
"gitHead": "d6b1f3475733f0402697b241e884628656aadf92",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.12.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.12.
|
39
|
+
"@sentecacommerce-theme/base": "^0.12.99",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.12.99",
|
41
41
|
"@sentecacommerce/sdk": "2.0.161",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|