@riosst100/pwa-marketplace 1.7.9 → 1.8.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/LegoSets/index.js +2 -0
- package/src/components/LegoSets/legoSets.js +279 -0
- package/src/components/LegoSets/legoSets.module.css +76 -0
- package/src/components/LegoSets/legoSets.shimmer.js +50 -0
- package/src/components/ShopBy/shopBy.js +41 -14
- package/src/components/SportCardsSets/sportCardsSets.js +110 -48
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +5 -1
- package/src/talons/FilterTop/filterTop.gql.js +2 -2
- package/src/talons/FilterTop/useFilterTop.js +6 -1
- package/src/talons/LegoSets/legoSets.gql.js +59 -0
- package/src/talons/LegoSets/useLegoSets.js +219 -0
- package/src/talons/ShopBy/useShopBy.js +36 -30
- package/src/talons/SportCardsSets/sportCardsSets.gql.js +18 -3
- package/src/talons/SportCardsSets/useSportCardsSets.js +108 -30
package/package.json
CHANGED
|
@@ -0,0 +1,279 @@
|
|
|
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 { useLegoSets } from '@riosst100/pwa-marketplace/src/talons/LegoSets/useLegoSets';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import defaultClasses from './legoSets.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 { LegoSetsShimmer } from '@riosst100/pwa-marketplace/src/components/LegoSets';
|
|
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 LegoSets = 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
|
+
|
|
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 = useLegoSets({ searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
73
|
+
|
|
74
|
+
const { error, loading, legoSets, categoryUrlSuffix, categoryUrlKey, productType, filteredLegoSets, availableGroups, category } = talonProps;
|
|
75
|
+
|
|
76
|
+
if (loading && !legoSets)
|
|
77
|
+
return <LegoSetsShimmer />;
|
|
78
|
+
if (error && !legoSets) return <ErrorView />;
|
|
79
|
+
|
|
80
|
+
if (!legoSets && !loading && !error) {
|
|
81
|
+
return <LegoSetsShimmer />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const setsLengthArr = [];
|
|
85
|
+
|
|
86
|
+
const newLegoSets = searchQuery ? filteredLegoSets : legoSets;
|
|
87
|
+
|
|
88
|
+
// useEffect(() => {
|
|
89
|
+
if (legoSets && legoSets.length) {
|
|
90
|
+
legoSets.map((setRelease, index) => {
|
|
91
|
+
const { group, sets } = setRelease;
|
|
92
|
+
|
|
93
|
+
setsLengthArr[group] = sets.length
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
// }, [legoSets])
|
|
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
|
+
const setRelases = newLegoSets && newLegoSets.length && newLegoSets.map((setRelease, index) => {
|
|
107
|
+
const { group, sets } = setRelease;
|
|
108
|
+
|
|
109
|
+
const setsResult = [];
|
|
110
|
+
|
|
111
|
+
if (sets.length) {
|
|
112
|
+
sets.map((set, index) => {
|
|
113
|
+
const { set_name, option_id, release_year } = set;
|
|
114
|
+
|
|
115
|
+
const categoryUrl = resourceUrl(
|
|
116
|
+
`/${category?.url_path}${categoryUrlSuffix || ''}?lego_set_name[filter]=${set_name},${option_id}`
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
setsResult.push(<li className='list-none'>
|
|
120
|
+
<Link to={categoryUrl} className="hover_bg-darkblue-900 hover_text-white w-full block text-[14px] py-[2px] px-2">
|
|
121
|
+
{set_name}
|
|
122
|
+
</Link>
|
|
123
|
+
</li>)
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let setsResultSplitted = [];
|
|
128
|
+
if (active == group || newLegoSets.length == 1) {
|
|
129
|
+
setsResultSplitted = splitToNChunks(setsResult, 3);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<>
|
|
134
|
+
{active == "all" && newLegoSets.length > 1 ?
|
|
135
|
+
<div className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
136
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' >
|
|
137
|
+
{group}
|
|
138
|
+
</div>
|
|
139
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
140
|
+
</div> : ''}
|
|
141
|
+
{active == group || newLegoSets.length == 1 ? setsResultSplitted && setsResultSplitted.length && setsResultSplitted.map((setsResult, index) =>
|
|
142
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
143
|
+
{index == 0 ? <div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
144
|
+
<div className='singles_item_group_letter text-xl font-semibold pb-1 mb-2' style={{"marginTop":"35px"}}></div>}
|
|
145
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
148
|
+
: ''}
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const handleActive = (val) => {
|
|
154
|
+
setActive(val);
|
|
155
|
+
|
|
156
|
+
setSearchQuery('')
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const handleActiveTab = (val) => {
|
|
160
|
+
setActiveTab(val);
|
|
161
|
+
|
|
162
|
+
setSearchQuery('')
|
|
163
|
+
}
|
|
164
|
+
const handleSearchQuery = (val) => {
|
|
165
|
+
setSearchQuery(val)
|
|
166
|
+
setActive('all')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
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'];
|
|
170
|
+
|
|
171
|
+
let title = "All Sets";
|
|
172
|
+
if (activeTab == "year") {
|
|
173
|
+
title = "By Year";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<Fragment>
|
|
178
|
+
<StoreTitle>{title}</StoreTitle>
|
|
179
|
+
<Breadcrumbs categoryId={categoryId} customPage={shopby == "release_year" ? "By Year" : "By Release/Set"} />
|
|
180
|
+
<ul className={classes.nav}>
|
|
181
|
+
<li className={classes.nav_item}>
|
|
182
|
+
<button
|
|
183
|
+
onClick={() => {
|
|
184
|
+
handleActiveTab('year')
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
{activeTab == 'year' ? <b>By Year</b> : 'By Year'}
|
|
188
|
+
</button>
|
|
189
|
+
</li>
|
|
190
|
+
<li className={classes.nav_item}>
|
|
191
|
+
<button
|
|
192
|
+
onClick={() => {
|
|
193
|
+
handleActiveTab('all')
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
{activeTab == 'all' ? <b>All Sets</b> : 'All Sets'}
|
|
197
|
+
</button>
|
|
198
|
+
</li>
|
|
199
|
+
</ul>
|
|
200
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
201
|
+
{title}
|
|
202
|
+
</h1>
|
|
203
|
+
{activeTab == "year" && <ul className={classes.nav}>
|
|
204
|
+
{availableGroups.map((group, index) => (
|
|
205
|
+
<li key={index} className={classes.nav_item}>
|
|
206
|
+
<button
|
|
207
|
+
onClick={() => {
|
|
208
|
+
handleActive(group)
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
{active == group ? <b>{group}</b> : group}
|
|
212
|
+
</button>
|
|
213
|
+
</li>
|
|
214
|
+
))}
|
|
215
|
+
<li className={classes.nav_item}>
|
|
216
|
+
<button
|
|
217
|
+
onClick={() => {
|
|
218
|
+
handleActive('all')
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
222
|
+
</button>
|
|
223
|
+
</li>
|
|
224
|
+
</ul>}
|
|
225
|
+
<div className='border border-gray-100 px-6'>
|
|
226
|
+
{legoSets ? (
|
|
227
|
+
<div
|
|
228
|
+
className={classes.toolbar}
|
|
229
|
+
>
|
|
230
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
231
|
+
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
232
|
+
</div>
|
|
233
|
+
) : ''}
|
|
234
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
235
|
+
{activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
236
|
+
<li>
|
|
237
|
+
<button
|
|
238
|
+
className={cn(
|
|
239
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
240
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
241
|
+
)}
|
|
242
|
+
onClick={() => {
|
|
243
|
+
handleActive('all')
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
247
|
+
</button>
|
|
248
|
+
</li>
|
|
249
|
+
{alpha.map((letter, index) => (
|
|
250
|
+
<li key={index}>
|
|
251
|
+
<button
|
|
252
|
+
className={cn(
|
|
253
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
254
|
+
'leading-4 font-medium text-base ',
|
|
255
|
+
setsLengthArr[letter] > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
256
|
+
)}
|
|
257
|
+
onClick={() => {
|
|
258
|
+
handleActive(letter)
|
|
259
|
+
}}
|
|
260
|
+
disabled={setsLengthArr[letter] > 0 ? false : true}
|
|
261
|
+
>
|
|
262
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
263
|
+
</button>
|
|
264
|
+
</li>
|
|
265
|
+
))}
|
|
266
|
+
</ul>}
|
|
267
|
+
</section>
|
|
268
|
+
<Divider className="mb-5 px-4 mt-5" />
|
|
269
|
+
<section className='singles-container'>
|
|
270
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
271
|
+
{newLegoSets && newLegoSets.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>)}
|
|
272
|
+
</div>
|
|
273
|
+
</section>
|
|
274
|
+
</div>
|
|
275
|
+
</Fragment>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export default LegoSets;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.nav {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
margin: 50px 0 30px 0;
|
|
5
|
+
composes: gap-[10px] from global;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.nav_item {
|
|
9
|
+
composes: px-4 from global;
|
|
10
|
+
composes: py-2 from global;
|
|
11
|
+
composes: transition-colors from global;
|
|
12
|
+
composes: duration-150 from global;
|
|
13
|
+
composes: border from global;
|
|
14
|
+
composes: border-solid from global;
|
|
15
|
+
composes: leading-normal from global;
|
|
16
|
+
composes: text-base from global;
|
|
17
|
+
composes: text-colorDefault from global;
|
|
18
|
+
composes: bg-white from global;
|
|
19
|
+
composes: border-gray-100 from global;
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.toolbar {
|
|
24
|
+
composes: relative from global;
|
|
25
|
+
composes: ml-2xs from global;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
margin-top: 20px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tabs {
|
|
32
|
+
composes: flex from global;
|
|
33
|
+
composes: flex-wrap from global;
|
|
34
|
+
composes: mt-3 from global;
|
|
35
|
+
composes: gap-[15px] from global;
|
|
36
|
+
margin-bottom: 30px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tabs_item {
|
|
40
|
+
composes: px-4 from global;
|
|
41
|
+
composes: py-2 from global;
|
|
42
|
+
composes: transition-colors from global;
|
|
43
|
+
composes: duration-150 from global;
|
|
44
|
+
composes: border from global;
|
|
45
|
+
composes: border-solid from global;
|
|
46
|
+
composes: leading-normal from global;
|
|
47
|
+
composes: text-base from global;
|
|
48
|
+
composes: text-colorDefault from global;
|
|
49
|
+
composes: bg-white from global;
|
|
50
|
+
composes: border-gray-100 from global;
|
|
51
|
+
border-radius: 5px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.singlesWrapper {
|
|
55
|
+
column-count: 1;
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 100%;
|
|
58
|
+
flex-wrap: wrap;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.singlesGroupWrapper {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media screen and (min-width: 768px) {
|
|
67
|
+
.singlesGroupWrapper {
|
|
68
|
+
width: 50%;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media screen and (min-width: 1023px) {
|
|
73
|
+
.singlesGroupWrapper {
|
|
74
|
+
width: 33.33%;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -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 './legoSets.module.css';
|
|
7
|
+
import cn from 'classnames';
|
|
8
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
9
|
+
|
|
10
|
+
const LegoSets = 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 LegoSets;
|
|
@@ -106,7 +106,7 @@ const ShopBy = props => {
|
|
|
106
106
|
|
|
107
107
|
const classes = useStyle(defaultClasses);
|
|
108
108
|
|
|
109
|
-
const talonProps = useShopBy({ searchQuery, setActive, currentSort, categoryId, shopby });
|
|
109
|
+
const talonProps = useShopBy({ searchQuery, active, setActive, currentSort, categoryId, shopby });
|
|
110
110
|
|
|
111
111
|
const { error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category, activeFilters } = talonProps;
|
|
112
112
|
|
|
@@ -128,19 +128,30 @@ const ShopBy = props => {
|
|
|
128
128
|
return result;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
filterSearchArr.
|
|
133
|
-
|
|
131
|
+
let filterSearchArr = search ? search.split('&') : [];
|
|
132
|
+
filterSearchArr = filterSearchArr.filter(function(data) {
|
|
133
|
+
return !data.includes('shopby');
|
|
134
|
+
})
|
|
135
|
+
let filterSearch = filterSearchArr.join('&')
|
|
134
136
|
|
|
135
|
-
|
|
137
|
+
if (!filterSearch.includes('?')) {
|
|
138
|
+
filterSearch = '?'+filterSearch;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let additionalFilter = '';
|
|
142
|
+
if (shopby == 'sc_brands') {
|
|
143
|
+
additionalFilter = '&shopby=release&active_tab=brand';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const setRelases = newAvailableGroups && newAvailableGroups.length && newAvailableGroups.map((group, index) => {
|
|
136
147
|
const optionsResult = [];
|
|
137
148
|
|
|
138
149
|
if (active === 'all' || active === group) {
|
|
139
|
-
dataResult[group].map((option, index) => {
|
|
150
|
+
dataResult[group] && dataResult[group].length && dataResult[group].map((option, index) => {
|
|
140
151
|
const { label, value } = option;
|
|
141
152
|
|
|
142
153
|
const filter = attributeData.attribute_code + '[filter]=' + label + ',' + value;
|
|
143
|
-
const params = filterSearch ? filterSearch + '&' + filter : '?' + filter;
|
|
154
|
+
const params = filterSearch ? filterSearch + '&' + filter + additionalFilter : '?' + filter + additionalFilter;
|
|
144
155
|
|
|
145
156
|
const categoryUrl = resourceUrl(
|
|
146
157
|
`/${category.url_path}${categoryUrlSuffix || ''}${params}`
|
|
@@ -154,19 +165,35 @@ const ShopBy = props => {
|
|
|
154
165
|
});
|
|
155
166
|
|
|
156
167
|
let optionsResultSplitted = [];
|
|
157
|
-
if (active == group) {
|
|
168
|
+
if (newAvailableGroups.length == 1 || active == group) {
|
|
158
169
|
optionsResultSplitted = splitToNChunks(optionsResult, 3);
|
|
159
170
|
}
|
|
160
171
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
// console.log(dataResult)
|
|
173
|
+
|
|
174
|
+
const all = active == "all" ? (
|
|
175
|
+
newAvailableGroups.length == 1 ? (
|
|
176
|
+
optionsResultSplitted && optionsResultSplitted.length && optionsResultSplitted.map((data, index) => (
|
|
177
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
178
|
+
{searchQuery && availableGroups.length > 1 && (index == 0 ? <div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
179
|
+
<div className='singles_item_group_letter text-xl font-semibold pb-1 mb-2' style={{"marginTop":"35px"}}></div>)}
|
|
180
|
+
<div className={cn('singles_item-list flex flex-col')}>{data}</div>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
) : (
|
|
164
185
|
<div className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
165
186
|
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' >
|
|
166
187
|
{group}
|
|
167
188
|
</div>
|
|
168
189
|
<div className={cn('singles_item-list flex flex-col')}>{optionsResult}</div>
|
|
169
|
-
</div>
|
|
190
|
+
</div>
|
|
191
|
+
)
|
|
192
|
+
) : '';
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
{all}
|
|
170
197
|
{active == group ? optionsResultSplitted && optionsResultSplitted.length && optionsResultSplitted.map((optionsResult, index) =>
|
|
171
198
|
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
172
199
|
{index == 0 ? <div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
@@ -212,7 +239,7 @@ const ShopBy = props => {
|
|
|
212
239
|
<CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} />
|
|
213
240
|
</div>
|
|
214
241
|
) : ''}
|
|
215
|
-
{productType != "expansion-sets" ? (
|
|
242
|
+
{shopby != "lego_theme" && shopby != "lego_age_level" && productType != "expansion-sets" ? (
|
|
216
243
|
<>
|
|
217
244
|
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
218
245
|
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
@@ -229,7 +256,7 @@ const ShopBy = props => {
|
|
|
229
256
|
{active == 'all' ? <b>All</b> : 'All'}
|
|
230
257
|
</button>
|
|
231
258
|
</li>
|
|
232
|
-
{alpha.map((letter, index) => (
|
|
259
|
+
{alpha && alpha.length && alpha.map((letter, index) => (
|
|
233
260
|
<li key={index}>
|
|
234
261
|
<button
|
|
235
262
|
className={cn(
|