@riosst100/pwa-marketplace 2.5.9 → 2.6.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/package.json +1 -1
- package/src/components/FilterTop/filterTop.js +3 -3
- package/src/components/SetsData/setsData.js +47 -39
- package/src/components/SetsData/setsData.module.css +1 -1
- package/src/components/ShopBy/shopBy.js +6 -5
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +4 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +3 -3
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +1 -1
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +2 -1
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +3 -3
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.module.css +1 -1
- package/src/talons/SetsData/setsData.gql.js +6 -2
- package/src/talons/SetsData/useSetsData.js +61 -27
- package/src/talons/ShopBy/useShopBy.js +50 -25
package/package.json
CHANGED
|
@@ -60,9 +60,9 @@ const FilterTop = props => {
|
|
|
60
60
|
typeof filterElement.getBoundingClientRect === 'function'
|
|
61
61
|
) {
|
|
62
62
|
const filterTop = filterElement.getBoundingClientRect().top;
|
|
63
|
-
const windowScrollY =
|
|
64
|
-
|
|
65
|
-
window.scrollTo(0, windowScrollY);
|
|
63
|
+
// const windowScrollY =
|
|
64
|
+
// window.scrollY + filterTop - SCROLL_OFFSET;
|
|
65
|
+
// window.scrollTo(0, windowScrollY);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
handleApply(...args);
|
|
@@ -30,6 +30,7 @@ const SetsData = props => {
|
|
|
30
30
|
const [activeFilter, setActiveFilter] = useState('');
|
|
31
31
|
const [activeYear, setActiveYear] = useState('');
|
|
32
32
|
const [searchQuery, setSearchQuery] = useState('');
|
|
33
|
+
const [setsFilters, setSetsFilters] = useState([]);
|
|
33
34
|
|
|
34
35
|
const shopby = query.get('shopby') || null;
|
|
35
36
|
const setType = query.get('set_type') || null;
|
|
@@ -67,16 +68,14 @@ const SetsData = props => {
|
|
|
67
68
|
|
|
68
69
|
const classes = useStyle(defaultClasses);
|
|
69
70
|
|
|
70
|
-
const talonProps = useSetsData({ activeFilter, activeYear, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
71
|
+
const talonProps = useSetsData({ setsFilters, activeFilter, activeYear, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
71
72
|
|
|
72
|
-
const { error, loading, setsData, categoryUrlSuffix, categoryUrlKey, productType, filteredSetsData, availableGroups, availableYears, category, attributeData, pageInfo } = talonProps;
|
|
73
|
+
const { error, loading, setsData, availableFilters, categoryUrlSuffix, categoryUrlKey, productType, filteredSetsData, availableGroups, availableYears, category, attributeData, pageInfo } = talonProps;
|
|
73
74
|
|
|
74
|
-
if (loading
|
|
75
|
-
return <SetsDataShimmer />;
|
|
76
|
-
if (error && !setsData) return <ErrorView />;
|
|
77
|
-
|
|
78
|
-
if (!setsData && !loading && !error) {
|
|
75
|
+
if (loading) {
|
|
79
76
|
return <SetsDataShimmer />;
|
|
77
|
+
} else if (error) {
|
|
78
|
+
return <ErrorView />;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
const setsLengthArr = [];
|
|
@@ -209,6 +208,23 @@ const SetsData = props => {
|
|
|
209
208
|
setActive('all')
|
|
210
209
|
}
|
|
211
210
|
|
|
211
|
+
const handleSetsFilters = (code, val) => {
|
|
212
|
+
setSetsFilters((prevFilters) => {
|
|
213
|
+
const updated = [...prevFilters];
|
|
214
|
+
const index = updated.findIndex((f) => f.code === code);
|
|
215
|
+
|
|
216
|
+
if (index !== -1) {
|
|
217
|
+
// Update value jika code sudah ada
|
|
218
|
+
updated[index].value = val;
|
|
219
|
+
} else {
|
|
220
|
+
// Tambahkan jika belum ada
|
|
221
|
+
updated.push({ code, value: val });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return updated;
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
|
|
212
228
|
let alpha = ['#', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
|
|
213
229
|
|
|
214
230
|
let title = pageInfo ? pageInfo.title : 'All S2ets';
|
|
@@ -216,12 +232,12 @@ const SetsData = props => {
|
|
|
216
232
|
title = "Sets | By Year";
|
|
217
233
|
}
|
|
218
234
|
|
|
219
|
-
const availableFilters = [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
];
|
|
235
|
+
// const availableFilters = [
|
|
236
|
+
// 'Theme',
|
|
237
|
+
// 'Sub-Theme',
|
|
238
|
+
// 'Interest',
|
|
239
|
+
// 'Age Level'
|
|
240
|
+
// ];
|
|
225
241
|
|
|
226
242
|
const handleActiveFilter = (val) => {
|
|
227
243
|
setActiveFilter(val);
|
|
@@ -262,6 +278,9 @@ const SetsData = props => {
|
|
|
262
278
|
<Fragment>
|
|
263
279
|
<StoreTitle>{title}</StoreTitle>
|
|
264
280
|
<Breadcrumbs categoryId={categoryId} currentFilter={activeFilters} customPage={shopby == "singles" ? "Mini-Figures" : title} />
|
|
281
|
+
{pageInfo && !pageInfo.hide_title && <h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
282
|
+
{title}
|
|
283
|
+
</h1>}
|
|
265
284
|
{shopby == "secret_lair" ? <>
|
|
266
285
|
<ul className={classes.nav}>
|
|
267
286
|
{availableYears.map((group, index) => (
|
|
@@ -286,33 +305,22 @@ const SetsData = props => {
|
|
|
286
305
|
</li>
|
|
287
306
|
</ul>
|
|
288
307
|
</> : ''}
|
|
289
|
-
{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
<
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
308
|
+
{availableFilters ? <>
|
|
309
|
+
{availableFilters.map(({code, options}, index) => (
|
|
310
|
+
<ul className={classes.nav} key={index}>
|
|
311
|
+
{options.map((value, index) => (
|
|
312
|
+
<li key={index} className={classes.nav_item}>
|
|
313
|
+
<button
|
|
314
|
+
onClick={() => {
|
|
315
|
+
handleSetsFilters(code, value)
|
|
316
|
+
}}
|
|
317
|
+
>
|
|
318
|
+
{setsFilters.find(f => f.code === code && f.value === value) || !setsFilters.length && index == 0 ? <b>{value}</b> : value}
|
|
319
|
+
</button>
|
|
320
|
+
</li>
|
|
301
321
|
))}
|
|
302
|
-
|
|
303
|
-
<button
|
|
304
|
-
onClick={() => {
|
|
305
|
-
handleActiveFilter('')
|
|
306
|
-
}}
|
|
307
|
-
>
|
|
308
|
-
{!activeFilter ? <b>A-Z</b> : 'A-Z'}
|
|
309
|
-
</button>
|
|
310
|
-
</li>
|
|
311
|
-
</ul>
|
|
322
|
+
</ul>))}
|
|
312
323
|
</> : ''}
|
|
313
|
-
{!pageInfo.hide_title && <h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
314
|
-
{title}
|
|
315
|
-
</h1>}
|
|
316
324
|
{activeTab == "year" && availableGroups ? <ul className={classes.nav}>
|
|
317
325
|
{availableGroups.map((group, index) => (
|
|
318
326
|
<li key={index} className={classes.nav_item}>
|
|
@@ -335,7 +343,7 @@ const SetsData = props => {
|
|
|
335
343
|
</button>
|
|
336
344
|
</li>
|
|
337
345
|
</ul> : ''}
|
|
338
|
-
{pageInfo.filter_group && <ul className={classes.nav}>
|
|
346
|
+
{pageInfo && pageInfo.filter_group && <ul className={classes.nav}>
|
|
339
347
|
{availableGroups.map((group, index) => (
|
|
340
348
|
<li key={index} className={classes.nav_item}>
|
|
341
349
|
<button
|
|
@@ -112,12 +112,13 @@ const ShopBy = props => {
|
|
|
112
112
|
|
|
113
113
|
const { error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category, activeFilters, pageInfo } = talonProps;
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (error && !dataResult) return <ErrorView />;
|
|
115
|
+
console.log('error', error)
|
|
116
|
+
console.log('loading', loading)
|
|
118
117
|
|
|
119
|
-
if (
|
|
118
|
+
if (loading) {
|
|
120
119
|
return <ShopByShimmer />;
|
|
120
|
+
} else if (error) {
|
|
121
|
+
return <ErrorView />;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
const newAvailableGroups = searchQuery ? filteredAvailableGroups : availableGroups;
|
|
@@ -425,7 +426,7 @@ const ShopBy = props => {
|
|
|
425
426
|
<Divider className="mb-5 px-4 mt-5" />
|
|
426
427
|
<section className='singles-container'>
|
|
427
428
|
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
428
|
-
{Object.keys(dataResult).length != 0 ? setRelases : (searchQuery ? <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found for <b>{searchQuery}</b> search query.</div> : <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found.</div>)}
|
|
429
|
+
{dataResult && Object.keys(dataResult).length != 0 ? setRelases : (searchQuery ? <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found for <b>{searchQuery}</b> search query.</div> : <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found.</div>)}
|
|
429
430
|
</div>
|
|
430
431
|
</section>
|
|
431
432
|
</div>
|
|
@@ -153,8 +153,10 @@ export const useFilterSidebar = props => {
|
|
|
153
153
|
// Add frontend input type
|
|
154
154
|
frontendInput.set(group, null);
|
|
155
155
|
// add items
|
|
156
|
-
for (const { label, value, path } of options) {
|
|
157
|
-
|
|
156
|
+
for (const { label, value, path, count } of options) {
|
|
157
|
+
if (count > 0) {
|
|
158
|
+
items.push({ title: stripHtml(label), value, path, count });
|
|
159
|
+
}
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
itemsByGroup.set(group, items);
|
|
@@ -20,9 +20,9 @@ const CurrentFilters = props => {
|
|
|
20
20
|
const { title, value } = item || {};
|
|
21
21
|
const key = `${group}::${title}_${value}`;
|
|
22
22
|
|
|
23
|
-
const customAttributeLandingPage = ['bricks_categories','sc_sports_categories','card_game',
|
|
23
|
+
const customAttributeLandingPage = ['bricks_categories','sc_sports_categories','card_game', 'sc_baseball_release','auction','special_price','lof_preorder','sc_baseball_inserts','sc_baseball_parallel','sc_set_type'];
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
if (!customAttributeLandingPage.includes(group)) {
|
|
26
26
|
elements.push(
|
|
27
27
|
<li key={key} className={classes.item}>
|
|
28
28
|
<CurrentFilter
|
|
@@ -34,7 +34,7 @@ const CurrentFilters = props => {
|
|
|
34
34
|
/>
|
|
35
35
|
</li>
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js
CHANGED
|
@@ -19,7 +19,7 @@ const FilterItemRadioGroup = props => {
|
|
|
19
19
|
const { filterApi, subFilterItems, allowedSubFilters, subFilter, filterState, group, isSubFilter, items, onApply, labels,isListExpanded = true, itemCountToShow = 5 } = props;
|
|
20
20
|
const radioItems = useMemo(() => {
|
|
21
21
|
return items.map((item,index) => {
|
|
22
|
-
if (
|
|
22
|
+
if (index >= itemCountToShow) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -260,6 +260,8 @@ const FilterList = props => {
|
|
|
260
260
|
const { pathname, search } = useLocation();
|
|
261
261
|
|
|
262
262
|
const showMoreItem = useMemo(() => {
|
|
263
|
+
console.log('itemCountToShow')
|
|
264
|
+
console.log(itemCountToShow)
|
|
263
265
|
if (items.length <= itemCountToShow) {
|
|
264
266
|
return null;
|
|
265
267
|
}
|
|
@@ -288,7 +290,6 @@ const FilterList = props => {
|
|
|
288
290
|
</li>
|
|
289
291
|
);
|
|
290
292
|
}, [
|
|
291
|
-
handleShowMore,
|
|
292
293
|
items,
|
|
293
294
|
itemCountToShow,
|
|
294
295
|
formatMessage,
|
|
@@ -49,9 +49,9 @@ const FilterSidebar = props => {
|
|
|
49
49
|
typeof filterElement.getBoundingClientRect === 'function'
|
|
50
50
|
) {
|
|
51
51
|
const filterTop = filterElement.getBoundingClientRect().top;
|
|
52
|
-
const windowScrollY =
|
|
53
|
-
|
|
54
|
-
window.scrollTo(0, windowScrollY);
|
|
52
|
+
// const windowScrollY =
|
|
53
|
+
// window.scrollY + filterTop - SCROLL_OFFSET;
|
|
54
|
+
// window.scrollTo(0, windowScrollY);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
handleApply(...args);
|
|
@@ -12,12 +12,16 @@ export const GET_STORE_CONFIG_DATA = gql`
|
|
|
12
12
|
`;
|
|
13
13
|
|
|
14
14
|
export const GET_SETS_DATA_QUERY = gql`
|
|
15
|
-
query getSetsData($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
|
|
16
|
-
getSetsData(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby, activeFilter: $activeFilter) {
|
|
15
|
+
query getSetsData($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String, $set_filters: [SetFiltersInput]) {
|
|
16
|
+
getSetsData(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby, activeFilter: $activeFilter, set_filters: $set_filters) {
|
|
17
17
|
attribute {
|
|
18
18
|
attribute_code
|
|
19
19
|
label
|
|
20
20
|
}
|
|
21
|
+
available_filters {
|
|
22
|
+
code
|
|
23
|
+
options
|
|
24
|
+
}
|
|
21
25
|
page_info {
|
|
22
26
|
title
|
|
23
27
|
hide_title
|
|
@@ -8,7 +8,7 @@ import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/tal
|
|
|
8
8
|
|
|
9
9
|
export const useSetsData = props => {
|
|
10
10
|
|
|
11
|
-
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter, activeYear } = props
|
|
11
|
+
const { setsFilters, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter, activeYear } = props
|
|
12
12
|
|
|
13
13
|
const { value: sortby } = currentSort
|
|
14
14
|
|
|
@@ -26,7 +26,11 @@ export const useSetsData = props => {
|
|
|
26
26
|
const parentCategoryUrlKey = pathnameArr[pathnameArr.length - 2].replace('.html','');
|
|
27
27
|
const productType = shopby;
|
|
28
28
|
|
|
29
|
-
const { data: introspectionData } = useQuery(getFilterInputsQuery
|
|
29
|
+
const { data: introspectionData,loading: introspectionLoading,error: introspectionDataError } = useQuery(getFilterInputsQuery, {
|
|
30
|
+
variables: {},
|
|
31
|
+
fetchPolicy: 'cache-and-network',
|
|
32
|
+
nextFetchPolicy: 'cache-first'
|
|
33
|
+
});
|
|
30
34
|
|
|
31
35
|
const filterTypeMap = useMemo(() => {
|
|
32
36
|
const typeMap = new Map();
|
|
@@ -39,35 +43,54 @@ export const useSetsData = props => {
|
|
|
39
43
|
}, [introspectionData]);
|
|
40
44
|
const filters = getFiltersFromSearch(search);
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
|
|
43
47
|
|
|
44
48
|
// Construct the filter arg object.
|
|
45
|
-
const newFilters = {};
|
|
46
|
-
filters.forEach((values, key) => {
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
// const newFilters = {};
|
|
50
|
+
// filters.forEach((values, key) => {
|
|
51
|
+
// newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
52
|
+
// if (key == "sc_baseball_release") {
|
|
53
|
+
// for(let item of values) {
|
|
54
|
+
// if(item) {
|
|
55
|
+
// const data = search.split('&');
|
|
56
|
+
// data.pop();
|
|
57
|
+
// activeFilters.push(
|
|
58
|
+
// {
|
|
59
|
+
// 'label': item.split(',')[0],
|
|
60
|
+
// 'path': data
|
|
61
|
+
// }
|
|
62
|
+
// )
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// });
|
|
67
|
+
const { newFilters, activeFilters } = useMemo(() => {
|
|
68
|
+
const resultFilters = {};
|
|
69
|
+
const resultActiveFilters = [];
|
|
70
|
+
|
|
71
|
+
if (filterTypeMap.size) {
|
|
72
|
+
filters.forEach((values, key) => {
|
|
73
|
+
resultFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
74
|
+
|
|
75
|
+
if (key === "sc_baseball_release") {
|
|
76
|
+
for (let item of values) {
|
|
77
|
+
if (item) {
|
|
78
|
+
const data = search.split('&');
|
|
79
|
+
data.pop();
|
|
80
|
+
resultActiveFilters.push({
|
|
81
|
+
label: item.split(',')[0],
|
|
82
|
+
path: data
|
|
83
|
+
});
|
|
61
84
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
65
88
|
}
|
|
66
|
-
});
|
|
67
89
|
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
return { newFilters: resultFilters, activeFilters: resultActiveFilters };
|
|
91
|
+
}, [filterTypeMap]);
|
|
70
92
|
|
|
93
|
+
useEffect(() => {
|
|
71
94
|
// if (queryResponse.data) {
|
|
72
95
|
|
|
73
96
|
|
|
@@ -81,6 +104,7 @@ export const useSetsData = props => {
|
|
|
81
104
|
filters: newFilters,
|
|
82
105
|
categoryUrlKey: pathname,
|
|
83
106
|
activeTab: activeTab,
|
|
107
|
+
set_filters: setsFilters,
|
|
84
108
|
shopby: shopby,
|
|
85
109
|
activeFilter: activeFilter
|
|
86
110
|
}
|
|
@@ -89,11 +113,12 @@ export const useSetsData = props => {
|
|
|
89
113
|
}, [
|
|
90
114
|
runQuery,
|
|
91
115
|
activeTab,
|
|
92
|
-
activeFilter
|
|
116
|
+
activeFilter,
|
|
117
|
+
setsFilters,
|
|
93
118
|
// queryResponse
|
|
94
119
|
// filterTypeMap,
|
|
95
120
|
// search,
|
|
96
|
-
|
|
121
|
+
newFilters,
|
|
97
122
|
// shopby,
|
|
98
123
|
// categoryUrlKey
|
|
99
124
|
]);
|
|
@@ -181,6 +206,14 @@ export const useSetsData = props => {
|
|
|
181
206
|
return queryResponse?.data?.getSetsData?.attribute;
|
|
182
207
|
}, [queryResponse]);
|
|
183
208
|
|
|
209
|
+
const availableFilters = useMemo(() => {
|
|
210
|
+
if (!queryResponse) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return queryResponse?.data?.getSetsData?.available_filters;
|
|
215
|
+
}, [queryResponse]);
|
|
216
|
+
|
|
184
217
|
const pageInfo = useMemo(() => {
|
|
185
218
|
if (!queryResponse) {
|
|
186
219
|
return null;
|
|
@@ -269,6 +302,7 @@ export const useSetsData = props => {
|
|
|
269
302
|
availableYears,
|
|
270
303
|
category,
|
|
271
304
|
attributeData,
|
|
305
|
+
availableFilters,
|
|
272
306
|
pageInfo
|
|
273
307
|
};
|
|
274
308
|
};
|
|
@@ -22,7 +22,7 @@ export const useShopBy = props => {
|
|
|
22
22
|
// }
|
|
23
23
|
// ] = useAppContext();
|
|
24
24
|
|
|
25
|
-
const [runQuery, queryResponse] = useLazyQuery(getShopByDataQuery, {
|
|
25
|
+
const [runQuery, {data: queryResponse, loading, error}] = useLazyQuery(getShopByDataQuery, {
|
|
26
26
|
fetchPolicy: 'cache-and-network',
|
|
27
27
|
nextFetchPolicy: 'cache-first'
|
|
28
28
|
});
|
|
@@ -50,7 +50,7 @@ export const useShopBy = props => {
|
|
|
50
50
|
return typeMap;
|
|
51
51
|
}, [introspectionData]);
|
|
52
52
|
|
|
53
|
-
const activeFilters = [];
|
|
53
|
+
// const activeFilters = [];
|
|
54
54
|
|
|
55
55
|
// if (!filterTypeMap.size) {
|
|
56
56
|
// return;
|
|
@@ -59,26 +59,51 @@ export const useShopBy = props => {
|
|
|
59
59
|
const filters = getFiltersFromSearch(search);
|
|
60
60
|
|
|
61
61
|
// Construct the filter arg object.
|
|
62
|
-
const newFilters = {};
|
|
63
|
-
filters.forEach((values, key) => {
|
|
64
|
-
|
|
62
|
+
// const newFilters = {};
|
|
63
|
+
// filters.forEach((values, key) => {
|
|
64
|
+
// newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
// if (key == "sc_baseball_release") {
|
|
67
|
+
// for(let item of values) {
|
|
68
|
+
// if(item) {
|
|
69
|
+
// // console.log(item.split(',')[0])
|
|
70
|
+
// const data = search.split('&');
|
|
71
|
+
// data.pop();
|
|
72
|
+
// activeFilters.push(
|
|
73
|
+
// {
|
|
74
|
+
// 'label': item.split(',')[0],
|
|
75
|
+
// 'path': data
|
|
76
|
+
// }
|
|
77
|
+
// )
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// });
|
|
82
|
+
const { newFilters, activeFilters } = useMemo(() => {
|
|
83
|
+
const resultFilters = {};
|
|
84
|
+
const resultActiveFilters = [];
|
|
85
|
+
|
|
86
|
+
if (filterTypeMap.size) {
|
|
87
|
+
filters.forEach((values, key) => {
|
|
88
|
+
resultFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
89
|
+
|
|
90
|
+
if (key === "sc_baseball_release") {
|
|
91
|
+
for (let item of values) {
|
|
92
|
+
if (item) {
|
|
93
|
+
const data = search.split('&');
|
|
94
|
+
data.pop();
|
|
95
|
+
resultActiveFilters.push({
|
|
96
|
+
label: item.split(',')[0],
|
|
97
|
+
path: data
|
|
98
|
+
});
|
|
76
99
|
}
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
80
103
|
}
|
|
81
|
-
|
|
104
|
+
|
|
105
|
+
return { newFilters: resultFilters, activeFilters: resultActiveFilters };
|
|
106
|
+
}, [filterTypeMap]);
|
|
82
107
|
|
|
83
108
|
useEffect(() => {
|
|
84
109
|
|
|
@@ -130,7 +155,7 @@ export const useShopBy = props => {
|
|
|
130
155
|
return null;
|
|
131
156
|
}
|
|
132
157
|
|
|
133
|
-
const rawData = queryResponse?.
|
|
158
|
+
const rawData = queryResponse?.shopByData?.data?.options;
|
|
134
159
|
if (!rawData) {
|
|
135
160
|
return null;
|
|
136
161
|
}
|
|
@@ -160,7 +185,7 @@ export const useShopBy = props => {
|
|
|
160
185
|
return null;
|
|
161
186
|
}
|
|
162
187
|
|
|
163
|
-
const rawData = queryResponse?.
|
|
188
|
+
const rawData = queryResponse?.shopByData?.data?.options;
|
|
164
189
|
if (!rawData) {
|
|
165
190
|
return null;
|
|
166
191
|
}
|
|
@@ -227,7 +252,7 @@ export const useShopBy = props => {
|
|
|
227
252
|
}
|
|
228
253
|
|
|
229
254
|
|
|
230
|
-
const attributeData = queryResponse?.
|
|
255
|
+
const attributeData = queryResponse?.shopByData?.data && queryResponse?.shopByData.data.length ? queryResponse.shopByData.data[0] : null
|
|
231
256
|
|
|
232
257
|
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
233
258
|
getCategoryContentQuery,
|
|
@@ -246,7 +271,7 @@ export const useShopBy = props => {
|
|
|
246
271
|
return null;
|
|
247
272
|
}
|
|
248
273
|
|
|
249
|
-
return queryResponse?.
|
|
274
|
+
return queryResponse?.shopByData?.page_info;
|
|
250
275
|
}, [queryResponse]);
|
|
251
276
|
|
|
252
277
|
const category =
|
|
@@ -255,8 +280,8 @@ export const useShopBy = props => {
|
|
|
255
280
|
: null;
|
|
256
281
|
|
|
257
282
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
283
|
+
error,
|
|
284
|
+
loading,
|
|
260
285
|
dataResult,
|
|
261
286
|
// collectibleGameSets,
|
|
262
287
|
filteredAvailableGroups,
|