@riosst100/pwa-marketplace 2.6.0 → 2.6.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/package.json +1 -1
- package/src/components/SetsData/setsData.js +48 -40
- package/src/components/SetsData/setsData.module.css +1 -1
- package/src/components/ShopBy/shopBy.js +5 -5
- 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/talons/SetsData/setsData.gql.js +6 -2
- package/src/talons/SetsData/useSetsData.js +61 -27
- package/src/talons/ShopBy/useShopBy.js +54 -26
package/package.json
CHANGED
|
@@ -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
|
|
@@ -403,7 +411,7 @@ const SetsData = props => {
|
|
|
403
411
|
<Divider className="mb-5 px-4 mt-5" />
|
|
404
412
|
<section className='singles-container'>
|
|
405
413
|
<div className={cn('singles-wrapper block', classes.singlesWrapper)}>
|
|
406
|
-
{
|
|
414
|
+
{setsData && Object.keys(setsData).length != 0 ? setRelases : (searchQuery ? <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No sets found for <b>{searchQuery}</b> search query.</div> : <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No sets found.</div>)}
|
|
407
415
|
</div>
|
|
408
416
|
</section>
|
|
409
417
|
</div>
|
|
@@ -112,12 +112,12 @@ 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
|
-
return <ShopByShimmer />;
|
|
117
|
-
if (error && !dataResult) return <ErrorView />;
|
|
115
|
+
console.log('dataResult SHOPBY', dataResult)
|
|
118
116
|
|
|
119
|
-
if (
|
|
117
|
+
if (loading) {
|
|
120
118
|
return <ShopByShimmer />;
|
|
119
|
+
} else if (error) {
|
|
120
|
+
return <ErrorView />;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
const newAvailableGroups = searchQuery ? filteredAvailableGroups : availableGroups;
|
|
@@ -425,7 +425,7 @@ const ShopBy = props => {
|
|
|
425
425
|
<Divider className="mb-5 px-4 mt-5" />
|
|
426
426
|
<section className='singles-container'>
|
|
427
427
|
<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>)}
|
|
428
|
+
{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
429
|
</div>
|
|
430
430
|
</section>
|
|
431
431
|
</div>
|
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,
|
|
@@ -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;
|
|
134
159
|
if (!rawData) {
|
|
135
160
|
return null;
|
|
136
161
|
}
|
|
@@ -156,11 +181,12 @@ export const useShopBy = props => {
|
|
|
156
181
|
}, [queryResponse, sortby]);
|
|
157
182
|
|
|
158
183
|
const filteredOptions = useMemo(() => {
|
|
184
|
+
console.log('queryResponse', queryResponse)
|
|
159
185
|
if (!queryResponse) {
|
|
160
186
|
return null;
|
|
161
187
|
}
|
|
162
188
|
|
|
163
|
-
const rawData = queryResponse?.
|
|
189
|
+
const rawData = queryResponse?.shopByData?.data;
|
|
164
190
|
if (!rawData) {
|
|
165
191
|
return null;
|
|
166
192
|
}
|
|
@@ -196,6 +222,8 @@ export const useShopBy = props => {
|
|
|
196
222
|
return options;
|
|
197
223
|
}, [queryResponse, searchQuery]);
|
|
198
224
|
|
|
225
|
+
console.log('filteredOptions',filteredOptions)
|
|
226
|
+
|
|
199
227
|
const dataResult = useMemo(() => {
|
|
200
228
|
if (filteredOptions) {
|
|
201
229
|
return filteredOptions.reduce((acc, item) => {
|
|
@@ -215,7 +243,7 @@ export const useShopBy = props => {
|
|
|
215
243
|
return filteredOptions;
|
|
216
244
|
}, [filteredOptions])
|
|
217
245
|
|
|
218
|
-
|
|
246
|
+
console.log('dataResult',dataResult)
|
|
219
247
|
|
|
220
248
|
let availableGroups = originalDataResult ? Object.keys(originalDataResult).sort() : [];
|
|
221
249
|
|
|
@@ -227,7 +255,7 @@ export const useShopBy = props => {
|
|
|
227
255
|
}
|
|
228
256
|
|
|
229
257
|
|
|
230
|
-
const attributeData = queryResponse?.
|
|
258
|
+
const attributeData = queryResponse?.shopByData?.data && queryResponse?.shopByData.data.length ? queryResponse.shopByData.data[0] : null
|
|
231
259
|
|
|
232
260
|
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
233
261
|
getCategoryContentQuery,
|
|
@@ -246,7 +274,7 @@ export const useShopBy = props => {
|
|
|
246
274
|
return null;
|
|
247
275
|
}
|
|
248
276
|
|
|
249
|
-
return queryResponse?.
|
|
277
|
+
return queryResponse?.shopByData?.page_info;
|
|
250
278
|
}, [queryResponse]);
|
|
251
279
|
|
|
252
280
|
const category =
|
|
@@ -255,8 +283,8 @@ export const useShopBy = props => {
|
|
|
255
283
|
: null;
|
|
256
284
|
|
|
257
285
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
286
|
+
error,
|
|
287
|
+
loading,
|
|
260
288
|
dataResult,
|
|
261
289
|
// collectibleGameSets,
|
|
262
290
|
filteredAvailableGroups,
|