@riosst100/pwa-marketplace 1.8.7 → 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/CustomSubCategoryPage/subCategoryPage.js +5 -3
- package/src/components/FilterTopBackup/CustomFilters/customFilters.js +2 -0
- package/src/components/LegoSets/legoSets.js +50 -19
- package/src/components/NonSportCardsSets/index.js +2 -0
- package/src/components/NonSportCardsSets/nonSportCardsSets.js +270 -0
- package/src/components/NonSportCardsSets/nonSportCardsSets.module.css +76 -0
- package/src/components/NonSportCardsSets/nonSportCardsSets.shimmer.js +50 -0
- 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 +71 -154
- package/src/components/SubCategory/customSubCategory.js +19 -9
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +5 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +31 -5
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +12 -3
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +2 -2
- 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/nonSportCardsSets.gql.js +59 -0
- package/src/talons/NonSportCardsSets/useNonSportCardsSets.js +238 -0
- 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/sportCardsSets.gql.js +2 -2
- package/src/talons/SportCardsSets/useSportCardsSets.js +10 -10
|
@@ -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;
|