@sentecacommerce-theme/lib 0.14.9 → 0.14.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/CHANGELOG.md +3 -196
  2. package/dist/cjs/components/Drawer/index.js +6 -6
  3. package/dist/cjs/contexts/CheckoutForm/utils/validateShipping.js +11 -7
  4. package/dist/cjs/hooks/CompareContext/CompareContext.js +141 -0
  5. package/dist/cjs/hooks/CompareContext/index.js +22 -0
  6. package/dist/cjs/hooks/useCheckoutShippingModule/index.js +4 -2
  7. package/dist/cjs/index.js +16 -4
  8. package/dist/cjs/navigation/components/SearchBox/Components/Products/index.js +2 -2
  9. package/dist/cjs/navigation/components/SearchBox/index.js +2 -1
  10. package/dist/cjs/seo/components/ProductSEO/index.js +1 -1
  11. package/dist/cjs/user/api/utils/processLoginPayload.js +5 -4
  12. package/dist/cjs/utils/index.js +0 -12
  13. package/dist/cjs/utils/tokens.js +1 -1
  14. package/dist/esm/build/api/query/fetchStore.js +1 -1
  15. package/dist/esm/components/Drawer/index.js +6 -6
  16. package/dist/esm/contexts/CheckoutForm/utils/validateShipping.js +11 -7
  17. package/dist/esm/hooks/CompareContext/CompareContext.js +114 -0
  18. package/dist/esm/hooks/CompareContext/index.js +1 -0
  19. package/dist/esm/hooks/basket-hooks/useBasketTotalPrice/index.js +1 -1
  20. package/dist/esm/hooks/ui-hooks/useSlideshow/index.js +1 -1
  21. package/dist/esm/hooks/useCheckoutShippingModule/index.js +4 -2
  22. package/dist/esm/index.js +1 -0
  23. package/dist/esm/navigation/components/SearchBox/Components/Products/index.js +2 -2
  24. package/dist/esm/navigation/components/SearchBox/index.js +2 -1
  25. package/dist/esm/seo/components/ProductSEO/index.js +1 -1
  26. package/dist/esm/user/api/utils/processLoginPayload.js +6 -5
  27. package/dist/esm/utils/index.js +0 -1
  28. package/dist/esm/utils/isTouchDevice.js +1 -1
  29. package/dist/esm/utils/tokens.js +1 -1
  30. package/dist/esm/webview/hooks/useIsInWebview.js +3 -3
  31. package/dist/esm/webview/utils/sendMessage.js +1 -1
  32. package/dist/types/hooks/CompareContext/CompareContext.d.ts +16 -0
  33. package/dist/types/hooks/CompareContext/index.d.ts +1 -0
  34. package/dist/types/hooks/ui-hooks/useUI/index.d.ts +4 -1
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/listing/utils/extendFilter.d.ts +1 -1
  37. package/dist/types/navigation/components/SearchBox/Components/Products/index.d.ts +2 -1
  38. package/dist/types/user/hooks/useResetPassword.d.ts +1 -1
  39. package/dist/types/utils/index.d.ts +0 -1
  40. package/dist/types/utils/tokens.d.ts +4 -9
  41. package/package.json +4 -4
  42. package/dist/cjs/utils/convertDateIntoRemainingDays.js +0 -10
  43. package/dist/esm/utils/convertDateIntoRemainingDays.js +0 -5
  44. package/dist/types/utils/convertDateIntoRemainingDays.d.ts +0 -1
@@ -31,7 +31,7 @@ function _templateObject() {
31
31
  return data;
32
32
  }
33
33
  var Products = function(param) {
34
- var data = param.data, bottomMenu = param.bottomMenu, priceColor = param.priceColor, textColor = param.textColor, labelsColor = param.labelsColor, onClose = param.onClose, backgroundColor = param.backgroundColor, title = param.title, offers = param.offers, productSpacing = param.productSpacing;
34
+ var data = param.data, bottomMenu = param.bottomMenu, priceColor = param.priceColor, textColor = param.textColor, labelsColor = param.labelsColor, onClose = param.onClose, backgroundColor = param.backgroundColor, title = param.title, offers = param.offers, productSpacing = param.productSpacing, noResults = param.noResults;
35
35
  return(/*#__PURE__*/ _react.default.createElement(_.Container, {
36
36
  backgroundColor: backgroundColor,
37
37
  labelsColor: labelsColor,
@@ -52,7 +52,7 @@ var Products = function(param) {
52
52
  offers: offers,
53
53
  productSpacing: productSpacing
54
54
  }));
55
- })) : /*#__PURE__*/ _react.default.createElement(NoResultsDesc, null, "No results found")));
55
+ })) : /*#__PURE__*/ _react.default.createElement(NoResultsDesc, null, noResults ? noResults : 'No results found')));
56
56
  };
57
57
  exports.Products = Products;
58
58
  var NoResultsDesc = _styledComponents.default.p(_templateObject());
