@sentecacommerce-theme/lib 0.12.100 → 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.
- package/dist/cjs/analytics/Pixel/mainScript.js +1 -2
- package/dist/cjs/api/getSDKConfig.js +2 -4
- package/dist/cjs/api/myCartApi/index.js +2 -8
- package/dist/cjs/config/SentecaProvider.js +1 -3
- package/dist/cjs/hooks/useAvailability/index.js +1 -1
- package/dist/cjs/hooks/useProduct/index.js +5 -15
- package/dist/cjs/hooks/wishlist-hooks/useWishlistItem/index.js +15 -39
- package/dist/cjs/listing/api/queries/useListingQuery.js +1 -1
- package/dist/cjs/listing/hooks/useListingMeta.js +40 -49
- package/dist/cjs/listing/hooks/useSlideFilter.js +3 -24
- package/dist/cjs/listing/ssr/prefetchCategories.js +6 -5
- package/dist/cjs/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/cjs/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
- package/dist/cjs/navigation/components/SearchBox/index.js +4 -4
- package/dist/cjs/seo/components/TranslationsMeta/index.js +14 -43
- package/dist/cjs/seo/components/index.js +0 -12
- package/dist/cjs/seo/hooks/useSeoTranslations.js +14 -55
- package/dist/cjs/ui/components/GridStyles.js +2 -2
- package/dist/cjs/ui/components/RangeSliderInput.js +1 -14
- package/dist/cjs/utils/index.js +0 -12
- package/dist/cjs/utils/isTouchDevice.js +1 -2
- package/dist/esm/analytics/Pixel/mainScript.js +1 -2
- package/dist/esm/api/getSDKConfig.js +3 -5
- package/dist/esm/api/myCartApi/index.js +2 -8
- package/dist/esm/config/SentecaProvider.js +1 -3
- package/dist/esm/hooks/useAvailability/index.js +1 -1
- package/dist/esm/hooks/useProduct/index.js +16 -26
- package/dist/esm/hooks/wishlist-hooks/useWishlistItem/index.js +13 -21
- package/dist/esm/listing/api/queries/useListingQuery.js +1 -1
- package/dist/esm/listing/hooks/useListingMeta.js +40 -49
- package/dist/esm/listing/hooks/useSlideFilter.js +3 -24
- package/dist/esm/listing/ssr/prefetchCategories.js +7 -6
- package/dist/esm/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/esm/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
- package/dist/esm/navigation/components/SearchBox/index.js +4 -4
- package/dist/esm/seo/components/TranslationsMeta/index.js +14 -43
- package/dist/esm/seo/components/index.js +0 -1
- package/dist/esm/seo/hooks/useSeoTranslations.js +14 -55
- package/dist/esm/ui/components/GridStyles.js +2 -2
- package/dist/esm/ui/components/RangeSliderInput.js +1 -14
- package/dist/esm/utils/index.js +0 -1
- package/dist/esm/utils/isTouchDevice.js +1 -2
- package/dist/types/listing/hooks/useSlideFilter.d.ts +0 -4
- package/dist/types/listing/types.d.ts +0 -10
- package/dist/types/navigation/components/SearchBox/Components/EmptyBox/index.d.ts +4 -5
- package/dist/types/navigation/components/SearchBox/index.d.ts +6 -7
- package/dist/types/seo/components/index.d.ts +0 -1
- package/dist/types/seo/hooks/useSeoTranslations.d.ts +3 -5
- package/dist/types/ui/components/GridStyles.d.ts +1 -2
- package/dist/types/ui/components/RangeSliderInput.d.ts +1 -2
- package/dist/types/utils/index.d.ts +0 -1
- package/package.json +4 -4
- package/dist/cjs/utils/getLocaleFromPath.js +0 -13
- package/dist/esm/utils/getLocaleFromPath.js +0 -8
- package/dist/types/seo/components/TranslationsMeta/index.d.ts +0 -1
- package/dist/types/utils/getLocaleFromPath.d.ts +0 -1
@@ -5,54 +5,25 @@ exports.TranslationsMeta = void 0;
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
6
6
|
var _useSeoTranslations = require("../../hooks/useSeoTranslations");
|
7
7
|
var _head = _interopRequireDefault(require("next/head"));
|
8
|
-
var _router = require("next/router");
|
9
|
-
function _extends() {
|
10
|
-
_extends = Object.assign || function(target) {
|
11
|
-
for(var i = 1; i < arguments.length; i++){
|
12
|
-
var source = arguments[i];
|
13
|
-
for(var key in source){
|
14
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
15
|
-
target[key] = source[key];
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
return target;
|
20
|
-
};
|
21
|
-
return _extends.apply(this, arguments);
|
22
|
-
}
|
23
8
|
function _interopRequireDefault(obj) {
|
24
9
|
return obj && obj.__esModule ? obj : {
|
25
10
|
default: obj
|
26
11
|
};
|
27
12
|
}
|
28
13
|
var TranslationsMeta = function() {
|
29
|
-
var ref = (0, _useSeoTranslations).useSeoTranslations()
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
rel: "alternate"
|
44
|
-
}, {
|
45
|
-
hreflang: locale
|
46
|
-
}, {
|
47
|
-
href: domain + href,
|
48
|
-
key: 'Translation__' + href
|
49
|
-
})));
|
50
|
-
}), defaultTranslation && /*#__PURE__*/ _react.default.createElement("link", _extends({
|
51
|
-
rel: "alternate"
|
52
|
-
}, {
|
53
|
-
hreflang: 'x-default'
|
54
|
-
}, {
|
55
|
-
href: "".concat(domain).concat(defaultTranslation === null || defaultTranslation === void 0 ? void 0 : defaultTranslation.slug)
|
56
|
-
}))));
|
14
|
+
var ref = (0, _useSeoTranslations).useSeoTranslations() || {}, translations = ref.translations, defaultLocaleSlug = ref.defaultLocaleSlug;
|
15
|
+
if (!translations || !defaultLocaleSlug) return null;
|
16
|
+
return(/*#__PURE__*/ _react.default.createElement(_head.default, null, translations === null || translations === void 0 ? void 0 : translations.map(function(translation) {
|
17
|
+
return(/*#__PURE__*/ _react.default.createElement("link", {
|
18
|
+
rel: "alternate",
|
19
|
+
hrefLang: translation.locale,
|
20
|
+
href: translation.slug,
|
21
|
+
key: 'Translation__' + translation.slug
|
22
|
+
}));
|
23
|
+
}), /*#__PURE__*/ _react.default.createElement("link", {
|
24
|
+
rel: "alternate",
|
25
|
+
hrefLang: "x-default",
|
26
|
+
href: defaultLocaleSlug
|
27
|
+
})));
|
57
28
|
};
|
58
29
|
exports.TranslationsMeta = TranslationsMeta;
|
@@ -74,18 +74,6 @@ Object.keys(_hiddenBreadcrumb).forEach(function(key) {
|
|
74
74
|
}
|
75
75
|
});
|
76
76
|
});
|
77
|
-
var _translationsMeta = _interopRequireWildcard(require("./TranslationsMeta"));
|
78
|
-
Object.keys(_translationsMeta).forEach(function(key) {
|
79
|
-
if (key === "default" || key === "__esModule") return;
|
80
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
81
|
-
if (key in exports && exports[key] === _translationsMeta[key]) return;
|
82
|
-
Object.defineProperty(exports, key, {
|
83
|
-
enumerable: true,
|
84
|
-
get: function() {
|
85
|
-
return _translationsMeta[key];
|
86
|
-
}
|
87
|
-
});
|
88
|
-
});
|
89
77
|
function _interopRequireWildcard(obj) {
|
90
78
|
if (obj && obj.__esModule) {
|
91
79
|
return obj;
|
@@ -3,81 +3,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
});
|
4
4
|
exports.useSeoTranslations = exports.SeoTranslationsProvider = void 0;
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
6
|
-
var _router = require("next/router");
|
7
|
-
function _defineProperty(obj, key, value) {
|
8
|
-
if (key in obj) {
|
9
|
-
Object.defineProperty(obj, key, {
|
10
|
-
value: value,
|
11
|
-
enumerable: true,
|
12
|
-
configurable: true,
|
13
|
-
writable: true
|
14
|
-
});
|
15
|
-
} else {
|
16
|
-
obj[key] = value;
|
17
|
-
}
|
18
|
-
return obj;
|
19
|
-
}
|
20
6
|
function _interopRequireDefault(obj) {
|
21
7
|
return obj && obj.__esModule ? obj : {
|
22
8
|
default: obj
|
23
9
|
};
|
24
10
|
}
|
25
|
-
function _objectSpread(target) {
|
26
|
-
for(var i = 1; i < arguments.length; i++){
|
27
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
28
|
-
var ownKeys = Object.keys(source);
|
29
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
30
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
31
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
32
|
-
}));
|
33
|
-
}
|
34
|
-
ownKeys.forEach(function(key) {
|
35
|
-
_defineProperty(target, key, source[key]);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
return target;
|
39
|
-
}
|
40
11
|
var SeoTranslationsContext = /*#__PURE__*/ _react.default.createContext({});
|
41
12
|
var SeoTranslationsProvider = function(param) {
|
42
13
|
var children = param.children, translations = param.translations, defaultLocale = param.defaultLocale, localesMap = param.localesMap;
|
43
|
-
var router = (0, _router).useRouter();
|
44
|
-
var currentLocale = router.locale;
|
45
|
-
var currentPath = router.asPath;
|
46
14
|
var data1 = _react.default.useMemo(function() {
|
47
|
-
|
48
|
-
|
49
|
-
slug: currentPath.split('?')[0].replace("/".concat(currentLocale), ''),
|
50
|
-
title: '',
|
51
|
-
id: Date.now().toString()
|
52
|
-
};
|
53
|
-
var map = Object.keys(translations || {}).filter(function(lang) {
|
15
|
+
var defaultLocaleSlug = '';
|
16
|
+
var list = Object.keys(translations || {}).filter(function(lang) {
|
54
17
|
return Boolean(localesMap[lang]);
|
55
|
-
}).
|
56
|
-
var ref;
|
18
|
+
}).map(function(lang) {
|
57
19
|
var data = translations === null || translations === void 0 ? void 0 : translations[lang];
|
58
20
|
var localeData = localesMap[lang];
|
59
21
|
var isDefault = defaultLocale === lang;
|
60
|
-
var
|
61
|
-
|
62
|
-
|
63
|
-
return _objectSpread({}, acc, _defineProperty({}, lang, {
|
22
|
+
var slug = "".concat(localeData.domain, "/").concat(isDefault ? lang + '/' : '').concat(data.slug);
|
23
|
+
if (isDefault) defaultLocaleSlug = slug;
|
24
|
+
return {
|
64
25
|
slug: slug,
|
26
|
+
title: data.title,
|
65
27
|
locale: lang,
|
66
|
-
isDefault: isDefault
|
67
|
-
|
68
|
-
|
69
|
-
}, {});
|
28
|
+
isDefault: isDefault
|
29
|
+
};
|
30
|
+
});
|
70
31
|
return {
|
71
|
-
|
32
|
+
translations: list,
|
72
33
|
defaultLocale: defaultLocale,
|
73
|
-
|
34
|
+
defaultLocaleSlug: defaultLocaleSlug
|
74
35
|
};
|
75
36
|
}, [
|
76
37
|
defaultLocale,
|
77
38
|
translations,
|
78
|
-
localesMap
|
79
|
-
currentLocale,
|
80
|
-
currentPath
|
39
|
+
localesMap
|
81
40
|
]);
|
82
41
|
return(/*#__PURE__*/ _react.default.createElement(SeoTranslationsContext.Provider, {
|
83
42
|
value: data1
|
@@ -85,6 +44,6 @@ var SeoTranslationsProvider = function(param) {
|
|
85
44
|
};
|
86
45
|
exports.SeoTranslationsProvider = SeoTranslationsProvider;
|
87
46
|
var useSeoTranslations = function() {
|
88
|
-
return _react.default.useContext(SeoTranslationsContext)
|
47
|
+
return _react.default.useContext(SeoTranslationsContext);
|
89
48
|
};
|
90
49
|
exports.useSeoTranslations = useSeoTranslations;
|
@@ -9,7 +9,7 @@ function _interopRequireDefault(obj) {
|
|
9
9
|
};
|
10
10
|
}
|
11
11
|
var GridStyles = function(param) {
|
12
|
-
var spaceX = param.spaceX, breakpoints = param.breakpoints, _remSize = param.remSize, remSize = _remSize === void 0 ? 10 : _remSize
|
12
|
+
var spaceX = param.spaceX, breakpoints = param.breakpoints, _remSize = param.remSize, remSize = _remSize === void 0 ? 10 : _remSize;
|
13
13
|
function getSize(width) {
|
14
14
|
return "min-width: calc(".concat(width, "% - ").concat(spaceX / remSize, "rem);") + "max-width: calc(".concat(width, "% - ").concat(spaceX / remSize, "rem);") + "margin: 0 ".concat(spaceX / 2 / remSize, "rem;");
|
15
15
|
}
|
@@ -29,7 +29,7 @@ var GridStyles = function(param) {
|
|
29
29
|
}, '');
|
30
30
|
return(/*#__PURE__*/ _react.default.createElement("style", {
|
31
31
|
dangerouslySetInnerHTML: {
|
32
|
-
__html: "\n .Page--row {\n display: flex;\n display: -webkit-flex;\n flex-wrap: wrap;\n -webkit-flex-wrap: wrap;\n margin: 0 -".concat(spaceX / remSize / 2, "rem;\n }\n\n .Page__section {\n padding-bottom:
|
32
|
+
__html: "\n .Page--row {\n display: flex;\n display: -webkit-flex;\n flex-wrap: wrap;\n -webkit-flex-wrap: wrap;\n margin: 0 -".concat(spaceX / remSize / 2, "rem;\n }\n\n .Page__section {\n padding-bottom: 8rem;\n }\n\n .Page--col {\n display: block;\n width: 100%;\n }\n \n .size-default-inherit {\n width: 100%;\n }\n ").concat(queries, "\n ")
|
33
33
|
}
|
34
34
|
}));
|
35
35
|
};
|
@@ -148,7 +148,7 @@ var RangeSlideClasses = {
|
|
148
148
|
};
|
149
149
|
exports.RangeSlideClasses = RangeSlideClasses;
|
150
150
|
var RangeSliderInput = function(param) {
|
151
|
-
var defaultValue = param.defaultValue, onChange = param.onChange,
|
151
|
+
var defaultValue = param.defaultValue, onChange = param.onChange, _min = param.min, min = _min === void 0 ? 0 : _min, _max = param.max, max = _max === void 0 ? 100 : _max, _step = param.step, step = _step === void 0 ? 1 : _step;
|
152
152
|
var ref1 = _slicedToArray((0, _react).useState(defaultValue), 2), value = ref1[0], setValue = ref1[1];
|
153
153
|
var inputLeftRef = _react.default.useRef(null);
|
154
154
|
var inputRightRef = _react.default.useRef(null);
|
@@ -161,17 +161,6 @@ var RangeSliderInput = function(param) {
|
|
161
161
|
}, [
|
162
162
|
defaultValue
|
163
163
|
]);
|
164
|
-
var onSlideGeneric = function() {
|
165
|
-
var inputLeft = inputLeftRef.current;
|
166
|
-
var inputRight = inputRightRef.current;
|
167
|
-
if (!inputLeft || !inputRight) return;
|
168
|
-
var leftValue = Math.min(Number(inputLeft.value), Number(inputRight.value) - 1);
|
169
|
-
var rightValue = Math.max(Number(inputRight.value), Number(inputLeft.value) + 1);
|
170
|
-
onSlide === null || onSlide === void 0 ? void 0 : onSlide({
|
171
|
-
left: leftValue,
|
172
|
-
right: rightValue
|
173
|
-
});
|
174
|
-
};
|
175
164
|
var updateLeftValue = (0, _react).useCallback(function() {
|
176
165
|
var inputLeft = inputLeftRef.current;
|
177
166
|
var inputRight = inputRightRef.current;
|
@@ -180,7 +169,6 @@ var RangeSliderInput = function(param) {
|
|
180
169
|
setValue(_objectSpread({}, value, {
|
181
170
|
left: leftValue
|
182
171
|
}));
|
183
|
-
onSlideGeneric();
|
184
172
|
}, [
|
185
173
|
setValue,
|
186
174
|
value
|
@@ -193,7 +181,6 @@ var RangeSliderInput = function(param) {
|
|
193
181
|
setValue(_objectSpread({}, value, {
|
194
182
|
right: rightValue
|
195
183
|
}));
|
196
|
-
onSlideGeneric();
|
197
184
|
}, [
|
198
185
|
setValue,
|
199
186
|
value
|
package/dist/cjs/utils/index.js
CHANGED
@@ -170,18 +170,6 @@ 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
|
-
});
|
185
173
|
var _calcDiscount = _interopRequireWildcard(require("./calcDiscount"));
|
186
174
|
Object.keys(_calcDiscount).forEach(function(key) {
|
187
175
|
if (key === "default" || key === "__esModule") return;
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
2
2
|
value: true
|
3
3
|
});
|
4
4
|
exports.isTouchDevice = isTouchDevice;
|
5
|
-
var _canUseDom = require("./canUseDom");
|
6
5
|
function isTouchDevice() {
|
7
|
-
return
|
6
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
8
7
|
}
|
@@ -246,8 +246,7 @@ function _objectSpread(target) {
|
|
246
246
|
mode: 'cors',
|
247
247
|
cache: 'no-cache',
|
248
248
|
headers: {
|
249
|
-
'Content-Type': 'application/json'
|
250
|
-
'senteca-locale': global.location.pathname.split('/')[1] || ''
|
249
|
+
'Content-Type': 'application/json'
|
251
250
|
},
|
252
251
|
body: JSON.stringify(payload)
|
253
252
|
});
|
@@ -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
|
3
|
+
import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY } from '../utils';
|
4
4
|
function _defineProperty(obj, key, value) {
|
5
5
|
if (key in obj) {
|
6
6
|
Object.defineProperty(obj, key, {
|
@@ -35,15 +35,13 @@ 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 || {}
|
39
|
-
'senteca-locale': getLocaleFromPath()
|
40
|
-
})
|
38
|
+
headers: _objectSpread({}, headers, options.headers || {})
|
41
39
|
}));
|
42
40
|
return config;
|
43
41
|
};
|
44
42
|
export var getOptions = function() {
|
45
43
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
46
|
-
if (
|
44
|
+
if (typeof window === 'undefined') {
|
47
45
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
48
46
|
var nodeFetch = require('node-fetch');
|
49
47
|
var ref;
|
@@ -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:
|
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([
|
@@ -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);
|
@@ -65,7 +65,7 @@ export var useAvailability = function(param) {
|
|
65
65
|
setStatus(ProductQuantityStatusEnum.OutOfStock);
|
66
66
|
return;
|
67
67
|
}
|
68
|
-
if (quantity
|
68
|
+
if ((quantity !== null && quantity !== void 0 ? quantity : 0) < (quantityInBasket || 1)) {
|
69
69
|
setStatus(ProductQuantityStatusEnum.MaxQuantityReached);
|
70
70
|
return;
|
71
71
|
}
|
@@ -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
|
225
|
-
var
|
226
|
-
|
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,
|
243
|
-
var result = attributeRules === null || attributeRules === void 0 ? void 0 : (ref = attributeRules[key]) === null || ref === void 0 ? void 0 : (
|
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,7 +238,7 @@ 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
|
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 = {
|
@@ -258,24 +248,24 @@ export function ProductProvider(param) {
|
|
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 : (
|
262
|
-
name: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
263
|
-
slug: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
264
|
-
logo: product === null || product === void 0 ? void 0 : (
|
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 : (
|
268
|
-
name: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
269
|
-
slug: getTranslatableField(product === null || product === void 0 ? void 0 : (
|
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 : (
|
274
|
-
slug: getTranslatableField(rootCategory === null || rootCategory === void 0 ? void 0 : (
|
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 : (
|
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
|
2
|
-
import {
|
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
|
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:
|
129
|
+
slug: slug,
|
130
130
|
offset: offset
|
131
131
|
});
|
132
132
|
return useQuery(queryKeys, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|