@sentecacommerce-theme/lib 0.13.1 → 0.13.2
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 +2 -1
- package/dist/cjs/api/getSDKConfig.js +4 -2
- package/dist/cjs/api/myCartApi/index.js +8 -2
- package/dist/cjs/basket/api/mutations/index.js +14 -0
- package/dist/cjs/basket/api/mutations/useChangeGiftVariant.js +116 -0
- package/dist/cjs/basket/hooks/index.js +12 -0
- package/dist/cjs/basket/hooks/useChangeGiftVariant.js +16 -0
- package/dist/cjs/config/SentecaProvider.js +3 -1
- package/dist/cjs/hooks/useAggregateResult/index.js +5 -1
- package/dist/cjs/hooks/useAvailability/index.js +1 -1
- package/dist/cjs/hooks/useClearAllFilters/index.js +2 -0
- package/dist/cjs/hooks/useProduct/index.js +36 -26
- 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/useListingBreadcrumbs.js +20 -8
- package/dist/cjs/listing/hooks/useListingCategories.js +2 -2
- package/dist/cjs/listing/hooks/useListingFilters.js +7 -1
- package/dist/cjs/listing/hooks/useListingMeta.js +51 -40
- package/dist/cjs/listing/hooks/useSlideFilter.js +27 -4
- package/dist/cjs/listing/ssr/prefetchCategories.js +5 -6
- package/dist/cjs/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/cjs/listing/utils/buildCategoryQuery.js +22 -1
- 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 +43 -14
- package/dist/cjs/seo/components/index.js +12 -0
- package/dist/cjs/seo/hooks/useSeoTranslations.js +55 -14
- package/dist/cjs/ui/components/GridStyles.js +2 -2
- package/dist/cjs/ui/components/RangeSliderInput.js +14 -1
- package/dist/cjs/user/api/queries/useGetMyLoyaltyCardQuery.js +49 -3
- package/dist/cjs/utils/getLocaleFromPath.js +13 -0
- package/dist/cjs/utils/getSelectedFilters.js +3 -1
- package/dist/cjs/utils/index.js +12 -0
- package/dist/cjs/utils/isTouchDevice.js +2 -1
- package/dist/cjs/utils/localStorage.js +7 -2
- package/dist/esm/analytics/Pixel/mainScript.js +2 -1
- package/dist/esm/api/getSDKConfig.js +5 -3
- package/dist/esm/api/myCartApi/index.js +8 -2
- package/dist/esm/basket/api/mutations/index.js +1 -0
- package/dist/esm/basket/api/mutations/useChangeGiftVariant.js +106 -0
- package/dist/esm/basket/hooks/index.js +1 -0
- package/dist/esm/basket/hooks/useChangeGiftVariant.js +3 -0
- package/dist/esm/config/SentecaProvider.js +3 -1
- package/dist/esm/hooks/useAggregateResult/index.js +5 -1
- package/dist/esm/hooks/useAvailability/index.js +1 -1
- package/dist/esm/hooks/useClearAllFilters/index.js +2 -0
- package/dist/esm/hooks/useProduct/index.js +28 -18
- 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/useListingBreadcrumbs.js +15 -3
- package/dist/esm/listing/hooks/useListingCategories.js +2 -2
- package/dist/esm/listing/hooks/useListingFilters.js +7 -1
- package/dist/esm/listing/hooks/useListingMeta.js +51 -42
- package/dist/esm/listing/hooks/useSlideFilter.js +27 -4
- package/dist/esm/listing/ssr/prefetchCategories.js +6 -7
- package/dist/esm/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/esm/listing/utils/buildCategoryQuery.js +22 -1
- 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 +43 -14
- package/dist/esm/seo/components/index.js +1 -0
- package/dist/esm/seo/hooks/useSeoTranslations.js +55 -14
- package/dist/esm/ui/components/GridStyles.js +2 -2
- package/dist/esm/ui/components/RangeSliderInput.js +14 -1
- package/dist/esm/user/api/queries/useGetMyLoyaltyCardQuery.js +44 -3
- package/dist/esm/utils/getLocaleFromPath.js +8 -0
- package/dist/esm/utils/getSelectedFilters.js +3 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/isTouchDevice.js +2 -1
- package/dist/esm/utils/localStorage.js +7 -2
- package/dist/types/basket/api/mutations/index.d.ts +1 -0
- package/dist/types/basket/api/mutations/useChangeGiftVariant.d.ts +2 -0
- package/dist/types/basket/hooks/index.d.ts +1 -0
- package/dist/types/basket/hooks/useChangeGiftVariant.d.ts +2 -0
- package/dist/types/hooks/basket-hooks/useBasketLineItem/index.d.ts +1 -2
- package/dist/types/hooks/useProduct/index.d.ts +2 -1
- package/dist/types/listing/hooks/useListingMeta.d.ts +4 -0
- 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/useSeoTranslations.d.ts +5 -3
- package/dist/types/ui/components/GridStyles.d.ts +2 -1
- package/dist/types/ui/components/RangeSliderInput.d.ts +2 -1
- package/dist/types/utils/getLocaleFromPath.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +2 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useRouter } from 'next/router';
|
3
3
|
import { usePredicate } from '../api';
|
4
|
-
import { useListingConfig } from './';
|
4
|
+
import { useListingCategories, useListingConfig, getCategoryName, getFilterByType } from './index';
|
5
5
|
import { useListingAlias } from '../../index';
|
6
6
|
import { typeToSuffix } from '../../utils/typeToSuffix';
|
7
7
|
import { getTranslatableField } from '../../utils/getTranslatableField';
|
@@ -33,10 +33,13 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
33
33
|
}
|
34
34
|
var _instance;
|
35
35
|
export var useListingBreadcrumbs = function() {
|
36
|
-
var
|
36
|
+
var ref3 = usePredicate(), data = ref3.data, isLoading = ref3.isLoading;
|
37
37
|
var config = useListingConfig();
|
38
38
|
var router = useRouter();
|
39
39
|
var slug = useListingAlias(config.meta).slug;
|
40
|
+
var ref1 = useListingCategories(), categoriesData = ref1.data;
|
41
|
+
var categoryName = getCategoryName(router, categoriesData);
|
42
|
+
var categoryId = getFilterByType('category', router);
|
40
43
|
var result = React.useMemo(function() {
|
41
44
|
if (config.type === ListingTypesEnum.AttrPage) {
|
42
45
|
var ref;
|
@@ -57,7 +60,16 @@ export var useListingBreadcrumbs = function() {
|
|
57
60
|
},
|
58
61
|
];
|
59
62
|
}
|
60
|
-
|
63
|
+
var breadcrumbData = createCatalogBreadcrumb(data, config.type, router);
|
64
|
+
if (config.type === ListingTypesEnum.View || config.type === ListingTypesEnum.Brand) {
|
65
|
+
var ref2;
|
66
|
+
breadcrumbData.push({
|
67
|
+
name: categoryName || '',
|
68
|
+
id: categoryId,
|
69
|
+
link: processLink((ref2 = data) === null || ref2 === void 0 ? void 0 : ref2.slug, config.type, router.query.slug) + applyFilters(router)
|
70
|
+
});
|
71
|
+
}
|
72
|
+
return breadcrumbData;
|
61
73
|
}, [
|
62
74
|
data,
|
63
75
|
config.type,
|
@@ -92,14 +92,14 @@ function generateUrl(current, router, slug, config) {
|
|
92
92
|
res = "/".concat(router.query.slug, "/").concat(getTranslatableField(current.meta.slug), "/").concat(suffix);
|
93
93
|
}
|
94
94
|
if (pageType === ListingTypesEnum.View) {
|
95
|
-
res = "/".concat(router.query.slug, "/").concat(
|
95
|
+
res = "/".concat(router.query.slug, "/").concat(suffix);
|
96
96
|
}
|
97
97
|
if (pageType === ListingTypesEnum.Search) {
|
98
98
|
var _q;
|
99
99
|
res = "/".concat(getTranslatableField(current.meta.slug), "/c?search=").concat((_q = router.query.q) !== null && _q !== void 0 ? _q : router.query.search);
|
100
100
|
}
|
101
101
|
var filter = router.query.filter;
|
102
|
-
if (suffix === 'b') {
|
102
|
+
if (suffix === 'b' || suffix === 'v') {
|
103
103
|
if (filter) {
|
104
104
|
if (Array.isArray(filter)) {
|
105
105
|
filter = _toConsumableArray(filter);
|
@@ -125,6 +125,8 @@ export function ListingFiltersProvider(param) {
|
|
125
125
|
query: _objectSpread({}, router.query, {
|
126
126
|
filter: filterByType(router.query.filter, filter)
|
127
127
|
})
|
128
|
+
}, undefined, {
|
129
|
+
shallow: true
|
128
130
|
});
|
129
131
|
},
|
130
132
|
type: type
|
@@ -144,6 +146,8 @@ export function ListingFiltersProvider(param) {
|
|
144
146
|
router.push({
|
145
147
|
pathname: router.pathname,
|
146
148
|
query: query
|
149
|
+
}, undefined, {
|
150
|
+
shallow: true
|
147
151
|
});
|
148
152
|
};
|
149
153
|
var selectedFilters = React.useMemo(function() {
|
@@ -186,7 +190,9 @@ function generateFilters(param) {
|
|
186
190
|
aggType: filter,
|
187
191
|
aggKey: filterKey,
|
188
192
|
aggOperator: filtersOperatorsMap[type]
|
189
|
-
}, Boolean(selected), router)
|
193
|
+
}, Boolean(selected), router), undefined, {
|
194
|
+
shallow: true
|
195
|
+
});
|
190
196
|
}
|
191
197
|
};
|
192
198
|
});
|
@@ -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,76 +106,59 @@ 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, ref6;
|
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.q) || (router === null || router === void 0 ? void 0 : (ref6 = router.query) === null || ref6 === void 0 ? void 0 : ref6.search),
|
124
|
+
isWithAttribute: Boolean(router === null || router === void 0 ? void 0 : router.query.cat)
|
125
|
+
});
|
126
|
+
return title || listingName;
|
118
127
|
}
|
119
|
-
function getFilterByType(filterType, router) {
|
128
|
+
export 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, ref7;
|
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 = (ref7 = /\d+/.exec((filters === null || filters === void 0 ? void 0 : filters[0]) || '')) === null || ref7 === void 0 ? void 0 : ref7[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 ref8, ref9, ref10;
|
143
|
+
var isFiltered = router === null || router === void 0 ? void 0 : (ref8 = router.query) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.filter) === null || ref9 === void 0 ? void 0 : ref9.includes(filterType);
|
135
144
|
if (!isFiltered) {
|
136
145
|
return '';
|
137
146
|
}
|
138
|
-
filterId = (
|
147
|
+
filterId = (ref10 = /(\w+)-(\d+)/.exec(router === null || router === void 0 ? void 0 : router.query.filter)) === null || ref10 === void 0 ? void 0 : ref10[0];
|
139
148
|
}
|
140
149
|
return filterId;
|
141
150
|
}
|
142
151
|
function getBrandName(router, filtersData) {
|
143
|
-
var ref,
|
152
|
+
var ref, ref11, ref12;
|
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 : (ref11 = ref.items) === null || ref11 === void 0 ? void 0 : ref11.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 : (ref12 = brand.meta) === null || ref12 === void 0 ? void 0 : ref12.name);
|
151
160
|
}
|
152
|
-
function getCategoryName(router, categories) {
|
161
|
+
export function getCategoryName(router, categories) {
|
153
162
|
var categoryId = getFilterByType('category', router);
|
154
163
|
if (!categoryId || !categories) return;
|
155
164
|
var stack = _toConsumableArray(categories);
|
@@ -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,16 +77,38 @@ 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, {
|
86
106
|
aggType: filterName,
|
87
107
|
aggKey: "".concat(formattedFrom, ",").concat(formattedTo),
|
88
108
|
aggOperator: filtersOperatorsMap.stats
|
89
|
-
}, false, router, true)
|
109
|
+
}, false, router, true), undefined, {
|
110
|
+
shallow: true
|
111
|
+
});
|
90
112
|
}, 500);
|
91
113
|
setState({
|
92
114
|
from: formattedFrom,
|
@@ -101,6 +123,7 @@ export var useSlideFilter = function(filterName, min, max) {
|
|
101
123
|
]);
|
102
124
|
return {
|
103
125
|
value: state,
|
126
|
+
applyFilter: applyFilter,
|
104
127
|
updateValue: updateValue
|
105
128
|
};
|
106
129
|
};
|
@@ -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,19 +45,18 @@ 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,
|
52
51
|
predicate: predicate,
|
53
52
|
slug: aliasedSlug,
|
54
53
|
aggregates: aggregates,
|
55
|
-
postFilter:
|
54
|
+
postFilter: getPostFilters(router),
|
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,
|
@@ -60,7 +60,7 @@ export var buildCategoryQuery = function(param) {
|
|
60
60
|
filter += (ref = config === null || config === void 0 ? void 0 : config.filterExtension) !== null && ref !== void 0 ? ref : '';
|
61
61
|
}
|
62
62
|
if (postFilter) {
|
63
|
-
if (
|
63
|
+
if (filter) filter += '&';
|
64
64
|
filter += postFilter;
|
65
65
|
}
|
66
66
|
break;
|
@@ -77,6 +77,14 @@ export var buildCategoryQuery = function(param) {
|
|
77
77
|
filter += "text;eq;\"".concat(searchQuery, "\"");
|
78
78
|
if (postFilter) filter += "&".concat(postFilter);
|
79
79
|
break;
|
80
|
+
case ListingTypesEnum.View:
|
81
|
+
filter += applyViewsPostFilter({
|
82
|
+
postFilter: postFilter
|
83
|
+
});
|
84
|
+
if (config === null || config === void 0 ? void 0 : config.filterExtension) {
|
85
|
+
filter += filter ? "&".concat(config === null || config === void 0 ? void 0 : config.filterExtension) : config === null || config === void 0 ? void 0 : config.filterExtension;
|
86
|
+
}
|
87
|
+
break;
|
80
88
|
default:
|
81
89
|
return "".concat((config === null || config === void 0 ? void 0 : config.filterExtension) + "".concat(postFilter !== null && postFilter !== void 0 ? postFilter : ''));
|
82
90
|
}
|
@@ -108,3 +116,16 @@ var applyBrandsPostFilter = function(param) {
|
|
108
116
|
}
|
109
117
|
return '';
|
110
118
|
};
|
119
|
+
var applyViewsPostFilter = function(param) {
|
120
|
+
var postFilter = param.postFilter;
|
121
|
+
if (postFilter) {
|
122
|
+
var filtersArr = postFilter.split('&');
|
123
|
+
var filters = filtersArr.reduce(function(res, val, i) {
|
124
|
+
if (val.includes('category')) return res;
|
125
|
+
if (!res) return res + "".concat(val);
|
126
|
+
return res += "&".concat(val);
|
127
|
+
}, '');
|
128
|
+
return "".concat(filters);
|
129
|
+
}
|
130
|
+
return '';
|
131
|
+
};
|
@@ -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,
|
@@ -1,19 +1,48 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useSeoTranslations } from '../../hooks/useSeoTranslations';
|
3
3
|
import Head from 'next/head';
|
4
|
+
import { useRouter } from 'next/router';
|
5
|
+
function _extends() {
|
6
|
+
_extends = Object.assign || function(target) {
|
7
|
+
for(var i = 1; i < arguments.length; i++){
|
8
|
+
var source = arguments[i];
|
9
|
+
for(var key in source){
|
10
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
11
|
+
target[key] = source[key];
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
return target;
|
16
|
+
};
|
17
|
+
return _extends.apply(this, arguments);
|
18
|
+
}
|
4
19
|
export var TranslationsMeta = function() {
|
5
|
-
var ref = useSeoTranslations()
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
href
|
18
|
-
|
20
|
+
var ref = useSeoTranslations(), translationsMap = ref.translationsMap, allLocales = ref.allLocales, defaultLocale = ref.defaultLocale;
|
21
|
+
var router = useRouter();
|
22
|
+
var defaultTranslation = translationsMap[defaultLocale];
|
23
|
+
var isError = router.route === '/404' || router.route === '/_error';
|
24
|
+
if (isError) return null;
|
25
|
+
var domain = defaultTranslation === null || defaultTranslation === void 0 ? void 0 : defaultTranslation.domain;
|
26
|
+
return(/*#__PURE__*/ React.createElement(Head, null, allLocales === null || allLocales === void 0 ? void 0 : allLocales.map(function(locale) {
|
27
|
+
var translation = translationsMap === null || translationsMap === void 0 ? void 0 : translationsMap[locale];
|
28
|
+
var href = translation === null || translation === void 0 ? void 0 : translation.slug;
|
29
|
+
// go to the same page but with the right locale.
|
30
|
+
// This is for pages that does not have a translated slug
|
31
|
+
// example: /checkout -> /en/checkout, /ro/checkout
|
32
|
+
if (!href) href = "/".concat(locale).concat(router.asPath);
|
33
|
+
return(/*#__PURE__*/ React.createElement("link", _extends({
|
34
|
+
rel: "alternate"
|
35
|
+
}, {
|
36
|
+
hreflang: locale
|
37
|
+
}, {
|
38
|
+
href: domain + href,
|
39
|
+
key: 'Translation__' + href
|
40
|
+
})));
|
41
|
+
}), defaultTranslation && /*#__PURE__*/ React.createElement("link", _extends({
|
42
|
+
rel: "alternate"
|
43
|
+
}, {
|
44
|
+
hreflang: 'x-default'
|
45
|
+
}, {
|
46
|
+
href: "".concat(domain).concat(defaultTranslation === null || defaultTranslation === void 0 ? void 0 : defaultTranslation.slug)
|
47
|
+
}))));
|
19
48
|
};
|