@riosst100/pwa-marketplace 1.7.2 → 1.7.3
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
CHANGED
|
@@ -19,7 +19,7 @@ const SportCardsSets = props => {
|
|
|
19
19
|
|
|
20
20
|
const [active, setActive] = useState('all');
|
|
21
21
|
const [activeTab, setActiveTab] = useState('leagues');
|
|
22
|
-
const [activeFilter, setActiveFilter] = useState('
|
|
22
|
+
const [activeFilter, setActiveFilter] = useState('Major Baseball League');
|
|
23
23
|
|
|
24
24
|
const [searchQuery, setSearchQuery] = useState('');
|
|
25
25
|
|
|
@@ -62,7 +62,7 @@ const SportCardsSets = props => {
|
|
|
62
62
|
|
|
63
63
|
const classes = useStyle(defaultClasses);
|
|
64
64
|
|
|
65
|
-
const talonProps = useSportCardsSets({ searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
65
|
+
const talonProps = useSportCardsSets({ searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter });
|
|
66
66
|
|
|
67
67
|
const { error, loading, sportCardsSets, categoryUrlSuffix, categoryUrlKey, productType, filteredSportCardsSets, availableGroups, category } = talonProps;
|
|
68
68
|
|
|
@@ -76,13 +76,33 @@ const SportCardsSets = props => {
|
|
|
76
76
|
|
|
77
77
|
const setsLengthArr = [];
|
|
78
78
|
|
|
79
|
-
const newSportCardsSets = searchQuery ? filteredSportCardsSets : sportCardsSets;
|
|
79
|
+
const newSportCardsSets = searchQuery || activeFilter != "all" ? filteredSportCardsSets : sportCardsSets;
|
|
80
80
|
|
|
81
81
|
// useEffect(() => {
|
|
82
82
|
if (sportCardsSets && sportCardsSets.length) {
|
|
83
83
|
sportCardsSets.map((setRelease, index) => {
|
|
84
84
|
const { group, sets } = setRelease;
|
|
85
85
|
|
|
86
|
+
// if (sets.length) {
|
|
87
|
+
// sets.map((set, index) => {
|
|
88
|
+
// // console.log(set)
|
|
89
|
+
// if (set.sc_league) {
|
|
90
|
+
// if (!availableLeagues.includes(set.sc_league)) {
|
|
91
|
+
// availableLeagues.push(set.sc_league)
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// })
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
setsLengthArr[group] = sets.length
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
// }, [sportCardsSets])
|
|
101
|
+
|
|
102
|
+
if (sportCardsSets && sportCardsSets.length) {
|
|
103
|
+
sportCardsSets.map((setRelease, index) => {
|
|
104
|
+
const { group, sets } = setRelease;
|
|
105
|
+
if (active == 'all' || active != "all" && active == group) {
|
|
86
106
|
if (sets.length) {
|
|
87
107
|
sets.map((set, index) => {
|
|
88
108
|
// console.log(set)
|
|
@@ -93,11 +113,9 @@ const SportCardsSets = props => {
|
|
|
93
113
|
}
|
|
94
114
|
})
|
|
95
115
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
// }, [sportCardsSets])
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
}
|
|
101
119
|
|
|
102
120
|
const splitToNChunks = (array, n) => {
|
|
103
121
|
let result = [];
|
|
@@ -109,7 +127,7 @@ const SportCardsSets = props => {
|
|
|
109
127
|
|
|
110
128
|
// console.log(category)
|
|
111
129
|
|
|
112
|
-
const setRelases = newSportCardsSets.length && newSportCardsSets.map((setRelease, index) => {
|
|
130
|
+
const setRelases = newSportCardsSets && newSportCardsSets.length && newSportCardsSets.map((setRelease, index) => {
|
|
113
131
|
const { group, sets } = setRelease;
|
|
114
132
|
|
|
115
133
|
const setsResult = [];
|
|
@@ -160,7 +178,8 @@ const SportCardsSets = props => {
|
|
|
160
178
|
setActive(val);
|
|
161
179
|
|
|
162
180
|
availableLeagues = [];
|
|
163
|
-
|
|
181
|
+
|
|
182
|
+
setActiveFilter('Major Baseball League')
|
|
164
183
|
|
|
165
184
|
|
|
166
185
|
setSearchQuery('')
|
|
@@ -232,6 +251,8 @@ const SportCardsSets = props => {
|
|
|
232
251
|
|
|
233
252
|
// console.log(availableLeagues)
|
|
234
253
|
|
|
254
|
+
availableLeagues.sort();
|
|
255
|
+
|
|
235
256
|
|
|
236
257
|
return (
|
|
237
258
|
<Fragment>
|
|
@@ -291,7 +312,7 @@ const SportCardsSets = props => {
|
|
|
291
312
|
</button>
|
|
292
313
|
</li>
|
|
293
314
|
</ul> : ''}
|
|
294
|
-
{availableLeagues ? <ul className={classes.nav}>
|
|
315
|
+
{activeTab == "leagues" && availableLeagues ? <ul className={classes.nav}>
|
|
295
316
|
{availableLeagues.map((group, index) => (
|
|
296
317
|
<li key={index} className={classes.nav_item}>
|
|
297
318
|
<button
|
|
@@ -303,15 +324,6 @@ const SportCardsSets = props => {
|
|
|
303
324
|
</button>
|
|
304
325
|
</li>
|
|
305
326
|
))}
|
|
306
|
-
<li className={classes.nav_item}>
|
|
307
|
-
<button
|
|
308
|
-
onClick={() => {
|
|
309
|
-
handleActiveFilter('all')
|
|
310
|
-
}}
|
|
311
|
-
>
|
|
312
|
-
{activeFilter == 'all' ? <b>All</b> : 'All'}
|
|
313
|
-
</button>
|
|
314
|
-
</li>
|
|
315
327
|
</ul> : ''}
|
|
316
328
|
<div className='border border-gray-100 px-6'>
|
|
317
329
|
{sportCardsSets ? (
|
|
@@ -8,7 +8,7 @@ import DEFAULT_OPERATIONS from './sportCardsSets.gql';
|
|
|
8
8
|
|
|
9
9
|
export const useSportCardsSets = props => {
|
|
10
10
|
|
|
11
|
-
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab } = props
|
|
11
|
+
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter } = props
|
|
12
12
|
|
|
13
13
|
const { value: sortby } = currentSort
|
|
14
14
|
|
|
@@ -77,7 +77,7 @@ export const useSportCardsSets = props => {
|
|
|
77
77
|
}
|
|
78
78
|
// if (release_year) {
|
|
79
79
|
// // groupingSetsByYear.splice(release_year, 0, set);
|
|
80
|
-
|
|
80
|
+
// const result = sortbyData.find(item => item.group === release_year);
|
|
81
81
|
|
|
82
82
|
// // groupingSetsByYear[release_year] = set;
|
|
83
83
|
// if (result) {
|
|
@@ -96,7 +96,7 @@ export const useSportCardsSets = props => {
|
|
|
96
96
|
})
|
|
97
97
|
// }
|
|
98
98
|
|
|
99
|
-
return
|
|
99
|
+
return sportCardsSets;
|
|
100
100
|
}, [data, activeTab]);
|
|
101
101
|
|
|
102
102
|
const availableGroups = sportCardsSets && sportCardsSets.length ? sportCardsSets.map(({ group }) => group) : [];
|
|
@@ -105,7 +105,7 @@ export const useSportCardsSets = props => {
|
|
|
105
105
|
// console.log(availableLeagues)
|
|
106
106
|
// sc_league
|
|
107
107
|
|
|
108
|
-
const
|
|
108
|
+
const filteredSportCardsSets = useMemo(() => {
|
|
109
109
|
if (!sportCardsSets) {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
@@ -131,8 +131,26 @@ export const useSportCardsSets = props => {
|
|
|
131
131
|
})
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
if (activeFilter && activeFilter != "all") {
|
|
135
|
+
sportCardsSets.map(({ group, sets }, index) => {
|
|
136
|
+
const newSets = sets.filter(function(set) {
|
|
137
|
+
return set.sc_league == activeFilter;
|
|
138
|
+
// return set.set_name.includes(searchQuery);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (newSets && newSets.length) {
|
|
142
|
+
filteredSets.push({
|
|
143
|
+
'group': group,
|
|
144
|
+
'sets': newSets
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
console.log(activeFilter)
|
|
149
|
+
console.log(filteredSets)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return searchQuery || activeFilter ? filteredSets : sportCardsSets;
|
|
153
|
+
}, [sportCardsSets, searchQuery, sortby, activeFilter]);
|
|
136
154
|
|
|
137
155
|
useEffect(() => {
|
|
138
156
|
setPageLoading(isBackgroundLoading);
|
|
@@ -159,7 +177,7 @@ export const useSportCardsSets = props => {
|
|
|
159
177
|
error,
|
|
160
178
|
loading,
|
|
161
179
|
sportCardsSets,
|
|
162
|
-
|
|
180
|
+
filteredSportCardsSets,
|
|
163
181
|
categoryUrlSuffix,
|
|
164
182
|
categoryUrlKey,
|
|
165
183
|
productType,
|