@@ -224,7 +224,8 @@ var SearchBox = function(param) {
224
224
  textColor: textColor,
225
225
  onClose: onClose,
226
226
  backgroundColor: backgroundColor,
227
- productSpacing: productSpacing
227
+ productSpacing: productSpacing,
228
+ noResults: labels === null || labels === void 0 ? void 0 : labels.noResults
228
229
  }), bottomMenu === BottomMenuEnum.promo && promoOffers && /*#__PURE__*/ _react.default.createElement(_components.Products, {
229
230
  data: promoOffers,
230
231
  title: labels.promoOffers,
@@ -58,7 +58,7 @@ function ProductSEO() {
58
58
  };
59
59
  var formattedDescription = favorDescriptionTemplateOverMeta ? createTemplate(descriptionTemplate) : seoData.description || createTemplate(descriptionTemplate);
60
60
  var formattedTitle = favorTitleTemplateOverMeta ? createTemplate(titleTemplate) : seoData.title || createTemplate(titleTemplate);
61
- var productJSONLd = "{\n \"@context\": \"https://schema.org\",\n \"@type\": \"Product\",\n \"name\": \"".concat(formattedTitle, "\",\n \"image\": [").concat(generateImage(image), "],\n \"description\": \"").concat(formattedDescription, "\",\n \"sku\": \"").concat((selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.sku) || '', "\",\n ").concat(brandName ? "\"brand\": {\n \"@type\": \"Brand\",\n \"name\": \"".concat(brandName, "\"\n },") : '', "\n ").concat(hasRating ? "\"aggregateRating\": {\n \"@type\": \"AggregateRating\",\n \"ratingValue\": \"".concat((ref13 = metaData.reviewRatingStatistics) === null || ref13 === void 0 ? void 0 : ref13.averageRating, "\",\n \"reviewCount\": \"").concat((ref14 = metaData.reviewRatingStatistics) === null || ref14 === void 0 ? void 0 : ref14.count, "\"\n },") : '', "\n \"offers\": {\n \"@type\": \"Offer\",\n \"priceCurrency\": \"").concat(currencyCode, "\",\n \"price\": \"").concat(price.value, "\",\n \"itemCondition\": \"").concat(itemCondition, "\",\n \"availability\": \"").concat(availability, "\"\n }\n }");
61
+ var productJSONLd = "{\n \"@context\": \"https://schema.org\",\n \"@type\": \"Product\",\n \"name\": \"".concat(formattedTitle.replaceAll('"', '″'), "\",\n \"image\": [").concat(generateImage(image), "],\n \"description\": \"").concat(formattedDescription.replaceAll('"', '″'), "\",\n \"sku\": \"").concat((selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.sku) || '', "\",\n ").concat(brandName ? "\"brand\": {\n \"@type\": \"Brand\",\n \"name\": \"".concat(brandName, "\"\n },") : '', "\n ").concat(hasRating ? "\"aggregateRating\": {\n \"@type\": \"AggregateRating\",\n \"ratingValue\": \"".concat((ref13 = metaData.reviewRatingStatistics) === null || ref13 === void 0 ? void 0 : ref13.averageRating, "\",\n \"reviewCount\": \"").concat((ref14 = metaData.reviewRatingStatistics) === null || ref14 === void 0 ? void 0 : ref14.count, "\"\n },") : '', "\n \"offers\": {\n \"@type\": \"Offer\",\n \"priceCurrency\": \"").concat(currencyCode, "\",\n \"price\": \"").concat(price.value, "\",\n \"itemCondition\": \"").concat(itemCondition, "\",\n \"availability\": \"").concat(availability, "\"\n }\n }");
62
62
  return(/*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_head.default, null, /*#__PURE__*/ _react.default.createElement("script", {
63
63
  type: "application/ld+json",
64
64
  dangerouslySetInnerHTML: (0, _utils).createDangerousMarkup(productJSONLd)
@@ -8,17 +8,18 @@ var _utils = require("../../../utils");
8
8
  var processLoginPayload = function(data) {
9
9
  var anonymous = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
10
10
  var accessTokenExpires = data.expires;
11
- var refreshTokenExpires = data.refreshTokenExpires;
11
+ var _refreshTokenExpires;
12
+ var refreshTokenExpires = (_refreshTokenExpires = data.refreshTokenExpires) !== null && _refreshTokenExpires !== void 0 ? _refreshTokenExpires : accessTokenExpires;
12
13
  (0, _utils).writeToLocalStorage(_wishlistApi.WISHLIST_STORAGE_KEY, data.wishList);
13
14
  (0, _utils).writeToLocalStorage(_myCartApi.BASKET_STORAGE_KEY, data.basket);
14
15
  (0, _utils).setAccessToken(data.accessToken, anonymous, {
15
- expires: (0, _utils).convertDateIntoRemainingDays(new Date(), new Date(accessTokenExpires))
16
+ expires: new Date(accessTokenExpires)
16
17
  });
17
18
  (0, _utils).setExpiryToken(data.expires, {
18
- expires: (0, _utils).convertDateIntoRemainingDays(new Date(), new Date(refreshTokenExpires))
19
+ expires: new Date(refreshTokenExpires)
19
20
  });
20
21
  (0, _utils).setRefreshToken(data.refreshToken, {
21
- expires: (0, _utils).convertDateIntoRemainingDays(new Date(), new Date(refreshTokenExpires))
22
+ expires: new Date(refreshTokenExpires)
22
23
  });
23
24
  !anonymous && (0, _utils).removeAnonToken();
24
25
  };
@@ -410,18 +410,6 @@ Object.keys(_transliterate).forEach(function(key) {
410
410
  }
411
411
  });
412
412
  });
413
- var _convertDateIntoRemainingDays = _interopRequireWildcard(require("./convertDateIntoRemainingDays"));
414
- Object.keys(_convertDateIntoRemainingDays).forEach(function(key) {
415
- if (key === "default" || key === "__esModule") return;
416
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
417
- if (key in exports && exports[key] === _convertDateIntoRemainingDays[key]) return;
418
- Object.defineProperty(exports, key, {
419
- enumerable: true,
420
- get: function() {
421
- return _convertDateIntoRemainingDays[key];
422
- }
423
- });
424
- });
425
413
  var _prefetchSDKConfig = _interopRequireWildcard(require("./prefetchSDKConfig"));
426
414
  Object.keys(_prefetchSDKConfig).forEach(function(key) {
427
415
  if (key === "default" || key === "__esModule") return;
@@ -93,7 +93,7 @@ var setAccessToken = function(token, anonymous, options) {
93
93
  };
94
94
  exports.setAccessToken = setAccessToken;
95
95
  var setRefreshToken = function(token, options) {
96
- _jsCookie.default.set(REFRESH_TOKEN_KEY, token, options);
96
+ token && _jsCookie.default.set(REFRESH_TOKEN_KEY, token, options);
97
97
  };
98
98
  exports.setRefreshToken = setRefreshToken;
99
99
  var setExpiryToken = function(timestamp, options) {
@@ -1,5 +1,5 @@
1
1
  import regeneratorRuntime from "regenerator-runtime";
2
- import { Configuration, StoresAPI } from "@sentecacommerce/sdk";
2
+ import { Configuration, StoresAPI } from '@sentecacommerce/sdk';
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4
4
  try {
5
5
  var info = gen[key](arg);
@@ -96,10 +96,10 @@ function _templateObject7() {
96
96
  }
97
97
  function _templateObject8() {
98
98
  var data = _taggedTemplateLiteral([
99
- "\n width: 100%;\n height: 100vh;\n position: fixed;\n left: 0;\n top: 0;\n background-color:",
100
- ";\n animation: ",
101
- "ms;\n opacity: ",
102
- ";\n "
99
+ "\n width: 100%;\n height: 100vh;\n position: fixed;\n left: 0;\n top: 0;\n background-color: ",
100
+ ";\n animation: ",
101
+ "ms;\n opacity: ",
102
+ ";\n "
103
103
  ]);
104
104
  _templateObject8 = function _templateObject8() {
105
105
  return data;
@@ -108,8 +108,8 @@ function _templateObject8() {
108
108
  }
109
109
  function _templateObject9() {
110
110
  var data = _taggedTemplateLiteral([
111
- "\n",
112
- ";\n "
111
+ "\n ",
112
+ ";\n"
113
113
  ]);
114
114
  _templateObject9 = function _templateObject9() {
115
115
  return data;
@@ -95,8 +95,12 @@ export function genericOfficeValidation(param) {
95
95
  }
96
96
  export function pickupFromStoreValidation(param) {
97
97
  var mod = param.mod, errorLabels = param.errorLabels;
98
- var ref;
99
- return !(mod === null || mod === void 0 ? void 0 : (ref = mod.moduleData) === null || ref === void 0 ? void 0 : ref.stockLocation) ? {
98
+ var ref, ref12;
99
+ // Returning undefined means validation is passed
100
+ if (mod === null || mod === void 0 ? void 0 : (ref = mod.moduleData) === null || ref === void 0 ? void 0 : ref.isWarehouseShipping) {
101
+ return undefined;
102
+ }
103
+ return !(mod === null || mod === void 0 ? void 0 : (ref12 = mod.moduleData) === null || ref12 === void 0 ? void 0 : ref12.stockLocation) ? {
100
104
  pickupFromStore: errorLabels.noStoreSelected
101
105
  } : undefined;
102
106
  }
@@ -125,8 +129,8 @@ export function validateShipping(data, mod, errorLabels, validations) {
125
129
  var requiredFields = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : defaultRequiredFields, enableNoShippingMethodMode = arguments.length > 5 ? arguments[5] : void 0;
126
130
  var validateErrors = {};
127
131
  var globalErrors = requiredFields.reduce(function(errors, field) {
128
- var ref, ref13;
129
- if (!(data === null || data === void 0 ? void 0 : (ref = data[field]) === null || ref === void 0 ? void 0 : (ref13 = ref.trim) === null || ref13 === void 0 ? void 0 : ref13.call(ref))) {
132
+ var ref, ref14;
133
+ if (!(data === null || data === void 0 ? void 0 : (ref = data[field]) === null || ref === void 0 ? void 0 : (ref14 = ref.trim) === null || ref14 === void 0 ? void 0 : ref14.call(ref))) {
130
134
  return _objectSpread({}, errors, _defineProperty({}, field, errorLabels.fieldIsRequired));
131
135
  }
132
136
  return errors;
@@ -138,13 +142,13 @@ export function validateShipping(data, mod, errorLabels, validations) {
138
142
  globalErrors.phoneNumber = (errorLabels === null || errorLabels === void 0 ? void 0 : errorLabels.invalidPhoneNumber) || '';
139
143
  }
140
144
  if (!enableNoShippingMethodMode) {
141
- var ref14, ref12;
142
- if (!(mod === null || mod === void 0 ? void 0 : mod.moduleKey) || !(mod === null || mod === void 0 ? void 0 : (ref14 = mod.moduleData) === null || ref14 === void 0 ? void 0 : ref14.methodKey)) {
145
+ var ref15, ref13;
146
+ if (!(mod === null || mod === void 0 ? void 0 : mod.moduleKey) || !(mod === null || mod === void 0 ? void 0 : (ref15 = mod.moduleData) === null || ref15 === void 0 ? void 0 : ref15.methodKey)) {
143
147
  return _objectSpread({}, globalErrors, {
144
148
  courier: errorLabels.selectCourier
145
149
  });
146
150
  }
147
- var validate = (ref12 = validations[mod === null || mod === void 0 ? void 0 : mod.moduleKey]) === null || ref12 === void 0 ? void 0 : ref12[mod === null || mod === void 0 ? void 0 : mod.moduleData.methodKey];
151
+ var validate = (ref13 = validations[mod === null || mod === void 0 ? void 0 : mod.moduleKey]) === null || ref13 === void 0 ? void 0 : ref13[mod === null || mod === void 0 ? void 0 : mod.moduleData.methodKey];
148
152
  if (!validate) {
149
153
  throw new Error("Validation for shipping with provider: ".concat(mod === null || mod === void 0 ? void 0 : mod.moduleKey, " and method key: ").concat(mod === null || mod === void 0 ? void 0 : mod.moduleData.methodKey, " not found"));
150
154
  }
@@ -0,0 +1,114 @@
1
+ import React, { useState } from 'react';
2
+ function _arrayLikeToArray(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _arrayWithHoles(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _iterableToArrayLimit(arr, i) {
11
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
+ if (_i == null) return;
13
+ var _arr = [];
14
+ var _n = true;
15
+ var _d = false;
16
+ var _s, _e;
17
+ try {
18
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
19
+ _arr.push(_s.value);
20
+ if (i && _arr.length === i) break;
21
+ }
22
+ } catch (err) {
23
+ _d = true;
24
+ _e = err;
25
+ } finally{
26
+ try {
27
+ if (!_n && _i["return"] != null) _i["return"]();
28
+ } finally{
29
+ if (_d) throw _e;
30
+ }
31
+ }
32
+ return _arr;
33
+ }
34
+ function _nonIterableRest() {
35
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
+ }
37
+ function _slicedToArray(arr, i) {
38
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
39
+ }
40
+ function _unsupportedIterableToArray(o, minLen) {
41
+ if (!o) return;
42
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
43
+ var n = Object.prototype.toString.call(o).slice(8, -1);
44
+ if (n === "Object" && o.constructor) n = o.constructor.name;
45
+ if (n === "Map" || n === "Set") return Array.from(n);
46
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
47
+ }
48
+ var CompareContextState = /*#__PURE__*/ React.createContext(undefined);
49
+ var CompareContextFunctions = /*#__PURE__*/ React.createContext(undefined);
50
+ export function CompareContextProvider(param) {
51
+ var children = param.children;
52
+ var ref = _slicedToArray(useState([]), 2), itemsToCompare = ref[0], setItemsToCompare = ref[1];
53
+ // notAllowedState is needed in order to trigger rerender in useEffect dependency on the client
54
+ // it allow us to know that we try to add more items than allowed
55
+ var ref1 = _slicedToArray(useState(0), 2), notAllowedState = ref1[0], setNotAllowedState = ref1[1];
56
+ var itemAlreadyAdded = function(id) {
57
+ return itemsToCompare.filter(function(i) {
58
+ return i._id === id;
59
+ }).length !== 0;
60
+ };
61
+ var addItemToCompare = function(item, maxItemLength) {
62
+ var alreadyAdded = itemAlreadyAdded(item._id);
63
+ if (alreadyAdded) {
64
+ return;
65
+ }
66
+ if (itemsToCompare.length === maxItemLength) {
67
+ setNotAllowedState(notAllowedState + 1);
68
+ return;
69
+ }
70
+ if (itemsToCompare.length < maxItemLength) {
71
+ itemsToCompare.push(item);
72
+ setNotAllowedState(0);
73
+ setItemsToCompare(itemsToCompare);
74
+ }
75
+ };
76
+ var removeComparedItem = function(id) {
77
+ var filtered = itemsToCompare.filter(function(i) {
78
+ return i._id !== id;
79
+ });
80
+ setItemsToCompare(filtered);
81
+ };
82
+ var removeAllComparedItems = function() {
83
+ return setItemsToCompare([]);
84
+ };
85
+ var notAllowed = function() {
86
+ return notAllowedState;
87
+ };
88
+ var functions = {
89
+ itemAlreadyAdded: itemAlreadyAdded,
90
+ addItemToCompare: addItemToCompare,
91
+ removeComparedItem: removeComparedItem,
92
+ removeAllComparedItems: removeAllComparedItems,
93
+ notAllowed: notAllowed
94
+ };
95
+ return(/*#__PURE__*/ React.createElement(CompareContextState.Provider, {
96
+ value: itemsToCompare
97
+ }, /*#__PURE__*/ React.createElement(CompareContextFunctions.Provider, {
98
+ value: functions
99
+ }, children)));
100
+ }
101
+ export function useCompareState() {
102
+ var context = React.useContext(CompareContextState);
103
+ if (context === undefined) {
104
+ throw new Error('CompareContextState must be used within a CompareContextProvider');
105
+ }
106
+ return context;
107
+ }
108
+ export function useCompareFunctions() {
109
+ var context = React.useContext(CompareContextFunctions);
110
+ if (context === undefined) {
111
+ throw new Error('CompareContextFunctions must be used within a CompareContextProvider');
112
+ }
113
+ return context;
114
+ }
@@ -0,0 +1 @@
1
+ export { CompareContextProvider, useCompareState, useCompareFunctions } from './CompareContext';
@@ -1,4 +1,4 @@
1
- import { myCartApi } from "../../../api/myCartApi";
1
+ import { myCartApi } from '../../../api/myCartApi';
2
2
  // Price with shipping included
3
3
  export var useBasketTotalPrice = function() {
4
4
  var data = myCartApi.useGet().data;
@@ -1,4 +1,4 @@
1
- import { useEffect, useState } from "react";
1
+ import { useEffect, useState } from 'react';
2
2
  function _arrayLikeToArray(arr, len) {
3
3
  if (len == null || len > arr.length) len = arr.length;
4
4
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -31,13 +31,15 @@ export var useCheckoutShippingModule = function(orderQuery) {
31
31
  var isEnabled = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
32
32
  var cartData = orderQuery.data;
33
33
  return useMemo(function() {
34
- var ref;
34
+ var ref, ref1;
35
35
  if (!isEnabled) return;
36
36
  var shipping = cartData === null || cartData === void 0 ? void 0 : (ref = cartData.shippings) === null || ref === void 0 ? void 0 : ref[0];
37
37
  return {
38
38
  moduleKey: shipping === null || shipping === void 0 ? void 0 : shipping.moduleKey,
39
39
  moduleData: _objectSpread({}, shipping === null || shipping === void 0 ? void 0 : shipping.moduleData, {
40
- methodKey: shipping === null || shipping === void 0 ? void 0 : shipping.moduleMethodKey
40
+ methodKey: shipping === null || shipping === void 0 ? void 0 : shipping.moduleMethodKey,
41
+ // Special case of warehouse for christian of roma
42
+ isWarehouseShipping: (shipping === null || shipping === void 0 ? void 0 : shipping.moduleKey) === 'PickUpFromStore' && (shipping === null || shipping === void 0 ? void 0 : (ref1 = shipping.merchant) === null || ref1 === void 0 ? void 0 : ref1.resourceKey) === 'christian-of-roma'
41
43
  })
42
44
  };
43
45
  }, [
package/dist/esm/index.js CHANGED
@@ -93,6 +93,7 @@ export * from './hooks/useProgressBar';
93
93
  export * from './hooks/useCatalogDiscounts';
94
94
  export * from './hooks/useLocalRating';
95
95
  export * from './hooks/useProductVariants/types';
96
+ export * from './hooks/CompareContext/';
96
97
  // Utils
97
98
  export * from './utils';
98
99
  export * from './types';
@@ -22,7 +22,7 @@ function _templateObject() {
22
22
  return data;
23
23
  }
24
24
  export var Products = function(param) {
25
- var data = param.data, bottomMenu = param.bottomMenu, priceColor = param.priceColor, textColor = param.textColor, labelsColor = param.labelsColor, onClose = param.onClose, backgroundColor = param.backgroundColor, title = param.title, offers = param.offers, productSpacing = param.productSpacing;
25
+ var data = param.data, bottomMenu = param.bottomMenu, priceColor = param.priceColor, textColor = param.textColor, labelsColor = param.labelsColor, onClose = param.onClose, backgroundColor = param.backgroundColor, title = param.title, offers = param.offers, productSpacing = param.productSpacing, noResults = param.noResults;
26
26
  return(/*#__PURE__*/ React.createElement(Container, {
27
27
  backgroundColor: backgroundColor,
28
28
  labelsColor: labelsColor,
@@ -43,6 +43,6 @@ export var Products = function(param) {
43
43
  offers: offers,
44
44
  productSpacing: productSpacing
45
45
  }));
46
- })) : /*#__PURE__*/ React.createElement(NoResultsDesc, null, "No results found")));
46
+ })) : /*#__PURE__*/ React.createElement(NoResultsDesc, null, noResults ? noResults : 'No results found')));
47
47
  };
48
48
  var NoResultsDesc = styled.p(_templateObject());
@@ -194,7 +194,8 @@ export var SearchBox = function(param) {
194
194
  textColor: textColor,
195
195
  onClose: onClose,
196
196
  backgroundColor: backgroundColor,
197
- productSpacing: productSpacing
197
+ productSpacing: productSpacing,
198
+ noResults: labels === null || labels === void 0 ? void 0 : labels.noResults
198
199
  }), bottomMenu === BottomMenuEnum.promo && promoOffers && /*#__PURE__*/ React.createElement(Products, {
199
200
  data: promoOffers,
200
201
  title: labels.promoOffers,
@@ -48,7 +48,7 @@ export function ProductSEO() {
48
48
  };
49
49
  var formattedDescription = favorDescriptionTemplateOverMeta ? createTemplate(descriptionTemplate) : seoData.description || createTemplate(descriptionTemplate);
50
50
  var formattedTitle = favorTitleTemplateOverMeta ? createTemplate(titleTemplate) : seoData.title || createTemplate(titleTemplate);
51
- var productJSONLd = "{\n \"@context\": \"https://schema.org\",\n \"@type\": \"Product\",\n \"name\": \"".concat(formattedTitle, "\",\n \"image\": [").concat(generateImage(image), "],\n \"description\": \"").concat(formattedDescription, "\",\n \"sku\": \"").concat((selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.sku) || '', "\",\n ").concat(brandName ? "\"brand\": {\n \"@type\": \"Brand\",\n \"name\": \"".concat(brandName, "\"\n },") : '', "\n ").concat(hasRating ? "\"aggregateRating\": {\n \"@type\": \"AggregateRating\",\n \"ratingValue\": \"".concat((ref13 = metaData.reviewRatingStatistics) === null || ref13 === void 0 ? void 0 : ref13.averageRating, "\",\n \"reviewCount\": \"").concat((ref14 = metaData.reviewRatingStatistics) === null || ref14 === void 0 ? void 0 : ref14.count, "\"\n },") : '', "\n \"offers\": {\n \"@type\": \"Offer\",\n \"priceCurrency\": \"").concat(currencyCode, "\",\n \"price\": \"").concat(price.value, "\",\n \"itemCondition\": \"").concat(itemCondition, "\",\n \"availability\": \"").concat(availability, "\"\n }\n }");
51
+ var productJSONLd = "{\n \"@context\": \"https://schema.org\",\n \"@type\": \"Product\",\n \"name\": \"".concat(formattedTitle.replaceAll('"', '″'), "\",\n \"image\": [").concat(generateImage(image), "],\n \"description\": \"").concat(formattedDescription.replaceAll('"', '″'), "\",\n \"sku\": \"").concat((selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.sku) || '', "\",\n ").concat(brandName ? "\"brand\": {\n \"@type\": \"Brand\",\n \"name\": \"".concat(brandName, "\"\n },") : '', "\n ").concat(hasRating ? "\"aggregateRating\": {\n \"@type\": \"AggregateRating\",\n \"ratingValue\": \"".concat((ref13 = metaData.reviewRatingStatistics) === null || ref13 === void 0 ? void 0 : ref13.averageRating, "\",\n \"reviewCount\": \"").concat((ref14 = metaData.reviewRatingStatistics) === null || ref14 === void 0 ? void 0 : ref14.count, "\"\n },") : '', "\n \"offers\": {\n \"@type\": \"Offer\",\n \"priceCurrency\": \"").concat(currencyCode, "\",\n \"price\": \"").concat(price.value, "\",\n \"itemCondition\": \"").concat(itemCondition, "\",\n \"availability\": \"").concat(availability, "\"\n }\n }");
52
52
  return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Head, null, /*#__PURE__*/ React.createElement("script", {
53
53
  type: "application/ld+json",
54
54
  dangerouslySetInnerHTML: createDangerousMarkup(productJSONLd)
@@ -1,20 +1,21 @@
1
1
  import { WISHLIST_STORAGE_KEY } from '../../../api/wishlistApi';
2
2
  import { BASKET_STORAGE_KEY } from '../../../api/myCartApi';
3
- import { writeToLocalStorage, setAccessToken, setExpiryToken, setRefreshToken, removeAnonToken, convertDateIntoRemainingDays } from '../../../utils';
3
+ import { removeAnonToken, setAccessToken, setExpiryToken, setRefreshToken, writeToLocalStorage } from '../../../utils';
4
4
  export var processLoginPayload = function(data) {
5
5
  var anonymous = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
6
6
  var accessTokenExpires = data.expires;
7
- var refreshTokenExpires = data.refreshTokenExpires;
7
+ var _refreshTokenExpires;
8
+ var refreshTokenExpires = (_refreshTokenExpires = data.refreshTokenExpires) !== null && _refreshTokenExpires !== void 0 ? _refreshTokenExpires : accessTokenExpires;
8
9
  writeToLocalStorage(WISHLIST_STORAGE_KEY, data.wishList);
9
10
  writeToLocalStorage(BASKET_STORAGE_KEY, data.basket);
10
11
  setAccessToken(data.accessToken, anonymous, {
11
- expires: convertDateIntoRemainingDays(new Date(), new Date(accessTokenExpires))
12
+ expires: new Date(accessTokenExpires)
12
13
  });
13
14
  setExpiryToken(data.expires, {
14
- expires: convertDateIntoRemainingDays(new Date(), new Date(refreshTokenExpires))
15
+ expires: new Date(refreshTokenExpires)
15
16
  });
16
17
  setRefreshToken(data.refreshToken, {
17
- expires: convertDateIntoRemainingDays(new Date(), new Date(refreshTokenExpires))
18
+ expires: new Date(refreshTokenExpires)
18
19
  });
19
20
  !anonymous && removeAnonToken();
20
21
  };
@@ -47,5 +47,4 @@ export * from './getDistance';
47
47
  export * from './getPagination';
48
48
  export * from './validations';
49
49
  export * from './transliterate';
50
- export * from './convertDateIntoRemainingDays';
51
50
  export * from './prefetchSDKConfig';
@@ -1,4 +1,4 @@
1
- import { canUseDOM } from "./canUseDom";
1
+ import { canUseDOM } from './canUseDom';
2
2
  export function isTouchDevice() {
3
3
  return canUseDOM() && ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
4
4
  }
@@ -78,7 +78,7 @@ export var setAccessToken = function(token, anonymous, options) {
78
78
  Cookies.set("".concat(tokenIdentifier), token, options);
79
79
  };
80
80
  export var setRefreshToken = function(token, options) {
81
- Cookies.set(REFRESH_TOKEN_KEY, token, options);
81
+ token && Cookies.set(REFRESH_TOKEN_KEY, token, options);
82
82
  };
83
83
  export var setExpiryToken = function(timestamp, options) {
84
84
  Cookies.set(TOKEN_EXPIRY_KEY, timestamp.toString(), options);
@@ -1,6 +1,6 @@
1
- import { useEffect } from "react";
2
- import { useBoolean } from "../../hooks/ui-hooks";
3
- import { isInWebView } from "../utils";
1
+ import { useEffect } from 'react';
2
+ import { useBoolean } from '../../hooks/ui-hooks';
3
+ import { isInWebView } from '../utils';
4
4
  function _arrayLikeToArray(arr, len) {
5
5
  if (len == null || len > arr.length) len = arr.length;
6
6
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -1,4 +1,4 @@
1
- import { isInWebView } from "./isInWebView";
1
+ import { isInWebView } from './isInWebView';
2
2
  export var sendMessageToWebview = function(data) {
3
3
  if (!isInWebView()) return;
4
4
  window.ReactNativeWebView.postMessage(JSON.stringify(data));
@@ -0,0 +1,16 @@
1
+ import type { SearchResultDTO, LineItemDTO } from '@sentecacommerce/sdk';
2
+ declare type CompareStateItemType = SearchResultDTO | LineItemDTO;
3
+ declare type CompareStateItemsType = SearchResultDTO[] | LineItemDTO[];
4
+ declare type CompareContextType = {
5
+ itemAlreadyAdded: (id: string) => boolean;
6
+ addItemToCompare: (item: CompareStateItemType, maxItemLength: number) => void;
7
+ removeComparedItem: (id: string) => void;
8
+ removeAllComparedItems: () => void;
9
+ notAllowed: () => number;
10
+ };
11
+ export declare function CompareContextProvider({ children }: {
12
+ children: any;
13
+ }): JSX.Element;
14
+ export declare function useCompareState(): CompareStateItemsType;
15
+ export declare function useCompareFunctions(): CompareContextType;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { CompareContextProvider, useCompareState, useCompareFunctions, } from './CompareContext';
@@ -31,5 +31,8 @@ declare type UIFunctionsContextType = {
31
31
  export declare function UIProvider({ children, displayNavbar, displaySidebar, customData, }: UIProviderProps): JSX.Element;
32
32
  export declare function useUIState(): UIStateContextType;
33
33
  export declare function useUIFunctions(): UIFunctionsContextType;
34
- export declare function useCustomUI(): [DefaultCustomUI, (state: DefaultCustomUI) => void];
34
+ export declare function useCustomUI(): [
35
+ DefaultCustomUI,
36
+ (state: DefaultCustomUI) => void
37
+ ];
35
38
  export {};
@@ -86,6 +86,7 @@ export * from './hooks/useProgressBar';
86
86
  export * from './hooks/useCatalogDiscounts';
87
87
  export * from './hooks/useLocalRating';
88
88
  export * from './hooks/useProductVariants/types';
89
+ export * from './hooks/CompareContext/';
89
90
  export * from './utils';
90
91
  export * from './types';
91
92
  export * from './seo';
@@ -1,4 +1,4 @@
1
- import { StringField, BooleanField } from "@sentecacommerce-theme/cms";
1
+ import { StringField, BooleanField } from '@sentecacommerce-theme/cms';
2
2
  export declare const extendFilter: ({ slug, filterExtension, noSplit, }: {
3
3
  slug: string;
4
4
  filterExtension?: StringField;
@@ -1,5 +1,5 @@
1
1
  import { BooleanField, NumberField, StringField } from '@sentecacommerce-theme/cms';
2
- export declare const Products: ({ data, bottomMenu, priceColor, textColor, labelsColor, onClose, backgroundColor, title, offers, productSpacing, }: {
2
+ export declare const Products: ({ data, bottomMenu, priceColor, textColor, labelsColor, onClose, backgroundColor, title, offers, productSpacing, noResults, }: {
3
3
  data?: any[] | undefined;
4
4
  bottomMenu?: StringField;
5
5
  priceColor?: StringField;
@@ -10,4 +10,5 @@ export declare const Products: ({ data, bottomMenu, priceColor, textColor, label
10
10
  title?: StringField;
11
11
  offers?: BooleanField;
12
12
  productSpacing?: NumberField;
13
+ noResults?: StringField;
13
14
  }) => JSX.Element;
@@ -1,4 +1,4 @@
1
- export declare const useResetPassword: ({ onSuccess, onError }: {
1
+ export declare const useResetPassword: ({ onSuccess, onError, }: {
2
2
  onSuccess?: (() => void) | undefined;
3
3
  onError?: (() => void) | undefined;
4
4
  }) => import("react-query").MutationResultPair<import("@sentecacommerce/sdk").CustomerDTO, unknown, import("@sentecacommerce/sdk").PasswordResetDTO, unknown>;
@@ -47,5 +47,4 @@ export * from './getDistance';
47
47
  export * from './getPagination';
48
48
  export * from './validations';
49
49
  export * from './transliterate';
50
- export * from './convertDateIntoRemainingDays';
51
50
  export * from './prefetchSDKConfig';
@@ -1,17 +1,12 @@
1
+ import Cookies from 'js-cookie';
1
2
  export declare const AUTH_TOKEN_KEY = "token";
2
3
  export declare const ANONYMOUS_TOKEN_KEY = "anonymousToken";
3
4
  export declare const TOKEN_EXPIRY_KEY = "tokenExpiry";
4
5
  export declare const REFRESH_TOKEN_KEY = "refreshToken";
5
6
  export declare const isTokenExpired: () => boolean;
6
- export declare const setAccessToken: (token: string, anonymous: boolean, options?: {
7
- expires: number;
8
- } | undefined) => void;
9
- export declare const setRefreshToken: (token: string, options?: {
10
- expires: number;
11
- } | undefined) => void;
12
- export declare const setExpiryToken: (timestamp: number, options?: {
13
- expires: number;
14
- } | undefined) => void;
7
+ export declare const setAccessToken: (token: string, anonymous: boolean, options?: Cookies.CookieAttributes | undefined) => void;
8
+ export declare const setRefreshToken: (token: string | undefined, options?: Cookies.CookieAttributes | undefined) => void;
9
+ export declare const setExpiryToken: (timestamp: number, options?: Cookies.CookieAttributes | undefined) => void;
15
10
  export declare const getExpiryToken: () => string | undefined;
16
11
  export declare const removeExpiryToken: () => void;
17
12
  export declare const getRefreshToken: () => string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.14.9",
4
+ "version": "0.14.12",
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": "704001f1791d48eef43ecd862836cc22da13a067",
34
+ "gitHead": "3bec8f769a02fbb65c6e9b1da3ed43fd99b448d9",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.14.9",
40
- "@sentecacommerce-theme/cms": "^0.14.9",
39
+ "@sentecacommerce-theme/base": "^0.14.12",
40
+ "@sentecacommerce-theme/cms": "^0.14.12",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",
@@ -1,10 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", {
2
- value: true
3
- });
4
- exports.convertDateIntoRemainingDays = void 0;
5
- var convertDateIntoRemainingDays = function(date1, date2) {
6
- var differenceInTime = date2.getTime() - date1.getTime();
7
- var differenceInDays = differenceInTime / (1000 * 3600 * 24);
8
- return Math.floor(differenceInDays);
9
- };
10
- exports.convertDateIntoRemainingDays = convertDateIntoRemainingDays;
@@ -1,5 +0,0 @@
1
- export var convertDateIntoRemainingDays = function(date1, date2) {
2
- var differenceInTime = date2.getTime() - date1.getTime();
3
- var differenceInDays = differenceInTime / (1000 * 3600 * 24);
4
- return Math.floor(differenceInDays);
5
- };
@@ -1 +0,0 @@
1
- export declare const convertDateIntoRemainingDays: (date1: Date, date2: Date) => number;