@riosst100/pwa-marketplace 1.8.4 → 1.8.6
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 +24 -6
- package/src/components/MiniatureGameSets/index.js +2 -0
- package/src/components/MiniatureGameSets/miniatureGameSets.js +297 -0
- package/src/components/MiniatureGameSets/miniatureGameSets.module.css +76 -0
- package/src/components/MiniatureGameSets/miniatureGameSets.shimmer.js +50 -0
- package/src/components/ProductLabel/index.js +1 -1
- package/src/components/ShopBy/shopBy.js +1 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +1 -1
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +2 -2
- package/src/talons/LegoSets/legoSets.gql.js +2 -2
- package/src/talons/LegoSets/useLegoSets.js +2 -1
- package/src/talons/MiniatureGameSets/miniatureGameSets.gql.js +59 -0
- package/src/talons/MiniatureGameSets/useMiniatureGameSets.js +220 -0
package/package.json
CHANGED
|
@@ -103,6 +103,15 @@ const LegoSets = props => {
|
|
|
103
103
|
return result;
|
|
104
104
|
}
|
|
105
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
|
+
|
|
106
115
|
const setRelases = newLegoSets && newLegoSets.length && newLegoSets.map((setRelease, index) => {
|
|
107
116
|
const { group, sets } = setRelease;
|
|
108
117
|
|
|
@@ -113,7 +122,7 @@ const LegoSets = props => {
|
|
|
113
122
|
const { set_name, option_id, release_year } = set;
|
|
114
123
|
|
|
115
124
|
const categoryUrl = resourceUrl(
|
|
116
|
-
`/${category?.url_path}${categoryUrlSuffix || ''}
|
|
125
|
+
`/${category?.url_path}${categoryUrlSuffix || ''}?${attributeCode}[filter]=${set_name},${option_id}`
|
|
117
126
|
);
|
|
118
127
|
|
|
119
128
|
setsResult.push(<li className='list-none'>
|
|
@@ -158,6 +167,7 @@ const LegoSets = props => {
|
|
|
158
167
|
|
|
159
168
|
const handleActiveTab = (val) => {
|
|
160
169
|
setActiveTab(val);
|
|
170
|
+
setActive('all')
|
|
161
171
|
|
|
162
172
|
setSearchQuery('')
|
|
163
173
|
}
|
|
@@ -168,15 +178,23 @@ const LegoSets = props => {
|
|
|
168
178
|
|
|
169
179
|
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
180
|
|
|
171
|
-
let title = "
|
|
181
|
+
let title = "Sets";
|
|
172
182
|
if (activeTab == "year") {
|
|
173
|
-
title = "By Year";
|
|
183
|
+
title = "Sets | By Year";
|
|
174
184
|
}
|
|
175
185
|
|
|
186
|
+
if (shopby == "singles") {
|
|
187
|
+
title = "Singles";
|
|
188
|
+
if (activeTab == "year") {
|
|
189
|
+
title = "Singles | By Year";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
176
194
|
return (
|
|
177
195
|
<Fragment>
|
|
178
196
|
<StoreTitle>{title}</StoreTitle>
|
|
179
|
-
<Breadcrumbs categoryId={categoryId} customPage={
|
|
197
|
+
<Breadcrumbs categoryId={categoryId} customPage={title} />
|
|
180
198
|
<ul className={classes.nav}>
|
|
181
199
|
<li className={classes.nav_item}>
|
|
182
200
|
<button
|
|
@@ -184,7 +202,7 @@ const LegoSets = props => {
|
|
|
184
202
|
handleActiveTab('year')
|
|
185
203
|
}}
|
|
186
204
|
>
|
|
187
|
-
{activeTab == 'year' ? <b>
|
|
205
|
+
{activeTab == 'year' ? <b>{byYearTitle}</b> : byYearTitle}
|
|
188
206
|
</button>
|
|
189
207
|
</li>
|
|
190
208
|
<li className={classes.nav_item}>
|
|
@@ -193,7 +211,7 @@ const LegoSets = props => {
|
|
|
193
211
|
handleActiveTab('all')
|
|
194
212
|
}}
|
|
195
213
|
>
|
|
196
|
-
{activeTab == 'all' ? <b>
|
|
214
|
+
{activeTab == 'all' ? <b>{allSetsTitle}</b> : allSetsTitle}
|
|
197
215
|
</button>
|
|
198
216
|
</li>
|
|
199
217
|
</ul>
|
|
@@ -0,0 +1,297 @@
|
|
|
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 { useMiniatureGameSets } from '@riosst100/pwa-marketplace/src/talons/MiniatureGameSets/useMiniatureGameSets';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import defaultClasses from './miniatureGameSets.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 { MiniatureGameSetsShimmer } from '@riosst100/pwa-marketplace/src/components/MiniatureGameSets';
|
|
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 MiniatureGameSets = 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 = useMiniatureGameSets({ searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
73
|
+
|
|
74
|
+
const { error, loading, miniatureGameSets, categoryUrlSuffix, categoryUrlKey, productType, filteredMiniatureGameSets, availableGroups, category } = talonProps;
|
|
75
|
+
|
|
76
|
+
if (loading && !miniatureGameSets)
|
|
77
|
+
return <MiniatureGameSetsShimmer />;
|
|
78
|
+
if (error && !miniatureGameSets) return <ErrorView />;
|
|
79
|
+
|
|
80
|
+
if (!miniatureGameSets && !loading && !error) {
|
|
81
|
+
return <MiniatureGameSetsShimmer />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const setsLengthArr = [];
|
|
85
|
+
|
|
86
|
+
const newMiniatureGameSets = searchQuery ? filteredMiniatureGameSets : miniatureGameSets;
|
|
87
|
+
|
|
88
|
+
// useEffect(() => {
|
|
89
|
+
if (miniatureGameSets && miniatureGameSets.length) {
|
|
90
|
+
miniatureGameSets.map((setRelease, index) => {
|
|
91
|
+
const { group, sets } = setRelease;
|
|
92
|
+
|
|
93
|
+
setsLengthArr[group] = sets.length
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
// }, [miniatureGameSets])
|
|
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 = newMiniatureGameSets && newMiniatureGameSets.length && newMiniatureGameSets.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
|
+
{set_name}
|
|
131
|
+
</Link>
|
|
132
|
+
</li>)
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let setsResultSplitted = [];
|
|
137
|
+
if (active == group || newMiniatureGameSets.length == 1) {
|
|
138
|
+
setsResultSplitted = splitToNChunks(setsResult, 3);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
{active == "all" && newMiniatureGameSets.length > 1 ?
|
|
144
|
+
<div className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
145
|
+
<div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2' >
|
|
146
|
+
{group}
|
|
147
|
+
</div>
|
|
148
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
149
|
+
</div> : ''}
|
|
150
|
+
{active == group || newMiniatureGameSets.length == 1 ? setsResultSplitted && setsResultSplitted.length && setsResultSplitted.map((setsResult, index) =>
|
|
151
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
152
|
+
{index == 0 ? <div className='singles_item_group_letter text-xl font-semibold border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
153
|
+
<div className='singles_item_group_letter text-xl font-semibold pb-1 mb-2' style={{"marginTop":"35px"}}></div>}
|
|
154
|
+
<div className={cn('singles_item-list flex flex-col')}>{setsResult}</div>
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
: ''}
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const handleActive = (val) => {
|
|
163
|
+
setActive(val);
|
|
164
|
+
|
|
165
|
+
setSearchQuery('')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const handleActiveTab = (val) => {
|
|
169
|
+
setActiveTab(val);
|
|
170
|
+
setActive('all')
|
|
171
|
+
|
|
172
|
+
setSearchQuery('')
|
|
173
|
+
}
|
|
174
|
+
const handleSearchQuery = (val) => {
|
|
175
|
+
setSearchQuery(val)
|
|
176
|
+
setActive('all')
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
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'];
|
|
180
|
+
|
|
181
|
+
let title = "Sets";
|
|
182
|
+
if (activeTab == "year") {
|
|
183
|
+
title = "Sets | By Year";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (shopby == "singles") {
|
|
187
|
+
title = "Singles";
|
|
188
|
+
if (activeTab == "year") {
|
|
189
|
+
title = "Singles | By Year";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<Fragment>
|
|
196
|
+
<StoreTitle>{title}</StoreTitle>
|
|
197
|
+
<Breadcrumbs categoryId={categoryId} customPage={title} />
|
|
198
|
+
<ul className={classes.nav}>
|
|
199
|
+
<li className={classes.nav_item}>
|
|
200
|
+
<button
|
|
201
|
+
onClick={() => {
|
|
202
|
+
handleActiveTab('year')
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
{activeTab == 'year' ? <b>{byYearTitle}</b> : byYearTitle}
|
|
206
|
+
</button>
|
|
207
|
+
</li>
|
|
208
|
+
<li className={classes.nav_item}>
|
|
209
|
+
<button
|
|
210
|
+
onClick={() => {
|
|
211
|
+
handleActiveTab('all')
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
{activeTab == 'all' ? <b>{allSetsTitle}</b> : allSetsTitle}
|
|
215
|
+
</button>
|
|
216
|
+
</li>
|
|
217
|
+
</ul>
|
|
218
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
219
|
+
{title}
|
|
220
|
+
</h1>
|
|
221
|
+
{activeTab == "year" && <ul className={classes.nav}>
|
|
222
|
+
{availableGroups.map((group, index) => (
|
|
223
|
+
<li key={index} className={classes.nav_item}>
|
|
224
|
+
<button
|
|
225
|
+
onClick={() => {
|
|
226
|
+
handleActive(group)
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
{active == group ? <b>{group}</b> : group}
|
|
230
|
+
</button>
|
|
231
|
+
</li>
|
|
232
|
+
))}
|
|
233
|
+
<li className={classes.nav_item}>
|
|
234
|
+
<button
|
|
235
|
+
onClick={() => {
|
|
236
|
+
handleActive('all')
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
240
|
+
</button>
|
|
241
|
+
</li>
|
|
242
|
+
</ul>}
|
|
243
|
+
<div className='border border-gray-100 px-6'>
|
|
244
|
+
{miniatureGameSets ? (
|
|
245
|
+
<div
|
|
246
|
+
className={classes.toolbar}
|
|
247
|
+
>
|
|
248
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
249
|
+
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
250
|
+
</div>
|
|
251
|
+
) : ''}
|
|
252
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
253
|
+
{activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
254
|
+
<li>
|
|
255
|
+
<button
|
|
256
|
+
className={cn(
|
|
257
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
258
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
259
|
+
)}
|
|
260
|
+
onClick={() => {
|
|
261
|
+
handleActive('all')
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
265
|
+
</button>
|
|
266
|
+
</li>
|
|
267
|
+
{alpha.map((letter, index) => (
|
|
268
|
+
<li key={index}>
|
|
269
|
+
<button
|
|
270
|
+
className={cn(
|
|
271
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
272
|
+
'leading-4 font-medium text-base ',
|
|
273
|
+
setsLengthArr[letter] > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
274
|
+
)}
|
|
275
|
+
onClick={() => {
|
|
276
|
+
handleActive(letter)
|
|
277
|
+
}}
|
|
278
|
+
disabled={setsLengthArr[letter] > 0 ? false : true}
|
|
279
|
+
>
|
|
280
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
281
|
+
</button>
|
|
282
|
+
</li>
|
|
283
|
+
))}
|
|
284
|
+
</ul>}
|
|
285
|
+
</section>
|
|
286
|
+
<Divider className="mb-5 px-4 mt-5" />
|
|
287
|
+
<section className='singles-container'>
|
|
288
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
289
|
+
{newMiniatureGameSets && newMiniatureGameSets.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>)}
|
|
290
|
+
</div>
|
|
291
|
+
</section>
|
|
292
|
+
</div>
|
|
293
|
+
</Fragment>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export default MiniatureGameSets;
|
|
@@ -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 './miniatureGameSets.module.css';
|
|
7
|
+
import cn from 'classnames';
|
|
8
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
9
|
+
|
|
10
|
+
const MiniatureGameSets = 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 MiniatureGameSets;
|
|
@@ -27,7 +27,7 @@ const ProductLabel = (props) => {
|
|
|
27
27
|
>
|
|
28
28
|
{salePrice > 0 && <div className='bg-yellow-400 rounded px-2.5 py-[6px] w-fit top-0 left-0'>
|
|
29
29
|
<span className='text-white text-xs font-medium'>
|
|
30
|
-
{salePrice/regularPrice*100}% off
|
|
30
|
+
{Math.round(salePrice/regularPrice*100)}% off
|
|
31
31
|
</span>
|
|
32
32
|
</div>}
|
|
33
33
|
{isPreOrder && <div className='bg-darkblue-900 rounded px-2.5 py-[6px] w-fit top-0 left-0'>
|
|
@@ -239,7 +239,7 @@ const ShopBy = props => {
|
|
|
239
239
|
<CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} />
|
|
240
240
|
</div>
|
|
241
241
|
) : ''}
|
|
242
|
-
{shopby != "
|
|
242
|
+
{shopby != "lego_age_level" && productType != "expansion-sets" ? (
|
|
243
243
|
<>
|
|
244
244
|
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
245
245
|
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
@@ -85,7 +85,7 @@ const Category = props => {
|
|
|
85
85
|
categoryId={uid}
|
|
86
86
|
isLoading={loading} />
|
|
87
87
|
) : (
|
|
88
|
-
shopby == "lego_set_name" && parentCategoryUrlKey == "lego" ? <LegoSets
|
|
88
|
+
shopby == "singles" || shopby == "lego_set_name" && parentCategoryUrlKey == "lego" ? <LegoSets
|
|
89
89
|
categoryId={uid}
|
|
90
90
|
shopby={shopby}
|
|
91
91
|
isLoading={loading} /> : shopby == "release" && parentCategoryUrlKey == "sport-cards" ? <SportCardsSets
|
|
@@ -92,7 +92,7 @@ const FilterSidebar = props => {
|
|
|
92
92
|
const frontendInput = filterFrontendInput.get(group);
|
|
93
93
|
|
|
94
94
|
const hideFilters = ['trains','trains_locomotives','trains_supplies_type','lof_preorder','auction','special_price','sc_baseball_inserts','sc_baseball_parallel','sale','sc_set_type','sc_brands'];
|
|
95
|
-
if (!hideFilters.includes(group)) {
|
|
95
|
+
if (!hideFilters.includes(group) && groupName) {
|
|
96
96
|
// if (!allowedFilters && !allowedFiltersArr.length && group != "category_uid" || allowedFilters && allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
|
|
97
97
|
|
|
98
98
|
|
|
@@ -106,7 +106,7 @@ const FilterSidebar = props => {
|
|
|
106
106
|
items={items}
|
|
107
107
|
name={groupName}
|
|
108
108
|
onApply={group == "category_uid" ? handleCategoryApplyFilter : handleApplyFilter}
|
|
109
|
-
initialOpen={
|
|
109
|
+
initialOpen={true}
|
|
110
110
|
/>
|
|
111
111
|
);
|
|
112
112
|
}
|
|
@@ -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
|
|
16
|
-
legoSets(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters) {
|
|
15
|
+
query getLegoSets($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String) {
|
|
16
|
+
legoSets(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby) {
|
|
17
17
|
group
|
|
18
18
|
sets {
|
|
19
19
|
set_name
|
|
@@ -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_SETS_QUERY = gql`
|
|
15
|
+
query getMiniatureGameSets($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String) {
|
|
16
|
+
miniatureGameSets(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby) {
|
|
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
|
+
getMiniatureGameSetsQuery: GET_SETS_QUERY,
|
|
57
|
+
getCategoryContentQuery: GET_CATEGORY_CONTENT,
|
|
58
|
+
getFilterInputsQuery: GET_FILTER_INPUTS,
|
|
59
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
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 './miniatureGameSets.gql';
|
|
8
|
+
import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
9
|
+
|
|
10
|
+
export const useMiniatureGameSets = 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, getMiniatureGameSetsQuery, getCategoryContentQuery, getFilterInputsQuery } = operations;
|
|
18
|
+
const { pathname, search } = useLocation();
|
|
19
|
+
const [runQuery, queryResponse] = useLazyQuery(getMiniatureGameSetsQuery, {
|
|
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(getMiniatureGameSetsQuery, {
|
|
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
|
+
}
|
|
98
|
+
});
|
|
99
|
+
// }
|
|
100
|
+
}, [
|
|
101
|
+
runQuery,
|
|
102
|
+
activeTab
|
|
103
|
+
// queryResponse
|
|
104
|
+
// filterTypeMap,
|
|
105
|
+
// search,
|
|
106
|
+
// newFilters,
|
|
107
|
+
// shopby,
|
|
108
|
+
// categoryUrlKey
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
const { data: storeConfigData } = useQuery(getStoreConfigData, {
|
|
112
|
+
fetchPolicy: 'cache-and-network',
|
|
113
|
+
nextFetchPolicy: 'cache-first'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
|
|
117
|
+
|
|
118
|
+
// { data: queryResponse, error, loading }
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// console.log(data)
|
|
123
|
+
|
|
124
|
+
// const isBackgroundLoading = !!data && loading;
|
|
125
|
+
|
|
126
|
+
const availableLeagues = [];
|
|
127
|
+
|
|
128
|
+
// console.log(queryResponse.data)
|
|
129
|
+
|
|
130
|
+
const miniatureGameSets = useMemo(() => {
|
|
131
|
+
if (!queryResponse) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// console.log(data)
|
|
136
|
+
|
|
137
|
+
const miniatureGameSets = queryResponse?.data?.miniatureGameSets;
|
|
138
|
+
if (!miniatureGameSets) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return miniatureGameSets.slice().sort((a, b) =>a.group.toLowerCase().localeCompare(b.group.toLowerCase()));
|
|
143
|
+
}, [queryResponse]);
|
|
144
|
+
|
|
145
|
+
const availableGroups = miniatureGameSets && miniatureGameSets.length ? miniatureGameSets.map(({ group }) => group) : [];
|
|
146
|
+
|
|
147
|
+
// const availableLeagues = miniatureGameSets && miniatureGameSets.length ? miniatureGameSets.map(({ sets }) => miniatureGameSets.map(({ sc_league }) => sc_league)) : [];
|
|
148
|
+
// console.log(availableLeagues)
|
|
149
|
+
// sc_league
|
|
150
|
+
|
|
151
|
+
const filteredMiniatureGameSets = useMemo(() => {
|
|
152
|
+
if (!miniatureGameSets) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const filteredSets = [];
|
|
157
|
+
|
|
158
|
+
if (searchQuery) {
|
|
159
|
+
|
|
160
|
+
// useEffect(() => {
|
|
161
|
+
// setActive('all')
|
|
162
|
+
// }, [active]);
|
|
163
|
+
|
|
164
|
+
miniatureGameSets.map(({ group, sets }, index) => {
|
|
165
|
+
const newSets = sets.filter(function(set) {
|
|
166
|
+
return set.set_name.search(new RegExp(searchQuery, "i")) != -1 || group.search(new RegExp(searchQuery, "i")) != -1;
|
|
167
|
+
// return set.set_name.includes(searchQuery);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (newSets && newSets.length) {
|
|
171
|
+
filteredSets.push({
|
|
172
|
+
'group': group,
|
|
173
|
+
'sets': newSets
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return searchQuery ? filteredSets : miniatureGameSets;
|
|
180
|
+
}, [miniatureGameSets, searchQuery]);
|
|
181
|
+
|
|
182
|
+
// useEffect(() => {
|
|
183
|
+
// setPageLoading(isBackgroundLoading);
|
|
184
|
+
// }, [isBackgroundLoading, setPageLoading]);
|
|
185
|
+
|
|
186
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
187
|
+
getCategoryContentQuery,
|
|
188
|
+
{
|
|
189
|
+
fetchPolicy: 'cache-and-network',
|
|
190
|
+
nextFetchPolicy: 'cache-first',
|
|
191
|
+
skip: !categoryId,
|
|
192
|
+
variables: {
|
|
193
|
+
id: categoryId
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const category =
|
|
199
|
+
categoryData && categoryData.categories.items.length
|
|
200
|
+
? categoryData.categories.items[0]
|
|
201
|
+
: null;
|
|
202
|
+
|
|
203
|
+
const error = queryResponse?.error;
|
|
204
|
+
const loading = queryResponse?.loading;
|
|
205
|
+
|
|
206
|
+
// console.log(miniatureGameSets)
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
error,
|
|
210
|
+
loading,
|
|
211
|
+
miniatureGameSets,
|
|
212
|
+
filteredMiniatureGameSets,
|
|
213
|
+
categoryUrlSuffix,
|
|
214
|
+
categoryUrlKey,
|
|
215
|
+
productType,
|
|
216
|
+
availableGroups,
|
|
217
|
+
category,
|
|
218
|
+
// availableLeagues
|
|
219
|
+
};
|
|
220
|
+
};
|