@sentecacommerce-theme/lib 0.12.92 → 0.12.96
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/hooks/usePixelProductsImpression.js +9 -8
- package/dist/cjs/hooks/wishlist-hooks/useWishlistItem/index.js +39 -15
- package/dist/cjs/listing/api/queries/useListingQuery.js +1 -1
- package/dist/cjs/listing/hooks/useListingMeta.js +49 -40
- package/dist/cjs/listing/hooks/useSlideFilter.js +24 -3
- package/dist/cjs/listing/ssr/prefetchCategories.js +4 -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 +58 -0
- package/dist/cjs/seo/components/index.js +12 -0
- package/dist/cjs/seo/hooks/index.js +14 -0
- package/dist/cjs/seo/hooks/useSeoTranslations.js +90 -0
- package/dist/cjs/ui/components/GridStyles.js +2 -2
- package/dist/cjs/ui/components/RangeSliderInput.js +14 -1
- package/dist/esm/analytics/Pixel/hooks/usePixelProductsImpression.js +9 -8
- package/dist/esm/hooks/wishlist-hooks/useWishlistItem/index.js +21 -13
- package/dist/esm/listing/api/queries/useListingQuery.js +1 -1
- package/dist/esm/listing/hooks/useListingMeta.js +49 -40
- package/dist/esm/listing/hooks/useSlideFilter.js +24 -3
- package/dist/esm/listing/ssr/prefetchCategories.js +5 -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 +48 -0
- package/dist/esm/seo/components/index.js +1 -0
- package/dist/esm/seo/hooks/index.js +1 -0
- package/dist/esm/seo/hooks/useSeoTranslations.js +79 -0
- package/dist/esm/ui/components/GridStyles.js +2 -2
- package/dist/esm/ui/components/RangeSliderInput.js +14 -1
- package/dist/types/listing/hooks/useSlideFilter.d.ts +4 -0
- package/dist/types/listing/types.d.ts +10 -0
- package/dist/types/navigation/components/SearchBox/Components/EmptyBox/index.d.ts +5 -4
- package/dist/types/navigation/components/SearchBox/index.d.ts +7 -6
- package/dist/types/seo/components/TranslationsMeta/index.d.ts +1 -0
- package/dist/types/seo/components/index.d.ts +1 -0
- package/dist/types/seo/hooks/index.d.ts +1 -0
- package/dist/types/seo/hooks/useSeoTranslations.d.ts +24 -0
- package/dist/types/ui/components/GridStyles.d.ts +2 -1
- package/dist/types/ui/components/RangeSliderInput.d.ts +2 -1
- package/package.json +4 -4
@@ -0,0 +1,90 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
2
|
+
value: true
|
3
|
+
});
|
4
|
+
exports.useSeoTranslations = exports.SeoTranslationsProvider = void 0;
|
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
|
+
function _interopRequireDefault(obj) {
|
21
|
+
return obj && obj.__esModule ? obj : {
|
22
|
+
default: obj
|
23
|
+
};
|
24
|
+
}
|
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
|
+
var SeoTranslationsContext = /*#__PURE__*/ _react.default.createContext({});
|
41
|
+
var SeoTranslationsProvider = function(param) {
|
42
|
+
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
|
+
var data1 = _react.default.useMemo(function() {
|
47
|
+
if (!translations) translations = {};
|
48
|
+
translations[currentLocale] = {
|
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) {
|
54
|
+
return Boolean(localesMap[lang]);
|
55
|
+
}).reduce(function(acc, lang) {
|
56
|
+
var ref;
|
57
|
+
var data = translations === null || translations === void 0 ? void 0 : translations[lang];
|
58
|
+
var localeData = localesMap[lang];
|
59
|
+
var isDefault = defaultLocale === lang;
|
60
|
+
var isFrontPage = data.slug === '/';
|
61
|
+
var prefix = ((ref = data.slug) === null || ref === void 0 ? void 0 : ref[0]) === '/' ? '' : '/';
|
62
|
+
var slug = "".concat(isDefault ? '' : "/".concat(lang)).concat(prefix).concat(isFrontPage ? '' : data.slug);
|
63
|
+
return _objectSpread({}, acc, _defineProperty({}, lang, {
|
64
|
+
slug: slug,
|
65
|
+
locale: lang,
|
66
|
+
isDefault: isDefault,
|
67
|
+
domain: "https://".concat(localeData.domain)
|
68
|
+
}));
|
69
|
+
}, {});
|
70
|
+
return {
|
71
|
+
translationsMap: map,
|
72
|
+
defaultLocale: defaultLocale,
|
73
|
+
allLocales: Object.keys(localesMap)
|
74
|
+
};
|
75
|
+
}, [
|
76
|
+
defaultLocale,
|
77
|
+
translations,
|
78
|
+
localesMap,
|
79
|
+
currentLocale,
|
80
|
+
currentPath
|
81
|
+
]);
|
82
|
+
return(/*#__PURE__*/ _react.default.createElement(SeoTranslationsContext.Provider, {
|
83
|
+
value: data1
|
84
|
+
}, children));
|
85
|
+
};
|
86
|
+
exports.SeoTranslationsProvider = SeoTranslationsProvider;
|
87
|
+
var useSeoTranslations = function() {
|
88
|
+
return _react.default.useContext(SeoTranslationsContext) || {};
|
89
|
+
};
|
90
|
+
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, _spaceBetweenSections = param.spaceBetweenSections, spaceBetweenSections = _spaceBetweenSections === void 0 ? 80 : _spaceBetweenSections;
|
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: ").concat(spaceBetweenSections / remSize, "rem;\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, _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;
|
151
|
+
var defaultValue = param.defaultValue, onChange = param.onChange, onSlide = param.onSlide, _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,6 +161,17 @@ 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
|
+
};
|
164
175
|
var updateLeftValue = (0, _react).useCallback(function() {
|
165
176
|
var inputLeft = inputLeftRef.current;
|
166
177
|
var inputRight = inputRightRef.current;
|
@@ -169,6 +180,7 @@ var RangeSliderInput = function(param) {
|
|
169
180
|
setValue(_objectSpread({}, value, {
|
170
181
|
left: leftValue
|
171
182
|
}));
|
183
|
+
onSlideGeneric();
|
172
184
|
}, [
|
173
185
|
setValue,
|
174
186
|
value
|
@@ -181,6 +193,7 @@ var RangeSliderInput = function(param) {
|
|
181
193
|
setValue(_objectSpread({}, value, {
|
182
194
|
right: rightValue
|
183
195
|
}));
|
196
|
+
onSlideGeneric();
|
184
197
|
}, [
|
185
198
|
setValue,
|
186
199
|
value
|
@@ -51,27 +51,28 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
51
51
|
}
|
52
52
|
export var usePixelProductsImpression = function(param) {
|
53
53
|
var productsData = param.productsData, isCarousel = param.isCarousel;
|
54
|
-
var
|
54
|
+
var ref5;
|
55
|
+
var ref1 = _slicedToArray(useBoolean(false), 2), sentAlready = ref1[0], setSentAlready = ref1[1];
|
55
56
|
var defaultMerchant = useConfigState().defaultMerchant;
|
56
57
|
var router = useRouter();
|
57
58
|
var products = [];
|
58
59
|
if (!isCarousel) {
|
59
|
-
products = createMappedProducts(productsData.products);
|
60
|
+
products = createMappedProducts(productsData === null || productsData === void 0 ? void 0 : productsData.products);
|
60
61
|
}
|
61
62
|
React.useEffect(function() {
|
62
63
|
setSentAlready.off();
|
63
64
|
}, [
|
64
65
|
router.asPath,
|
65
|
-
productsData.products.length,
|
66
|
+
productsData === null || productsData === void 0 ? void 0 : (ref5 = productsData.products) === null || ref5 === void 0 ? void 0 : ref5.length,
|
66
67
|
setSentAlready
|
67
68
|
]);
|
68
69
|
React.useEffect(function() {
|
69
|
-
var ref,
|
70
|
-
if (sentAlready || !products.length) return;
|
71
|
-
if (canUseDOM() && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (
|
72
|
-
var
|
70
|
+
var ref, ref2, ref3;
|
71
|
+
if (sentAlready || !(products === null || products === void 0 ? void 0 : products.length)) return;
|
72
|
+
if (canUseDOM() && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref2 = ref[0]) === null || ref2 === void 0 ? void 0 : ref2.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : (ref3 = productsData.products) === null || ref3 === void 0 ? void 0 : ref3.length) > 0) {
|
73
|
+
var ref4;
|
73
74
|
var pixel = window.pixel;
|
74
|
-
var title = window === null || window === void 0 ? void 0 : (
|
75
|
+
var title = window === null || window === void 0 ? void 0 : (ref4 = window.document) === null || ref4 === void 0 ? void 0 : ref4.title;
|
75
76
|
var sendImpressions = function() {
|
76
77
|
if (!title || title === 'за') {
|
77
78
|
setTimeout(function() {
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { wishlistApi } from '../../../';
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import { useBoolean, wishlistApi } from '../../../';
|
3
3
|
import { usePrefetchProduct, getTranslatableField } from '../../../';
|
4
|
-
import {
|
4
|
+
import { 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,15 +51,19 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
51
51
|
}
|
52
52
|
export var useWishlistItem = function(props) {
|
53
53
|
var ref16;
|
54
|
-
var
|
54
|
+
var item = props.item, expiry = props.expiry;
|
55
|
+
var ref1 = _slicedToArray(useBoolean(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
|
55
56
|
var ref2 = _slicedToArray(wishlistApi.useSync(), 1), syncWishlist = ref2[0];
|
56
57
|
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
|
+
}, []);
|
57
65
|
var data = React.useMemo(function() {
|
58
66
|
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
|
-
}
|
63
67
|
var offer = item === null || item === void 0 ? void 0 : (ref = item.productVariant) === null || ref === void 0 ? void 0 : ref.offer;
|
64
68
|
var mappedAttributes = createMappedAttributes(item === null || item === void 0 ? void 0 : (ref4 = item.productVariant) === null || ref4 === void 0 ? void 0 : ref4.attributes) || {};
|
65
69
|
var mappedCustomField = customFieldsToMap(item.custom);
|
@@ -99,11 +103,15 @@ export var useWishlistItem = function(props) {
|
|
99
103
|
}
|
100
104
|
};
|
101
105
|
}, [
|
102
|
-
|
106
|
+
item
|
107
|
+
]);
|
108
|
+
useEffect(function() {
|
109
|
+
if (isExpired) {
|
110
|
+
syncWishlist();
|
111
|
+
setIsExpired.off();
|
112
|
+
}
|
113
|
+
}, [
|
114
|
+
isExpired
|
103
115
|
]);
|
104
|
-
if (isExpired) {
|
105
|
-
syncWishlist();
|
106
|
-
setIsExpired(false);
|
107
|
-
}
|
108
116
|
return data;
|
109
117
|
};
|
@@ -126,7 +126,7 @@ export var useListingQuery = function() {
|
|
126
126
|
predicate: predicate,
|
127
127
|
sort: sort,
|
128
128
|
postFilter: postFilter,
|
129
|
-
slug:
|
129
|
+
slug: aliasedSlug,
|
130
130
|
offset: offset
|
131
131
|
});
|
132
132
|
return useQuery(queryKeys, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
@@ -4,7 +4,6 @@ import { customFieldsToMap, escape, getTranslatableField } from '../../utils';
|
|
4
4
|
import { assetsFieldsToMap } from '../../utils/assetsToMap';
|
5
5
|
import { useRouter } from 'next/router';
|
6
6
|
import { getListingPageType } from '../utils';
|
7
|
-
import { ListingTypesEnum } from '../types';
|
8
7
|
import { useListingAlias } from '../../index';
|
9
8
|
import { useListingFilters } from './useListingFilters';
|
10
9
|
import { useListingCategories } from './useListingCategories';
|
@@ -23,6 +22,33 @@ function _iterableToArray(iter) {
|
|
23
22
|
function _nonIterableSpread() {
|
24
23
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
25
24
|
}
|
25
|
+
function _objectWithoutProperties(source, excluded) {
|
26
|
+
if (source == null) return {};
|
27
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
28
|
+
var key, i;
|
29
|
+
if (Object.getOwnPropertySymbols) {
|
30
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
31
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
32
|
+
key = sourceSymbolKeys[i];
|
33
|
+
if (excluded.indexOf(key) >= 0) continue;
|
34
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
35
|
+
target[key] = source[key];
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return target;
|
39
|
+
}
|
40
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
41
|
+
if (source == null) return {};
|
42
|
+
var target = {};
|
43
|
+
var sourceKeys = Object.keys(source);
|
44
|
+
var key, i;
|
45
|
+
for(i = 0; i < sourceKeys.length; i++){
|
46
|
+
key = sourceKeys[i];
|
47
|
+
if (excluded.indexOf(key) >= 0) continue;
|
48
|
+
target[key] = source[key];
|
49
|
+
}
|
50
|
+
return target;
|
51
|
+
}
|
26
52
|
function _toConsumableArray(arr) {
|
27
53
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
28
54
|
}
|
@@ -80,74 +106,57 @@ export var useListingMeta = function() {
|
|
80
106
|
return result;
|
81
107
|
};
|
82
108
|
function processDisplayName(slug, config, name, breadcrumb, router, aggData, categoriesData) {
|
109
|
+
var ref, ref5;
|
83
110
|
var listingName = getTranslatableField(name);
|
84
111
|
var brandName = getBrandName(router, aggData);
|
85
112
|
var categoryName = getCategoryName(router, categoriesData);
|
86
113
|
var type = getListingPageType(router, slug, config);
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
return "Всички продукти от ".concat(listingName, " за ").concat(attribute);
|
101
|
-
}
|
102
|
-
return "".concat(categoryName, " от ").concat(listingName, " за ").concat(attribute);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
if (type === ListingTypesEnum.Category && brandName) {
|
106
|
-
return "".concat(listingName, " от ").concat(brandName);
|
107
|
-
}
|
108
|
-
if (type === ListingTypesEnum.Brand) {
|
109
|
-
if (!categoryName) {
|
110
|
-
return "Всички продукти от ".concat(listingName);
|
111
|
-
}
|
112
|
-
return "".concat(categoryName, " от ").concat(listingName);
|
113
|
-
}
|
114
|
-
if (type === ListingTypesEnum.Search && (router === null || router === void 0 ? void 0 : router.query.search)) {
|
115
|
-
return "".concat(listingName, " от \"").concat(router.query.search, "\"");
|
116
|
-
}
|
117
|
-
return listingName;
|
114
|
+
var getTitle = config.getTitle, rest = _objectWithoutProperties(config, [
|
115
|
+
"getTitle"
|
116
|
+
]);
|
117
|
+
var title = getTitle === null || getTitle === void 0 ? void 0 : getTitle(type, rest, {
|
118
|
+
category: categoryName,
|
119
|
+
brand: brandName,
|
120
|
+
defaultName: listingName,
|
121
|
+
attribute: (ref = config.titleAliases) === null || ref === void 0 ? void 0 : ref[slug],
|
122
|
+
childAttribute: getTranslatableField(breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.label),
|
123
|
+
search: router === null || router === void 0 ? void 0 : (ref5 = router.query) === null || ref5 === void 0 ? void 0 : ref5.search,
|
124
|
+
isWithAttribute: Boolean(router === null || router === void 0 ? void 0 : router.query.cat)
|
125
|
+
});
|
126
|
+
return title || listingName;
|
118
127
|
}
|
119
128
|
function getFilterByType(filterType, router) {
|
120
129
|
var filterId = '';
|
121
130
|
if (Array.isArray(router === null || router === void 0 ? void 0 : router.query.filter)) {
|
122
|
-
var ref,
|
131
|
+
var ref, ref6;
|
123
132
|
var filters = (ref = router === null || router === void 0 ? void 0 : router.query.filter) === null || ref === void 0 ? void 0 : ref.filter(function(x) {
|
124
133
|
return x === null || x === void 0 ? void 0 : x.includes(filterType);
|
125
134
|
});
|
126
135
|
if ((filters === null || filters === void 0 ? void 0 : filters.length) && filters.length > 1) {
|
127
136
|
return '';
|
128
137
|
}
|
129
|
-
var filterTerm = (
|
138
|
+
var filterTerm = (ref6 = /\d+/.exec((filters === null || filters === void 0 ? void 0 : filters[0]) || '')) === null || ref6 === void 0 ? void 0 : ref6[0];
|
130
139
|
if (!filterTerm) return '';
|
131
140
|
filterId = filterTerm;
|
132
141
|
} else {
|
133
|
-
var
|
134
|
-
var isFiltered = router === null || router === void 0 ? void 0 : (
|
142
|
+
var ref7, ref8, ref9;
|
143
|
+
var isFiltered = router === null || router === void 0 ? void 0 : (ref7 = router.query) === null || ref7 === void 0 ? void 0 : (ref8 = ref7.filter) === null || ref8 === void 0 ? void 0 : ref8.includes(filterType);
|
135
144
|
if (!isFiltered) {
|
136
145
|
return '';
|
137
146
|
}
|
138
|
-
filterId = (
|
147
|
+
filterId = (ref9 = /(\w+)-(\d+)/.exec(router === null || router === void 0 ? void 0 : router.query.filter)) === null || ref9 === void 0 ? void 0 : ref9[0];
|
139
148
|
}
|
140
149
|
return filterId;
|
141
150
|
}
|
142
151
|
function getBrandName(router, filtersData) {
|
143
|
-
var ref,
|
152
|
+
var ref, ref10, ref11;
|
144
153
|
var brandId = getFilterByType('brand', router);
|
145
154
|
var brand = (ref = filtersData === null || filtersData === void 0 ? void 0 : filtersData.find(function(x) {
|
146
155
|
return x.name === 'Brands';
|
147
|
-
})) === null || ref === void 0 ? void 0 : (
|
156
|
+
})) === null || ref === void 0 ? void 0 : (ref10 = ref.items) === null || ref10 === void 0 ? void 0 : ref10.find(function(x) {
|
148
157
|
return x.data.key === brandId;
|
149
158
|
});
|
150
|
-
return getTranslatableField(brand === null || brand === void 0 ? void 0 : (
|
159
|
+
return getTranslatableField(brand === null || brand === void 0 ? void 0 : (ref11 = brand.meta) === null || ref11 === void 0 ? void 0 : ref11.name);
|
151
160
|
}
|
152
161
|
function getCategoryName(router, categories) {
|
153
162
|
var categoryId = getFilterByType('category', router);
|
@@ -52,7 +52,7 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
52
52
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
53
53
|
}
|
54
54
|
export var useSlideFilter = function(filterName, min, max) {
|
55
|
-
var
|
55
|
+
var ref3;
|
56
56
|
var router = useRouter();
|
57
57
|
var meta = useListingConfig().meta;
|
58
58
|
var slug = useListingAlias(meta).slug;
|
@@ -67,7 +67,7 @@ export var useSlideFilter = function(filterName, min, max) {
|
|
67
67
|
}
|
68
68
|
if (allFilters.includes(filterQuery)) return allFilters;
|
69
69
|
};
|
70
|
-
var filter = (
|
70
|
+
var filter = (ref3 = getFilter()) === null || ref3 === void 0 ? void 0 : ref3.replace(filterQuery, '');
|
71
71
|
var ref1 = _slicedToArray(filter ? filter.split(',') : [
|
72
72
|
min,
|
73
73
|
max
|
@@ -77,9 +77,29 @@ export var useSlideFilter = function(filterName, min, max) {
|
|
77
77
|
to: +to || max
|
78
78
|
}), 2), state = ref2[0], setState = ref2[1];
|
79
79
|
var timeoutRef = useRef();
|
80
|
-
var
|
80
|
+
var getFormattedPriceRange = function(data) {
|
81
81
|
var formattedFrom = Math.min(Math.max(data.from, min), data.to);
|
82
82
|
var formattedTo = Math.max(data.from, Math.min(data.to, max));
|
83
|
+
return {
|
84
|
+
formattedFrom: formattedFrom,
|
85
|
+
formattedTo: formattedTo
|
86
|
+
};
|
87
|
+
};
|
88
|
+
var updateValue = useCallback(function(data) {
|
89
|
+
var ref = getFormattedPriceRange(data), formattedFrom = ref.formattedFrom, formattedTo = ref.formattedTo;
|
90
|
+
setState({
|
91
|
+
from: formattedFrom,
|
92
|
+
to: formattedTo
|
93
|
+
});
|
94
|
+
}, [
|
95
|
+
filterName,
|
96
|
+
max,
|
97
|
+
min,
|
98
|
+
router,
|
99
|
+
slug
|
100
|
+
]);
|
101
|
+
var applyFilter = useCallback(function(data) {
|
102
|
+
var ref = getFormattedPriceRange(data), formattedFrom = ref.formattedFrom, formattedTo = ref.formattedTo;
|
83
103
|
clearTimeout(timeoutRef.current);
|
84
104
|
timeoutRef.current = setTimeout(function() {
|
85
105
|
router.push(createAggregateQuery(getListingPageType(router, slug, meta), router.query.slug, {
|
@@ -101,6 +121,7 @@ export var useSlideFilter = function(filterName, min, max) {
|
|
101
121
|
]);
|
102
122
|
return {
|
103
123
|
value: state,
|
124
|
+
applyFilter: applyFilter,
|
104
125
|
updateValue: updateValue
|
105
126
|
};
|
106
127
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import regeneratorRuntime from "regenerator-runtime";
|
2
2
|
import { CatalogAggregate } from '@sentecacommerce/sdk';
|
3
|
-
import {
|
3
|
+
import { getListingAlias, getPostFilters } from '../utils';
|
4
4
|
import { prepareAggregateQuery, AggregateRequestEnum, generateAggregateKey } from '../api';
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
6
6
|
try {
|
@@ -36,7 +36,7 @@ export function prefetchCategories(queryCache, router, predicate, aggregates, co
|
|
36
36
|
}
|
37
37
|
function _prefetchCategories() {
|
38
38
|
_prefetchCategories = _asyncToGenerator(regeneratorRuntime.mark(function _callee(queryCache, router, predicate, aggregates, config) {
|
39
|
-
var aggregateKeys, aliasedSlug,
|
39
|
+
var aggregateKeys, aliasedSlug, query, response;
|
40
40
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
41
41
|
while(1)switch(_ctx.prev = _ctx.next){
|
42
42
|
case 0:
|
@@ -45,7 +45,6 @@ function _prefetchCategories() {
|
|
45
45
|
router: router,
|
46
46
|
config: config
|
47
47
|
});
|
48
|
-
slug = getSlug(router, aliasedSlug);
|
49
48
|
query = prepareAggregateQuery({
|
50
49
|
request: AggregateRequestEnum.Categories,
|
51
50
|
router: router,
|
@@ -55,9 +54,9 @@ function _prefetchCategories() {
|
|
55
54
|
postFilter: undefined,
|
56
55
|
config: config
|
57
56
|
});
|
58
|
-
_ctx.next =
|
57
|
+
_ctx.next = 5;
|
59
58
|
return CatalogAggregate(query);
|
60
|
-
case
|
59
|
+
case 5:
|
61
60
|
response = _ctx.sent;
|
62
61
|
queryCache.setQueryData([
|
63
62
|
AggregateRequestEnum.Categories,
|
@@ -68,7 +67,7 @@ function _prefetchCategories() {
|
|
68
67
|
staleTime: 30000
|
69
68
|
});
|
70
69
|
return _ctx.abrupt("return", response);
|
71
|
-
case
|
70
|
+
case 8:
|
72
71
|
case "end":
|
73
72
|
return _ctx.stop();
|
74
73
|
}
|
@@ -35,20 +35,20 @@ export function prefetchPredicate(queryCache, router, config) {
|
|
35
35
|
}
|
36
36
|
function _prefetchPredicate() {
|
37
37
|
_prefetchPredicate = _asyncToGenerator(regeneratorRuntime.mark(function _callee(queryCache, router, config) {
|
38
|
-
var
|
38
|
+
var aliasedSlug, slug, data, attribute;
|
39
39
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
40
40
|
while(1)switch(_ctx.prev = _ctx.next){
|
41
41
|
case 0:
|
42
|
-
attribute = router.query.cat && router.query.slug;
|
43
42
|
aliasedSlug = getListingAlias({
|
44
43
|
router: router,
|
45
44
|
config: config
|
46
45
|
});
|
47
46
|
slug = getSlug(router, aliasedSlug);
|
48
|
-
_ctx.next =
|
47
|
+
_ctx.next = 4;
|
49
48
|
return processPredicateRequest(slug, router, aliasedSlug);
|
50
|
-
case
|
49
|
+
case 4:
|
51
50
|
data = _ctx.sent;
|
51
|
+
attribute = router.query.cat && aliasedSlug;
|
52
52
|
queryCache.setQueryData([
|
53
53
|
ListingQueryKeysEnum.usePredicate,
|
54
54
|
slug,
|
@@ -80,38 +80,38 @@ export var EmptyBox = function(param) {
|
|
80
80
|
textColor: textColor || '',
|
81
81
|
onClose: onClose
|
82
82
|
})), /*#__PURE__*/ React.createElement(SuggestedSearches, null, canDisplayPopular && /*#__PURE__*/ React.createElement(PopularSearches, {
|
83
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
83
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.popularSearches) || '',
|
84
84
|
onClose: onClose,
|
85
85
|
textColor: textColor || '',
|
86
86
|
labelsColor: labelsColor || ''
|
87
87
|
}), withRecent && canDisplayRecent && /*#__PURE__*/ React.createElement(RecentSearches, {
|
88
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
88
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.recentSearches) || '',
|
89
89
|
data: searchHistory,
|
90
90
|
onClose: onClose,
|
91
91
|
textColor: textColor || '',
|
92
92
|
labelsColor: labelsColor || ''
|
93
93
|
}))) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Container, {
|
94
94
|
labelsColor: labelsColor,
|
95
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
95
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
|
96
96
|
onlyMobile: true
|
97
97
|
}, /*#__PURE__*/ React.createElement(NoResultsDesc, {
|
98
98
|
className: "SEARCH_BOX_NO_RESULT"
|
99
|
-
},
|
99
|
+
}, labels === null || labels === void 0 ? void 0 : labels.noResults)), /*#__PURE__*/ React.createElement(PromoCol, {
|
100
100
|
backgroundColor: backgroundColor
|
101
101
|
}, /*#__PURE__*/ React.createElement(Products, {
|
102
102
|
data: promoOffers,
|
103
103
|
textColor: textColor || '',
|
104
104
|
labelsColor: labelsColor || '',
|
105
105
|
onClose: onClose,
|
106
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
106
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.promoOffers) || '',
|
107
107
|
offers: true
|
108
108
|
})), /*#__PURE__*/ React.createElement(Container, {
|
109
109
|
labelsColor: labelsColor,
|
110
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
110
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
|
111
111
|
onlyDesktop: true
|
112
112
|
}, /*#__PURE__*/ React.createElement(NoResultsDesc, {
|
113
113
|
className: "SEARCH_BOX_NO_RESULT"
|
114
|
-
},
|
114
|
+
}, labels === null || labels === void 0 ? void 0 : labels.noResults))))));
|
115
115
|
};
|
116
116
|
var Wrapper = styled.div.attrs({
|
117
117
|
className: 'd-flex flex-column flex-lg-row mx-lg-auto '
|
@@ -173,14 +173,14 @@ export var SearchBox = function(param) {
|
|
173
173
|
data: displayableBrands,
|
174
174
|
onClose: onClose,
|
175
175
|
searchValue: searchValue || '',
|
176
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
176
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.suggestedBrands) || '',
|
177
177
|
labelsColor: labelsColor || '',
|
178
178
|
textColor: textColor || ''
|
179
179
|
})), suggestedCategories.length > 0 && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Suggestions, {
|
180
180
|
data: suggestedCategories,
|
181
181
|
onClose: onClose,
|
182
182
|
searchValue: searchValue || '',
|
183
|
-
title: (labels === null || labels === void 0 ? void 0 : labels.
|
183
|
+
title: (labels === null || labels === void 0 ? void 0 : labels.suggestedCategories) || '',
|
184
184
|
labelsColor: labelsColor || '',
|
185
185
|
textColor: textColor || ''
|
186
186
|
}))), /*#__PURE__*/ React.createElement(ProductsWrapper, {
|
@@ -188,7 +188,7 @@ export var SearchBox = function(param) {
|
|
188
188
|
}, /*#__PURE__*/ React.createElement(Products, {
|
189
189
|
data: suggestions,
|
190
190
|
bottomMenu: bottomMenu,
|
191
|
-
title: labels === null || labels === void 0 ? void 0 : labels.
|
191
|
+
title: labels === null || labels === void 0 ? void 0 : labels.products,
|
192
192
|
priceColor: priceColor,
|
193
193
|
labelsColor: labelsColor,
|
194
194
|
textColor: textColor,
|
@@ -197,7 +197,7 @@ export var SearchBox = function(param) {
|
|
197
197
|
productSpacing: productSpacing
|
198
198
|
}), bottomMenu === BottomMenuEnum.promo && promoOffers && /*#__PURE__*/ React.createElement(Products, {
|
199
199
|
data: promoOffers,
|
200
|
-
title: labels.
|
200
|
+
title: labels.promoOffers,
|
201
201
|
labelsColor: labelsColor,
|
202
202
|
textColor: textColor,
|
203
203
|
onClose: onClose,
|