@riosst100/pwa-marketplace 1.8.8 → 1.8.9
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/LegoSets/legoSets.js +50 -19
- package/src/components/NonSportCardsSets/nonSportCardsSets.js +15 -2
- package/src/components/ShopBy/shopBy.js +8 -1
- package/src/components/ShopByVehicles/index.js +2 -0
- package/src/components/ShopByVehicles/shopByVehicles.js +328 -0
- package/src/components/ShopByVehicles/shopByVehicles.shimmer.js +50 -0
- package/src/components/SportCardsSets/sportCardsSets.js +6 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +4 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +1 -1
- package/src/talons/LegoSets/legoSets.gql.js +2 -2
- package/src/talons/LegoSets/useLegoSets.js +4 -2
- package/src/talons/NonSportCardsSets/useNonSportCardsSets.js +1 -1
- package/src/talons/ShopBy/useShopBy.js +13 -3
- package/src/talons/ShopByVehicles/shopByVehicles.gql.js +59 -0
- package/src/talons/ShopByVehicles/useShopByVehicles.js +222 -0
- package/src/talons/SportCardsSets/useSportCardsSets.js +1 -1
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ const LegoSets = props => {
|
|
|
23
23
|
|
|
24
24
|
const [active, setActive] = useState('all');
|
|
25
25
|
const [activeTab, setActiveTab] = useState('all');
|
|
26
|
-
|
|
26
|
+
const [activeFilter, setActiveFilter] = useState('');
|
|
27
27
|
const [searchQuery, setSearchQuery] = useState('');
|
|
28
28
|
|
|
29
29
|
const shopby = query.get('shopby') || null;
|
|
@@ -69,7 +69,7 @@ const LegoSets = props => {
|
|
|
69
69
|
|
|
70
70
|
const classes = useStyle(defaultClasses);
|
|
71
71
|
|
|
72
|
-
const talonProps = useLegoSets({ searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
72
|
+
const talonProps = useLegoSets({ activeFilter, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
73
73
|
|
|
74
74
|
const { error, loading, legoSets, categoryUrlSuffix, categoryUrlKey, productType, filteredLegoSets, availableGroups, category } = talonProps;
|
|
75
75
|
|
|
@@ -106,11 +106,11 @@ const LegoSets = props => {
|
|
|
106
106
|
let allSetsTitle = "Sets";
|
|
107
107
|
let attributeCode = "lego_set_name";
|
|
108
108
|
let byYearTitle = "By Year";
|
|
109
|
-
if (shopby == "singles") {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
109
|
+
// if (shopby == "singles") {
|
|
110
|
+
// attributeCode = "lego_set_name";
|
|
111
|
+
// // allSetsTitle = "Singles";
|
|
112
|
+
// byYearTitle = "By Year";
|
|
113
|
+
// }
|
|
114
114
|
|
|
115
115
|
const setRelases = newLegoSets && newLegoSets.length && newLegoSets.map((setRelease, index) => {
|
|
116
116
|
const { group, sets } = setRelease;
|
|
@@ -127,7 +127,8 @@ const LegoSets = props => {
|
|
|
127
127
|
|
|
128
128
|
setsResult.push(<li className='list-none'>
|
|
129
129
|
<Link to={categoryUrl} className="hover_bg-darkblue-900 hover_text-white w-full block text-[14px] py-[2px] px-2">
|
|
130
|
-
{set_name}
|
|
130
|
+
<b>{set_name}</b>
|
|
131
|
+
<div style={{"fontSize": "12px"}}>589 Parts, 2 Minifigures</div>
|
|
131
132
|
</Link>
|
|
132
133
|
</li>)
|
|
133
134
|
})
|
|
@@ -167,7 +168,8 @@ const LegoSets = props => {
|
|
|
167
168
|
|
|
168
169
|
const handleActiveTab = (val) => {
|
|
169
170
|
setActiveTab(val);
|
|
170
|
-
setActive('all')
|
|
171
|
+
setActive('all');
|
|
172
|
+
setActiveFilter('');
|
|
171
173
|
|
|
172
174
|
setSearchQuery('')
|
|
173
175
|
}
|
|
@@ -182,19 +184,26 @@ const LegoSets = props => {
|
|
|
182
184
|
if (activeTab == "year") {
|
|
183
185
|
title = "Sets | By Year";
|
|
184
186
|
}
|
|
187
|
+
|
|
188
|
+
const availableFilters = [
|
|
189
|
+
'Theme',
|
|
190
|
+
'Sub-Theme',
|
|
191
|
+
'Interest',
|
|
192
|
+
'Age Level'
|
|
193
|
+
];
|
|
185
194
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
195
|
+
const handleActiveFilter = (val) => {
|
|
196
|
+
setActiveFilter(val);
|
|
197
|
+
|
|
198
|
+
setActive('all');
|
|
199
|
+
|
|
200
|
+
setSearchQuery('')
|
|
191
201
|
}
|
|
192
|
-
|
|
193
202
|
|
|
194
203
|
return (
|
|
195
204
|
<Fragment>
|
|
196
205
|
<StoreTitle>{title}</StoreTitle>
|
|
197
|
-
<Breadcrumbs categoryId={categoryId} customPage={title} />
|
|
206
|
+
<Breadcrumbs categoryId={categoryId} customPage={shopby == "singles" ? "Mini-Figures" : title} />
|
|
198
207
|
<ul className={classes.nav}>
|
|
199
208
|
<li className={classes.nav_item}>
|
|
200
209
|
<button
|
|
@@ -215,10 +224,32 @@ const LegoSets = props => {
|
|
|
215
224
|
</button>
|
|
216
225
|
</li>
|
|
217
226
|
</ul>
|
|
227
|
+
{shopby == "lego_set_name" && activeTab == "all" ? <><ul className={classes.nav}>
|
|
228
|
+
{availableFilters.map((group, index) => (
|
|
229
|
+
<li key={index} className={classes.nav_item}>
|
|
230
|
+
<button
|
|
231
|
+
onClick={() => {
|
|
232
|
+
handleActiveFilter(group)
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
{activeFilter == group ? <b>{group}</b> : group}
|
|
236
|
+
</button>
|
|
237
|
+
</li>
|
|
238
|
+
))}<li className={classes.nav_item}>
|
|
239
|
+
<button
|
|
240
|
+
onClick={() => {
|
|
241
|
+
handleActiveFilter('')
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
{!activeFilter ? <b>A-Z</b> : 'A-Z'}
|
|
245
|
+
</button>
|
|
246
|
+
</li></ul>
|
|
247
|
+
|
|
248
|
+
</> : ''}
|
|
218
249
|
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
219
250
|
{title}
|
|
220
251
|
</h1>
|
|
221
|
-
{activeTab == "year" && <ul className={classes.nav}>
|
|
252
|
+
{activeTab == "year" && availableGroups ? <ul className={classes.nav}>
|
|
222
253
|
{availableGroups.map((group, index) => (
|
|
223
254
|
<li key={index} className={classes.nav_item}>
|
|
224
255
|
<button
|
|
@@ -239,7 +270,7 @@ const LegoSets = props => {
|
|
|
239
270
|
{active == 'all' ? <b>All</b> : 'All'}
|
|
240
271
|
</button>
|
|
241
272
|
</li>
|
|
242
|
-
</ul>}
|
|
273
|
+
</ul> : ''}
|
|
243
274
|
<div className='border border-gray-100 px-6'>
|
|
244
275
|
{legoSets ? (
|
|
245
276
|
<div
|
|
@@ -250,7 +281,7 @@ const LegoSets = props => {
|
|
|
250
281
|
</div>
|
|
251
282
|
) : ''}
|
|
252
283
|
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
253
|
-
{activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
284
|
+
{!activeFilter && activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
254
285
|
<li>
|
|
255
286
|
<button
|
|
256
287
|
className={cn(
|
|
@@ -32,9 +32,13 @@ const NonSportCardsSets = props => {
|
|
|
32
32
|
let availableBrands = [];
|
|
33
33
|
|
|
34
34
|
const shopby = query.get('shopby') || null;
|
|
35
|
-
|
|
35
|
+
let setType = query.get('nsc_set_type[filter]') || null;
|
|
36
36
|
const brandsFilter = query.get('sc_brands[filter]') || null;
|
|
37
37
|
|
|
38
|
+
if (setType && setType.includes("Inserts")) {
|
|
39
|
+
setType = "Inserts";
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
let defaultSort = {
|
|
39
43
|
sortText: 'All (A-Z)',
|
|
40
44
|
value: 'all'
|
|
@@ -200,10 +204,19 @@ const NonSportCardsSets = props => {
|
|
|
200
204
|
setSearchQuery('')
|
|
201
205
|
}
|
|
202
206
|
|
|
207
|
+
const handleSearchQuery = (val) => {
|
|
208
|
+
setSearchQuery(val)
|
|
209
|
+
setActive('all')
|
|
210
|
+
}
|
|
211
|
+
|
|
203
212
|
let brandName = brandsFilter ? brandsFilter.split(',')[0] : '';
|
|
204
213
|
|
|
205
214
|
let title = "By Release/Set";
|
|
206
215
|
|
|
216
|
+
if (setType && setType == "Inserts") {
|
|
217
|
+
title = "Insert Sets";
|
|
218
|
+
}
|
|
219
|
+
|
|
207
220
|
return (
|
|
208
221
|
<Fragment>
|
|
209
222
|
<StoreTitle>{title}</StoreTitle>
|
|
@@ -238,7 +251,7 @@ const NonSportCardsSets = props => {
|
|
|
238
251
|
<div
|
|
239
252
|
className={classes.toolbar}
|
|
240
253
|
>
|
|
241
|
-
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={
|
|
254
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
242
255
|
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
243
256
|
</div>
|
|
244
257
|
) : ''}
|
|
@@ -214,6 +214,13 @@ const ShopBy = props => {
|
|
|
214
214
|
setSearchQuery('')
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
// let availableSortBy = [
|
|
218
|
+
// {
|
|
219
|
+
// 'label': 'All (A-Z)',
|
|
220
|
+
// 'value': 'all'
|
|
221
|
+
// }
|
|
222
|
+
// ];
|
|
223
|
+
|
|
217
224
|
let availableSortBy = [
|
|
218
225
|
{
|
|
219
226
|
'label': 'All (A-Z)',
|
|
@@ -239,7 +246,7 @@ const ShopBy = props => {
|
|
|
239
246
|
<CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} />
|
|
240
247
|
</div>
|
|
241
248
|
) : ''}
|
|
242
|
-
{shopby != "lego_age_level" && productType != "expansion-sets" ? (
|
|
249
|
+
{shopby != "trains_gauge" && shopby != "vehicles_scale" && shopby != "lego_theme" && shopby != "lego_subtheme" && shopby != "lego_interest" && shopby != "lego_age_level" && productType != "expansion-sets" ? (
|
|
243
250
|
<>
|
|
244
251
|
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
245
252
|
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import React, { Fragment, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
3
|
+
import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
|
|
4
|
+
import { useShopByVehicles } from '@riosst100/pwa-marketplace/src/talons/ShopByVehicles/useShopByVehicles';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import defaultClasses from './shopByVehicles.module.css';
|
|
8
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
9
|
+
import cn from 'classnames';
|
|
10
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
11
|
+
import { ShopByVehiclesShimmer } from '@riosst100/pwa-marketplace/src/components/ShopByVehicles';
|
|
12
|
+
import CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
|
|
13
|
+
import ArraySearchInput from '@riosst100/pwa-marketplace/src/components/ArraySearchInput';
|
|
14
|
+
import { useCustomSort } from '@riosst100/pwa-marketplace/src/hooks/useCustomSort';
|
|
15
|
+
import Breadcrumbs from '@magento/venia-ui/lib/components/Breadcrumbs';
|
|
16
|
+
|
|
17
|
+
const ShopByVehicles = props => {
|
|
18
|
+
const { categoryId } = props
|
|
19
|
+
|
|
20
|
+
const { location } = globalThis;
|
|
21
|
+
|
|
22
|
+
const query = new URLSearchParams(location.search);
|
|
23
|
+
|
|
24
|
+
const [active, setActive] = useState('all');
|
|
25
|
+
const [activeTab, setActiveTab] = useState('all');
|
|
26
|
+
const [activeFilter, setActiveFilter] = useState('');
|
|
27
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
28
|
+
|
|
29
|
+
const shopby = query.get('shopby') || null;
|
|
30
|
+
const setType = query.get('set_type') || null;
|
|
31
|
+
|
|
32
|
+
let defaultSort = {
|
|
33
|
+
sortText: 'All (A-Z)',
|
|
34
|
+
value: 'all'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (shopby == "release_year") {
|
|
38
|
+
defaultSort = {
|
|
39
|
+
sortText: 'All (By Year)',
|
|
40
|
+
value: 'date'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if (productType == "expansion_sets") {
|
|
45
|
+
// defaultSort = {
|
|
46
|
+
// sortText: 'All (Expansion Sets)',
|
|
47
|
+
// value: 'all'
|
|
48
|
+
// };
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
// Sorting
|
|
52
|
+
const sortProps = useCustomSort({ sortFromSearch: false, defaultSort: defaultSort});
|
|
53
|
+
const [currentSort] = sortProps;
|
|
54
|
+
// const [sortBy, setSortBy] = useState({
|
|
55
|
+
// sortText: 'All (A-Z)',
|
|
56
|
+
// value: 'all'
|
|
57
|
+
// });
|
|
58
|
+
|
|
59
|
+
// let availableSortBy = [
|
|
60
|
+
// {
|
|
61
|
+
// 'label': 'All (A-Z)',
|
|
62
|
+
// 'value': 'all'
|
|
63
|
+
// },
|
|
64
|
+
// {
|
|
65
|
+
// 'label': 'By Year',
|
|
66
|
+
// 'value': 'newest'
|
|
67
|
+
// }
|
|
68
|
+
// ];
|
|
69
|
+
|
|
70
|
+
const classes = useStyle(defaultClasses);
|
|
71
|
+
|
|
72
|
+
const talonProps = useShopByVehicles({ activeFilter, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
73
|
+
|
|
74
|
+
const { error, loading, shopByVehicles, categoryUrlSuffix, categoryUrlKey, productType, filteredShopByVehicles, availableGroups, category } = talonProps;
|
|
75
|
+
|
|
76
|
+
if (loading && !shopByVehicles)
|
|
77
|
+
return <ShopByVehiclesShimmer />;
|
|
78
|
+
if (error && !shopByVehicles) return <ErrorView />;
|
|
79
|
+
|
|
80
|
+
if (!shopByVehicles && !loading && !error) {
|
|
81
|
+
return <ShopByVehiclesShimmer />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const setsLengthArr = [];
|
|
85
|
+
|
|
86
|
+
const newShopByVehicles = searchQuery ? filteredShopByVehicles : shopByVehicles;
|
|
87
|
+
|
|
88
|
+
// useEffect(() => {
|
|
89
|
+
if (shopByVehicles && shopByVehicles.length) {
|
|
90
|
+
shopByVehicles.map((setRelease, index) => {
|
|
91
|
+
const { group, sets } = setRelease;
|
|
92
|
+
|
|
93
|
+
setsLengthArr[group] = sets.length
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
// }, [shopByVehicles])
|
|
97
|
+
|
|
98
|
+
const splitToNChunks = (array, n) => {
|
|
99
|
+
let result = [];
|
|
100
|
+
for (let i = n; i > 0; i--) {
|
|
101
|
+
result.push(array.splice(0, Math.ceil(array.length / i)));
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let allSetsTitle = "Sets";
|
|
107
|
+
let attributeCode = "lego_set_name";
|
|
108
|
+
let byYearTitle = "By Year";
|
|
109
|
+
// if (shopby == "singles") {
|
|
110
|
+
// attributeCode = "lego_set_name";
|
|
111
|
+
// // allSetsTitle = "Singles";
|
|
112
|
+
// byYearTitle = "By Year";
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
const setRelases = newShopByVehicles && newShopByVehicles.length && newShopByVehicles.map((setRelease, index) => {
|
|
116
|
+
const { group, sets } = setRelease;
|
|
117
|
+
|
|
118
|
+
const setsResult = [];
|
|
119
|
+
|
|
120
|
+
if (sets.length) {
|
|
121
|
+
sets.map((set, index) => {
|
|
122
|
+
const { set_name, option_id, release_year } = set;
|
|
123
|
+
|
|
124
|
+
const categoryUrl = resourceUrl(
|
|
125
|
+
`/${category?.url_path}${categoryUrlSuffix || ''}?${attributeCode}[filter]=${set_name},${option_id}`
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
setsResult.push(<li className='list-none'>
|
|
129
|
+
<Link to={categoryUrl} className="hover_bg-darkblue-900 hover_text-white w-full block text-[14px] py-[2px] px-2">
|
|
130
|
+
<b>{set_name}</b>
|
|
131
|
+
<div style={{"fontSize": "12px"}}>589 Parts, 2 Minifigures</div>
|
|
132
|
+
</Link>
|
|
133
|
+
</li>)
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let setsResultSplitted = [];
|
|
138
|
+
if (active == group || newShopByVehicles.length == 1) {
|
|
139
|
+
setsResultSplitted = splitToNChunks(setsResult, 3);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
{active == "all" && newShopByVehicles.length > 1 ?
|
|
145
|
+
<div className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
146
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' >
|
|
147
|
+
{group}
|
|
148
|
+
</div>
|
|
149
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
150
|
+
</div> : ''}
|
|
151
|
+
{active == group || newShopByVehicles.length == 1 ? setsResultSplitted && setsResultSplitted.length && setsResultSplitted.map((setsResult, index) =>
|
|
152
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
153
|
+
{index == 0 ? <div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
154
|
+
<div className='singles_item_group_letter text-xl font-semibold pb-1 mb-2' style={{"marginTop":"35px"}}></div>}
|
|
155
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
: ''}
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const handleActive = (val) => {
|
|
164
|
+
setActive(val);
|
|
165
|
+
|
|
166
|
+
setSearchQuery('')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const handleActiveTab = (val) => {
|
|
170
|
+
setActiveTab(val);
|
|
171
|
+
setActive('all');
|
|
172
|
+
setActiveFilter('');
|
|
173
|
+
|
|
174
|
+
setSearchQuery('')
|
|
175
|
+
}
|
|
176
|
+
const handleSearchQuery = (val) => {
|
|
177
|
+
setSearchQuery(val)
|
|
178
|
+
setActive('all')
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
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'];
|
|
182
|
+
|
|
183
|
+
let title = "Sets";
|
|
184
|
+
if (activeTab == "year") {
|
|
185
|
+
title = "Sets | By Year";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const availableFilters = [
|
|
189
|
+
'Theme',
|
|
190
|
+
'Sub-Theme',
|
|
191
|
+
'Interest',
|
|
192
|
+
'Age Level'
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
const handleActiveFilter = (val) => {
|
|
196
|
+
setActiveFilter(val);
|
|
197
|
+
|
|
198
|
+
setActive('all');
|
|
199
|
+
|
|
200
|
+
setSearchQuery('')
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Fragment>
|
|
205
|
+
<StoreTitle>{title}</StoreTitle>
|
|
206
|
+
<Breadcrumbs categoryId={categoryId} customPage={shopby == "singles" ? "Mini-Figures" : title} />
|
|
207
|
+
<ul className={classes.nav}>
|
|
208
|
+
<li className={classes.nav_item}>
|
|
209
|
+
<button
|
|
210
|
+
onClick={() => {
|
|
211
|
+
handleActiveTab('year')
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
{activeTab == 'year' ? <b>{byYearTitle}</b> : byYearTitle}
|
|
215
|
+
</button>
|
|
216
|
+
</li>
|
|
217
|
+
<li className={classes.nav_item}>
|
|
218
|
+
<button
|
|
219
|
+
onClick={() => {
|
|
220
|
+
handleActiveTab('all')
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
{activeTab == 'all' ? <b>{allSetsTitle}</b> : allSetsTitle}
|
|
224
|
+
</button>
|
|
225
|
+
</li>
|
|
226
|
+
</ul>
|
|
227
|
+
{shopby == "lego_set_name" && activeTab == "all" ? <><ul className={classes.nav}>
|
|
228
|
+
{availableFilters.map((group, index) => (
|
|
229
|
+
<li key={index} className={classes.nav_item}>
|
|
230
|
+
<button
|
|
231
|
+
onClick={() => {
|
|
232
|
+
handleActiveFilter(group)
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
{activeFilter == group ? <b>{group}</b> : group}
|
|
236
|
+
</button>
|
|
237
|
+
</li>
|
|
238
|
+
))}<li className={classes.nav_item}>
|
|
239
|
+
<button
|
|
240
|
+
onClick={() => {
|
|
241
|
+
handleActiveFilter('')
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
{!activeFilter ? <b>A-Z</b> : 'A-Z'}
|
|
245
|
+
</button>
|
|
246
|
+
</li></ul>
|
|
247
|
+
|
|
248
|
+
</> : ''}
|
|
249
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
250
|
+
{title}
|
|
251
|
+
</h1>
|
|
252
|
+
{activeTab == "year" && availableGroups ? <ul className={classes.nav}>
|
|
253
|
+
{availableGroups.map((group, index) => (
|
|
254
|
+
<li key={index} className={classes.nav_item}>
|
|
255
|
+
<button
|
|
256
|
+
onClick={() => {
|
|
257
|
+
handleActive(group)
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
260
|
+
{active == group ? <b>{group}</b> : group}
|
|
261
|
+
</button>
|
|
262
|
+
</li>
|
|
263
|
+
))}
|
|
264
|
+
<li className={classes.nav_item}>
|
|
265
|
+
<button
|
|
266
|
+
onClick={() => {
|
|
267
|
+
handleActive('all')
|
|
268
|
+
}}
|
|
269
|
+
>
|
|
270
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
271
|
+
</button>
|
|
272
|
+
</li>
|
|
273
|
+
</ul> : ''}
|
|
274
|
+
<div className='border border-gray-100 px-6'>
|
|
275
|
+
{shopByVehicles ? (
|
|
276
|
+
<div
|
|
277
|
+
className={classes.toolbar}
|
|
278
|
+
>
|
|
279
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
280
|
+
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
281
|
+
</div>
|
|
282
|
+
) : ''}
|
|
283
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
284
|
+
{!activeFilter && activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
285
|
+
<li>
|
|
286
|
+
<button
|
|
287
|
+
className={cn(
|
|
288
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
289
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
290
|
+
)}
|
|
291
|
+
onClick={() => {
|
|
292
|
+
handleActive('all')
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
296
|
+
</button>
|
|
297
|
+
</li>
|
|
298
|
+
{alpha.map((letter, index) => (
|
|
299
|
+
<li key={index}>
|
|
300
|
+
<button
|
|
301
|
+
className={cn(
|
|
302
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
303
|
+
'leading-4 font-medium text-base ',
|
|
304
|
+
setsLengthArr[letter] > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
305
|
+
)}
|
|
306
|
+
onClick={() => {
|
|
307
|
+
handleActive(letter)
|
|
308
|
+
}}
|
|
309
|
+
disabled={setsLengthArr[letter] > 0 ? false : true}
|
|
310
|
+
>
|
|
311
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
312
|
+
</button>
|
|
313
|
+
</li>
|
|
314
|
+
))}
|
|
315
|
+
</ul>}
|
|
316
|
+
</section>
|
|
317
|
+
<Divider className="mb-5 px-4 mt-5" />
|
|
318
|
+
<section className='singles-container'>
|
|
319
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
320
|
+
{newShopByVehicles && newShopByVehicles.length ? 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>)}
|
|
321
|
+
</div>
|
|
322
|
+
</section>
|
|
323
|
+
</div>
|
|
324
|
+
</Fragment>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export default ShopByVehicles;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shape, string } from 'prop-types';
|
|
3
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
4
|
+
|
|
5
|
+
import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
|
|
6
|
+
import defaultClasses from './shopByVehicles.module.css';
|
|
7
|
+
import cn from 'classnames';
|
|
8
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
9
|
+
|
|
10
|
+
const ShopByVehicles = props => {
|
|
11
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'><Shimmer width="25%" height="6vh" /></h1>
|
|
16
|
+
<div className='border border-gray-100 px-6'>
|
|
17
|
+
<center>
|
|
18
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
19
|
+
<Shimmer width="95%" height="6vh" />
|
|
20
|
+
</section>
|
|
21
|
+
</center>
|
|
22
|
+
<Divider className="mb-5 px-4" />
|
|
23
|
+
<section className='singles-container'>
|
|
24
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
25
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
26
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
27
|
+
</div>
|
|
28
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
29
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
30
|
+
</div>
|
|
31
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
32
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
33
|
+
</div>
|
|
34
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
35
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
36
|
+
</div>
|
|
37
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
38
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
39
|
+
</div>
|
|
40
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
41
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' ><Shimmer width="95%" height="100vh" /></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</section>
|
|
45
|
+
</div>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default ShopByVehicles;
|
|
@@ -206,6 +206,11 @@ const SportCardsSets = props => {
|
|
|
206
206
|
setSearchQuery('')
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
const handleSearchQuery = (val) => {
|
|
210
|
+
setSearchQuery(val)
|
|
211
|
+
setActive('all')
|
|
212
|
+
}
|
|
213
|
+
|
|
209
214
|
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'];
|
|
210
215
|
|
|
211
216
|
let brandName = brandsFilter ? brandsFilter.split(',')[0] : '';
|
|
@@ -303,7 +308,7 @@ const SportCardsSets = props => {
|
|
|
303
308
|
<div
|
|
304
309
|
className={classes.toolbar}
|
|
305
310
|
>
|
|
306
|
-
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={
|
|
311
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
307
312
|
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
308
313
|
</div>
|
|
309
314
|
) : ''}
|
|
@@ -91,6 +91,10 @@ const CategoryContent = props => {
|
|
|
91
91
|
if (urlKey == "non-sports-cards") {
|
|
92
92
|
history.replace('/cards/non-sports-cards/comics.html')
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
if (urlKey == "age-level" || urlKey == "lego" || urlKey == "minifigures" || urlKey == "sub-theme" || urlKey == "theme" || urlKey == "interest") {
|
|
96
|
+
history.replace('/lego-toys/lego/sets.html')
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
}, [category]);
|
|
96
100
|
|
|
@@ -624,7 +624,7 @@ const ProductFullDetail = props => {
|
|
|
624
624
|
</div>
|
|
625
625
|
</div>
|
|
626
626
|
</Link>
|
|
627
|
-
<Link class="flex items-center justify-center gap-[5px] py-1 px-5 relative bg-white rounded-[30px] border border-solid border-[#6243fa]">
|
|
627
|
+
<Link to={"/seller/"+sellerDetails.url_key} class="flex items-center justify-center gap-[5px] py-1 px-5 relative bg-white rounded-[30px] border border-solid border-[#6243fa]">
|
|
628
628
|
<div class="flex items-center justify-center gap-[10px] relative">
|
|
629
629
|
<Shop color="#6243FA" size={14} variant="Outline" className='stroke-[#6243FA]' />
|
|
630
630
|
<div class="relative xs_hidden lg_flex w-fit font-medium text-[#6243fa] text-[14px] tracking-[0] leading-[20px] whitespace-nowrap">
|
|
@@ -12,8 +12,8 @@ export const GET_STORE_CONFIG_DATA = gql`
|
|
|
12
12
|
`;
|
|
13
13
|
|
|
14
14
|
export const GET_LEGO_SETS_QUERY = gql`
|
|
15
|
-
query getLegoSets($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String) {
|
|
16
|
-
legoSets(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby) {
|
|
15
|
+
query getLegoSets($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
|
|
16
|
+
legoSets(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby, activeFilter: $activeFilter) {
|
|
17
17
|
group
|
|
18
18
|
sets {
|
|
19
19
|
set_name
|
|
@@ -93,13 +93,15 @@ export const useLegoSets = props => {
|
|
|
93
93
|
filters: newFilters,
|
|
94
94
|
categoryUrlKey: categoryUrlKey,
|
|
95
95
|
activeTab: activeTab,
|
|
96
|
-
shopby: shopby
|
|
96
|
+
shopby: shopby,
|
|
97
|
+
activeFilter: activeFilter
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
100
|
// }
|
|
100
101
|
}, [
|
|
101
102
|
runQuery,
|
|
102
|
-
activeTab
|
|
103
|
+
activeTab,
|
|
104
|
+
activeFilter
|
|
103
105
|
// queryResponse
|
|
104
106
|
// filterTypeMap,
|
|
105
107
|
// search,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
2
2
|
import { useEffect, useMemo } from 'react';
|
|
3
3
|
import { useLocation } from 'react-router-dom';
|
|
4
|
-
import { useAppContext } from '@magento/peregrine/lib/context/app';
|
|
5
4
|
|
|
6
5
|
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
7
6
|
import DEFAULT_OPERATIONS from './shopBy.gql';
|
|
@@ -141,6 +140,9 @@ export const useShopBy = props => {
|
|
|
141
140
|
if (!alpha.includes(firstLetter)) {
|
|
142
141
|
firstLetter = '#';
|
|
143
142
|
}
|
|
143
|
+
if (shopby == "trains_gauge" || shopby == "vehicles_scale" || shopby == "lego_theme" || shopby == "lego_subtheme" || shopby == "lego_interest") {
|
|
144
|
+
firstLetter = '#';
|
|
145
|
+
}
|
|
144
146
|
acc[firstLetter] = acc[firstLetter] || [];
|
|
145
147
|
acc[firstLetter].push(item);
|
|
146
148
|
return acc;
|
|
@@ -199,6 +201,9 @@ export const useShopBy = props => {
|
|
|
199
201
|
if (!alpha.includes(firstLetter)) {
|
|
200
202
|
firstLetter = '#';
|
|
201
203
|
}
|
|
204
|
+
if (shopby == "trains_gauge" || shopby == "vehicles_scale" || shopby == "lego_theme" || shopby == "lego_subtheme" || shopby == "lego_interest") {
|
|
205
|
+
firstLetter = '#';
|
|
206
|
+
}
|
|
202
207
|
acc[firstLetter] = acc[firstLetter] || [];
|
|
203
208
|
acc[firstLetter].push(item);
|
|
204
209
|
return acc;
|
|
@@ -210,9 +215,14 @@ export const useShopBy = props => {
|
|
|
210
215
|
|
|
211
216
|
// console.log(dataResult)
|
|
212
217
|
|
|
213
|
-
|
|
218
|
+
let availableGroups = originalDataResult ? Object.keys(originalDataResult).sort() : [];
|
|
214
219
|
|
|
215
|
-
|
|
220
|
+
let filteredAvailableGroups = dataResult ? Object.keys(dataResult).sort() : [];
|
|
221
|
+
|
|
222
|
+
if (shopby == "trains_gauge" || shopby == "vehicles_scale" || shopby == "lego_theme" || shopby == "lego_subtheme" || shopby == "lego_interest") {
|
|
223
|
+
availableGroups = ['#'];
|
|
224
|
+
filteredAvailableGroups = ['#'];
|
|
225
|
+
}
|
|
216
226
|
|
|
217
227
|
|
|
218
228
|
const attributeData = queryResponse?.data?.shopByData && queryResponse?.data?.shopByData.length ? queryResponse.data.shopByData[0] : null
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const GET_STORE_CONFIG_DATA = gql`
|
|
4
|
+
query getStoreConfigData {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
|
+
storeConfig {
|
|
7
|
+
store_code
|
|
8
|
+
product_url_suffix
|
|
9
|
+
category_url_suffix
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const GET_SHOP_BY_DATA_QUERY = gql`
|
|
15
|
+
query getShopByVehicles($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
|
|
16
|
+
shopByVehicles(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby, activeFilter: $activeFilter) {
|
|
17
|
+
group
|
|
18
|
+
sets {
|
|
19
|
+
set_name
|
|
20
|
+
option_id
|
|
21
|
+
release_year
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const GET_CATEGORY_CONTENT = gql`
|
|
28
|
+
query getCategoryData($id: String!) {
|
|
29
|
+
categories(filters: { category_uid: { in: [$id] } }) {
|
|
30
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
31
|
+
items {
|
|
32
|
+
uid
|
|
33
|
+
name
|
|
34
|
+
url_key
|
|
35
|
+
url_path
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export const GET_FILTER_INPUTS = gql`
|
|
42
|
+
query GetFilterInputsForCategory {
|
|
43
|
+
__type(name: "ProductAttributeFilterInput") {
|
|
44
|
+
inputFields {
|
|
45
|
+
name
|
|
46
|
+
type {
|
|
47
|
+
name
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
getStoreConfigData: GET_STORE_CONFIG_DATA,
|
|
56
|
+
getShopByVehiclesQuery: GET_SHOP_BY_DATA_QUERY,
|
|
57
|
+
getCategoryContentQuery: GET_CATEGORY_CONTENT,
|
|
58
|
+
getFilterInputsQuery: GET_FILTER_INPUTS,
|
|
59
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { useAppContext } from '@magento/peregrine/lib/context/app';
|
|
5
|
+
|
|
6
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
7
|
+
import DEFAULT_OPERATIONS from './shopByVehicles.gql';
|
|
8
|
+
import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
9
|
+
|
|
10
|
+
export const useShopByVehicles = props => {
|
|
11
|
+
|
|
12
|
+
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter } = props
|
|
13
|
+
|
|
14
|
+
const { value: sortby } = currentSort
|
|
15
|
+
|
|
16
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, null);
|
|
17
|
+
const { getStoreConfigData, getShopByVehiclesQuery, getCategoryContentQuery, getFilterInputsQuery } = operations;
|
|
18
|
+
const { pathname, search } = useLocation();
|
|
19
|
+
const [runQuery, queryResponse] = useLazyQuery(getShopByVehiclesQuery, {
|
|
20
|
+
fetchPolicy: 'cache-and-network',
|
|
21
|
+
nextFetchPolicy: 'cache-first'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const pathnameArr = pathname.split('/');
|
|
25
|
+
|
|
26
|
+
const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
|
|
27
|
+
const parentCategoryUrlKey = pathnameArr[pathnameArr.length - 2].replace('.html','');
|
|
28
|
+
const productType = shopby;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// const { error, loading, data } = useQuery(getShopByVehiclesQuery, {
|
|
33
|
+
// fetchPolicy: 'cache-and-network',
|
|
34
|
+
// nextFetchPolicy: 'cache-first',
|
|
35
|
+
// skip: !storeConfigData,
|
|
36
|
+
// variables: {
|
|
37
|
+
// categoryUrlKey: categoryUrlKey,
|
|
38
|
+
// setType: setType
|
|
39
|
+
// }
|
|
40
|
+
// });
|
|
41
|
+
const { data: introspectionData } = useQuery(getFilterInputsQuery);
|
|
42
|
+
|
|
43
|
+
const filterTypeMap = useMemo(() => {
|
|
44
|
+
const typeMap = new Map();
|
|
45
|
+
if (introspectionData) {
|
|
46
|
+
introspectionData.__type.inputFields.forEach(({ name, type }) => {
|
|
47
|
+
typeMap.set(name, type.name);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return typeMap;
|
|
51
|
+
}, [introspectionData]);
|
|
52
|
+
const filters = getFiltersFromSearch(search);
|
|
53
|
+
|
|
54
|
+
// console.log(search)
|
|
55
|
+
|
|
56
|
+
// Construct the filter arg object.
|
|
57
|
+
const newFilters = {};
|
|
58
|
+
filters.forEach((values, key) => {
|
|
59
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
60
|
+
// console.log(key)
|
|
61
|
+
// console.log(values)
|
|
62
|
+
|
|
63
|
+
if (key == "sc_baseball_release") {
|
|
64
|
+
for(let item of values) {
|
|
65
|
+
if(item) {
|
|
66
|
+
// console.log(item.split(',')[0])
|
|
67
|
+
const data = search.split('&');
|
|
68
|
+
data.pop();
|
|
69
|
+
activeFilters.push(
|
|
70
|
+
{
|
|
71
|
+
'label': item.split(',')[0],
|
|
72
|
+
'path': data
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
// console.log("MASUK")
|
|
82
|
+
|
|
83
|
+
// if (queryResponse.data) {
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// Use the category uid for the current category page regardless of the
|
|
88
|
+
// applied filters. Follow-up in PWA-404.
|
|
89
|
+
// newFilters['category_uid'] = { eq: id };
|
|
90
|
+
|
|
91
|
+
runQuery({
|
|
92
|
+
variables: {
|
|
93
|
+
filters: newFilters,
|
|
94
|
+
categoryUrlKey: categoryUrlKey,
|
|
95
|
+
activeTab: activeTab,
|
|
96
|
+
shopby: shopby,
|
|
97
|
+
activeFilter: activeFilter
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// }
|
|
101
|
+
}, [
|
|
102
|
+
runQuery,
|
|
103
|
+
activeTab,
|
|
104
|
+
activeFilter
|
|
105
|
+
// queryResponse
|
|
106
|
+
// filterTypeMap,
|
|
107
|
+
// search,
|
|
108
|
+
// newFilters,
|
|
109
|
+
// shopby,
|
|
110
|
+
// categoryUrlKey
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
const { data: storeConfigData } = useQuery(getStoreConfigData, {
|
|
114
|
+
fetchPolicy: 'cache-and-network',
|
|
115
|
+
nextFetchPolicy: 'cache-first'
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
|
|
119
|
+
|
|
120
|
+
// { data: queryResponse, error, loading }
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// console.log(data)
|
|
125
|
+
|
|
126
|
+
// const isBackgroundLoading = !!data && loading;
|
|
127
|
+
|
|
128
|
+
const availableLeagues = [];
|
|
129
|
+
|
|
130
|
+
// console.log(queryResponse.data)
|
|
131
|
+
|
|
132
|
+
const shopByVehicles = useMemo(() => {
|
|
133
|
+
if (!queryResponse) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// console.log(data)
|
|
138
|
+
|
|
139
|
+
const shopByVehicles = queryResponse?.data?.shopByVehicles;
|
|
140
|
+
if (!shopByVehicles) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return shopByVehicles.slice().sort((a, b) =>a.group.toLowerCase().localeCompare(b.group.toLowerCase()));
|
|
145
|
+
}, [queryResponse]);
|
|
146
|
+
|
|
147
|
+
const availableGroups = shopByVehicles && shopByVehicles.length ? shopByVehicles.map(({ group }) => group) : [];
|
|
148
|
+
|
|
149
|
+
// const availableLeagues = shopByVehicles && shopByVehicles.length ? shopByVehicles.map(({ sets }) => shopByVehicles.map(({ sc_league }) => sc_league)) : [];
|
|
150
|
+
// console.log(availableLeagues)
|
|
151
|
+
// sc_league
|
|
152
|
+
|
|
153
|
+
const filteredShopByVehicles = useMemo(() => {
|
|
154
|
+
if (!shopByVehicles) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const filteredSets = [];
|
|
159
|
+
|
|
160
|
+
if (searchQuery) {
|
|
161
|
+
|
|
162
|
+
// useEffect(() => {
|
|
163
|
+
// setActive('all')
|
|
164
|
+
// }, [active]);
|
|
165
|
+
|
|
166
|
+
shopByVehicles.map(({ group, sets }, index) => {
|
|
167
|
+
const newSets = sets.filter(function(set) {
|
|
168
|
+
return set.set_name.search(new RegExp(searchQuery, "i")) != -1 || group.search(new RegExp(searchQuery, "i")) != -1;
|
|
169
|
+
// return set.set_name.includes(searchQuery);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (newSets && newSets.length) {
|
|
173
|
+
filteredSets.push({
|
|
174
|
+
'group': group,
|
|
175
|
+
'sets': newSets
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return searchQuery ? filteredSets : shopByVehicles;
|
|
182
|
+
}, [shopByVehicles, searchQuery]);
|
|
183
|
+
|
|
184
|
+
// useEffect(() => {
|
|
185
|
+
// setPageLoading(isBackgroundLoading);
|
|
186
|
+
// }, [isBackgroundLoading, setPageLoading]);
|
|
187
|
+
|
|
188
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
189
|
+
getCategoryContentQuery,
|
|
190
|
+
{
|
|
191
|
+
fetchPolicy: 'cache-and-network',
|
|
192
|
+
nextFetchPolicy: 'cache-first',
|
|
193
|
+
skip: !categoryId,
|
|
194
|
+
variables: {
|
|
195
|
+
id: categoryId
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const category =
|
|
201
|
+
categoryData && categoryData.categories.items.length
|
|
202
|
+
? categoryData.categories.items[0]
|
|
203
|
+
: null;
|
|
204
|
+
|
|
205
|
+
const error = queryResponse?.error;
|
|
206
|
+
const loading = queryResponse?.loading;
|
|
207
|
+
|
|
208
|
+
// console.log(shopByVehicles)
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
error,
|
|
212
|
+
loading,
|
|
213
|
+
shopByVehicles,
|
|
214
|
+
filteredShopByVehicles,
|
|
215
|
+
categoryUrlSuffix,
|
|
216
|
+
categoryUrlKey,
|
|
217
|
+
productType,
|
|
218
|
+
availableGroups,
|
|
219
|
+
category,
|
|
220
|
+
// availableLeagues
|
|
221
|
+
};
|
|
222
|
+
};
|