@riosst100/pwa-marketplace 1.9.5 → 1.9.7

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.
Files changed (28) hide show
  1. package/package.json +4 -4
  2. package/src/components/FilterTop/CurrentTopFilters/currentTopFilter.js +1 -1
  3. package/src/components/FilterTop/FilterBlockList/filterTopItem.js +26 -3
  4. package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.js +1 -1
  5. package/src/components/FilterTop/filterTop.js +1 -1
  6. package/src/components/ShopBy/shopBy.js +8 -0
  7. package/src/components/ShopByBrands/index.js +2 -0
  8. package/src/components/ShopByBrands/legoSets.shimmer.js +50 -0
  9. package/src/components/ShopByBrands/shopByBrands.js +327 -0
  10. package/src/components/ShopByBrands/shopByBrands.module.css +76 -0
  11. package/src/components/ShopByBrands/shopByBrands.shimmer.js +50 -0
  12. package/src/components/ShopByFilters/index.js +1 -0
  13. package/src/components/ShopByFilters/shopByFilters.js +74 -0
  14. package/src/components/ShopByFilters/shopByFilters.module.css +21 -0
  15. package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +1 -4
  16. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +1 -1
  17. package/src/overwrites/venia-ui/lib/components/MegaMenu/customSubmenuColumn.js +1 -1
  18. package/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn.js +1 -1
  19. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +2 -2
  20. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +1 -1
  21. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +1 -1
  22. package/src/talons/FilterTop/filterTop.gql.js +2 -2
  23. package/src/talons/FilterTop/useFilterTop.js +2 -1
  24. package/src/talons/ShopBy/shopBy.gql.js +2 -2
  25. package/src/talons/ShopBy/useShopBy.js +3 -2
  26. package/src/talons/ShopByBrands/shopByBrands.gql.js +59 -0
  27. package/src/talons/ShopByBrands/shopByBrands.js +59 -0
  28. package/src/talons/ShopByBrands/useShopByBrands.js +218 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "1.9.5",
4
+ "version": "1.9.7",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -12,10 +12,10 @@
12
12
  "axios": "^1.6.5",
13
13
  "iconsax-react": "^0.0.8",
14
14
  "react-countdown": "^2.3.5",
15
- "react-phone-number-input": "^3.3.9",
16
- "react-slick": "^0.30.2",
17
15
  "react-datepicker": "4.10.0",
18
- "react-dropzone": "^14.2.3"
16
+ "react-dropzone": "^14.2.3",
17
+ "react-phone-number-input": "^3.3.9",
18
+ "react-slick": "^0.30.2"
19
19
  },
20
20
  "license": "MIT",
21
21
  "private": false
@@ -31,7 +31,7 @@ const CurrentTopFilter = props => {
31
31
  }
32
32
  );
33
33
 
34
- return group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "filterby" && group != "trains" && group != "toys_franchise" && group != "toys_brands" && group != "trains_gauge" && group != "category" && group != "shopby" ? (
34
+ return group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "filterby" && group != "trains" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "shopby" ? (
35
35
  <span className={classes.item} data-cy="CurrentTopFilter-root">
36
36
  <Trigger
37
37
  action={handleClick}
@@ -28,6 +28,22 @@ const FilterTopItem = props => {
28
28
  [group, item, onApply, removeGroup, toggleItem]
29
29
  );
30
30
 
31
+ let filterSearchArr = search ? search.split('&') : [];
32
+ let categoryIdFilters = [];
33
+ let shopbyFilters = [];
34
+ if (filterSearchArr) {
35
+ categoryIdFilters = filterSearchArr.filter(function(data) {
36
+ return data && data.includes('cat_id');
37
+ })
38
+ shopbyFilters = filterSearchArr.filter(function(data) {
39
+ return data && data.includes('shopby');
40
+ })
41
+ }
42
+
43
+ // console.log(filterSearchArr)
44
+
45
+ // const catId = null;
46
+
31
47
  const element = group == "filterby" ? (
32
48
  filterBy == value ? (
33
49
  <span className={classes.item}><b>{title}</b></span>
@@ -36,12 +52,19 @@ const FilterTopItem = props => {
36
52
  )
37
53
  ) : group == "category" ? (
38
54
  <Link className={classes.item} to={'/'+value}>{title}</Link>
39
- ) : value == "all_brands" ? (
40
- <Link className={classes.item} to={search ? search + '&shopby=' + 'all_brands' : '?shopby=' + 'all_brands'}>{title}</Link>
55
+ ) : value == "shopby_all" ? (
56
+ <Link className={classes.item} to={search ? search + '&shopby=' + group : '?shopby=' + group}>{title}</Link>
41
57
  ) : group == "shopby" || group == "shopby_with_all" ? (
42
58
  <Link className={classes.item} to={search ? search + '&shopby=' + value : '?shopby=' + value}>{title}</Link>
59
+ ) : group == "cat_id" ? (
60
+ value == "all" && !categoryIdFilters.length || categoryIdFilters.length && categoryIdFilters[0].includes('cat_id='+value) ? (
61
+ <span className={classes.item}><b>{title}</b></span>
62
+ ) : (
63
+ value == "all" ? <Link className={classes.item} to={'#'}>{title}</Link> :
64
+ <Link className={classes.item} to={'?cat_id=' + value + (shopbyFilters.length ? '&' + shopbyFilters[0] : '')}>{title}</Link>
65
+ )
43
66
  ) : (
44
- activeFilters.includes(value) ? (
67
+ activeFilters && activeFilters.includes(value) ? (
45
68
  <span className={classes.item}><b>{title}</b></span>
46
69
  ) : (
47
70
  <span className={classes.item} onClick={() =>handleOnchange(value)}>{title}</span>
@@ -87,7 +87,7 @@ const FilterTopItemGroup = props => {
87
87
  <div className={classes.root}>
88
88
  {radioItems}
89
89
  {filterElements && filterElements.length > 10 ? <span className={classes.item}><b>More Item</b></span> : ''}
90
- {filterElements && filterElements.length ? filterElements : group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "trains" && group != "trains_gauge" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "filterby" && group != "shopby" ? (<span className={classes.item}><b>All</b></span>) : ''}
90
+ {filterElements && filterElements.length ? filterElements : group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "trains" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "filterby" && group != "shopby" && group != "cat_id" ? (<span className={classes.item}><b>All</b></span>) : ''}
91
91
  </div>
92
92
  );
93
93
  };
@@ -114,8 +114,8 @@ const FilterTop = props => {
114
114
  const blockState = filterState.get(group);
115
115
  const groupName = filterNames.get(group);
116
116
  const frontendInput = filterFrontendInput.get(group);
117
+
117
118
  if (customFilters && customFilters.length && customFilters.includes(group)) {
118
-
119
119
  return (
120
120
  <FilterTopBlock
121
121
  key={group}
@@ -31,6 +31,7 @@ import { useLocation } from 'react-router-dom';
31
31
  import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
32
32
  import CustomSubCategory from '@riosst100/pwa-marketplace/src/components/SubCategory/customSubCategory';
33
33
  import AlphaFilter from '@riosst100/pwa-marketplace/src/components/AlphaFilter';
34
+ import ShopByFilters from '@riosst100/pwa-marketplace/src/components/ShopByFilters';
34
35
 
35
36
  import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
36
37
  import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
@@ -133,6 +134,9 @@ const ShopBy = props => {
133
134
  filterSearchArr = filterSearchArr.filter(function(data) {
134
135
  return !data.includes('shopby');
135
136
  })
137
+ filterSearchArr = filterSearchArr.filter(function(data) {
138
+ return !data.includes('trains_roadname_country');
139
+ })
136
140
  let filterSearch = filterSearchArr.join('&')
137
141
 
138
142
  if (!filterSearch.includes('?')) {
@@ -335,10 +339,14 @@ const ShopBy = props => {
335
339
  setSearchQuery('')
336
340
  }
337
341
 
342
+ // console.log(category)
343
+
338
344
  return (
339
345
  <Fragment>
340
346
  <StoreTitle>{title}</StoreTitle>
341
347
  <Breadcrumbs categoryId={categoryId} customPage={title} currentFilter={activeFilters} />
348
+ {category.url_path.includes('model-railway') && <FilterTop shopby={shopby} filters={[]} category={category} children={[]} allowedFilters={category ? category.allowed_filters : []} />}
349
+ {/* <ShopByFilters handleActiveFilter={handleActiveFilter} activeFilter={activeFilter} category={category} /> */}
342
350
  {availableFilterOption.length ?
343
351
  <ul className={classes.nav}>
344
352
  {availableFilterOption.map((filter, index) => (
@@ -0,0 +1,2 @@
1
+ export { default } from './shopByBrands';
2
+ export { default as ShopByBrandsShimmer } from './shopByBrands.shimmer';
@@ -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 ShopByBrands = 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 ShopByBrands;
@@ -0,0 +1,327 @@
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 { useShopByBrands } from '@riosst100/pwa-marketplace/src/talons/ShopByBrands/useShopByBrands';
5
+ import { Link } from 'react-router-dom';
6
+ import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
7
+ import defaultClasses from './shopByBrands.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 { ShopByBrandsShimmer } from '@riosst100/pwa-marketplace/src/components/ShopByBrands';
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 ShopByBrands = 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 = useShopByBrands({ activeFilter, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
73
+
74
+ const { error, loading, shopByBrands, categoryUrlSuffix, categoryUrlKey, productType, filteredShopByBrands, availableGroups, category } = talonProps;
75
+
76
+ if (loading && !shopByBrands)
77
+ return <ShopByBrandsShimmer />;
78
+ if (error && !shopByBrands) return <ErrorView />;
79
+
80
+ if (!shopByBrands && !loading && !error) {
81
+ return <ShopByBrandsShimmer />;
82
+ }
83
+
84
+ const setsLengthArr = [];
85
+
86
+ const newShopByBrands = searchQuery ? filteredShopByBrands : shopByBrands;
87
+
88
+ // useEffect(() => {
89
+ if (shopByBrands && shopByBrands.length) {
90
+ shopByBrands.map((setRelease, index) => {
91
+ const { group, sets } = setRelease;
92
+
93
+ setsLengthArr[group] = sets.length
94
+ })
95
+ }
96
+ // }, [shopByBrands])
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 = newShopByBrands && newShopByBrands.length && newShopByBrands.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 || newShopByBrands.length == 1) {
138
+ setsResultSplitted = splitToNChunks(setsResult, 3);
139
+ }
140
+
141
+ return (
142
+ <>
143
+ {active == "all" && newShopByBrands.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 || newShopByBrands.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
+ setActiveFilter('');
172
+
173
+ setSearchQuery('')
174
+ }
175
+ const handleSearchQuery = (val) => {
176
+ setSearchQuery(val)
177
+ setActive('all')
178
+ }
179
+
180
+ 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'];
181
+
182
+ let title = "Sets";
183
+ if (activeTab == "year") {
184
+ title = "Sets | By Year";
185
+ }
186
+
187
+ const availableFilters = [
188
+ 'Theme',
189
+ 'Sub-Theme',
190
+ 'Interest',
191
+ 'Age Level'
192
+ ];
193
+
194
+ const handleActiveFilter = (val) => {
195
+ setActiveFilter(val);
196
+
197
+ setActive('all');
198
+
199
+ setSearchQuery('')
200
+ }
201
+
202
+ return (
203
+ <Fragment>
204
+ <StoreTitle>{title}</StoreTitle>
205
+ <Breadcrumbs categoryId={categoryId} customPage={shopby == "singles" ? "Mini-Figures" : title} />
206
+ <ul className={classes.nav}>
207
+ <li className={classes.nav_item}>
208
+ <button
209
+ onClick={() => {
210
+ handleActiveTab('year')
211
+ }}
212
+ >
213
+ {activeTab == 'year' ? <b>{byYearTitle}</b> : byYearTitle}
214
+ </button>
215
+ </li>
216
+ <li className={classes.nav_item}>
217
+ <button
218
+ onClick={() => {
219
+ handleActiveTab('all')
220
+ }}
221
+ >
222
+ {activeTab == 'all' ? <b>{allSetsTitle}</b> : allSetsTitle}
223
+ </button>
224
+ </li>
225
+ </ul>
226
+ {shopby == "lego_set_name" && activeTab == "all" ? <><ul className={classes.nav}>
227
+ {availableFilters.map((group, index) => (
228
+ <li key={index} className={classes.nav_item}>
229
+ <button
230
+ onClick={() => {
231
+ handleActiveFilter(group)
232
+ }}
233
+ >
234
+ {activeFilter == group ? <b>{group}</b> : group}
235
+ </button>
236
+ </li>
237
+ ))}<li className={classes.nav_item}>
238
+ <button
239
+ onClick={() => {
240
+ handleActiveFilter('')
241
+ }}
242
+ >
243
+ {!activeFilter ? <b>A-Z</b> : 'A-Z'}
244
+ </button>
245
+ </li></ul>
246
+
247
+ </> : ''}
248
+ <h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
249
+ {title}
250
+ </h1>
251
+ {activeTab == "year" && availableGroups ? <ul className={classes.nav}>
252
+ {availableGroups.map((group, index) => (
253
+ <li key={index} className={classes.nav_item}>
254
+ <button
255
+ onClick={() => {
256
+ handleActive(group)
257
+ }}
258
+ >
259
+ {active == group ? <b>{group}</b> : group}
260
+ </button>
261
+ </li>
262
+ ))}
263
+ <li className={classes.nav_item}>
264
+ <button
265
+ onClick={() => {
266
+ handleActive('all')
267
+ }}
268
+ >
269
+ {active == 'all' ? <b>All</b> : 'All'}
270
+ </button>
271
+ </li>
272
+ </ul> : ''}
273
+ <div className='border border-gray-100 px-6'>
274
+ {shopByBrands ? (
275
+ <div
276
+ className={classes.toolbar}
277
+ >
278
+ <div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
279
+ {/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
280
+ </div>
281
+ ) : ''}
282
+ <section className='single_list-indexing-container relative m-auto pt-5'>
283
+ {!activeFilter && activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
284
+ <li>
285
+ <button
286
+ className={cn(
287
+ 'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
288
+ 'leading-4 font-medium text-base hover_bg-gray-50'
289
+ )}
290
+ onClick={() => {
291
+ handleActive('all')
292
+ }}
293
+ >
294
+ {active == 'all' ? <b>All</b> : 'All'}
295
+ </button>
296
+ </li>
297
+ {alpha.map((letter, index) => (
298
+ <li key={index}>
299
+ <button
300
+ className={cn(
301
+ 'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
302
+ 'leading-4 font-medium text-base ',
303
+ setsLengthArr[letter] > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
304
+ )}
305
+ onClick={() => {
306
+ handleActive(letter)
307
+ }}
308
+ disabled={setsLengthArr[letter] > 0 ? false : true}
309
+ >
310
+ {active == letter ? <b>{letter}</b> : letter}
311
+ </button>
312
+ </li>
313
+ ))}
314
+ </ul>}
315
+ </section>
316
+ <Divider className="mb-5 px-4 mt-5" />
317
+ <section className='singles-container'>
318
+ <div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
319
+ {newShopByBrands && newShopByBrands.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>)}
320
+ </div>
321
+ </section>
322
+ </div>
323
+ </Fragment>
324
+ );
325
+ }
326
+
327
+ export default ShopByBrands;
@@ -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 './shopByBrands.module.css';
7
+ import cn from 'classnames';
8
+ import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
9
+
10
+ const ShopByBrands = 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 ShopByBrands;
@@ -0,0 +1 @@
1
+ export { default } from './shopByFilters';
@@ -0,0 +1,74 @@
1
+ import React 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 { useShopByFilters } from '@riosst100/pwa-marketplace/src/talons/ShopByFilters/useShopByFilters';
5
+ // import { Link } from 'react-router-dom';
6
+ // import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
7
+ import defaultClasses from './shopByFilters.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 CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
12
+ // import ArraySearchInput from '@riosst100/pwa-marketplace/src/components/ArraySearchInput';
13
+ // import { useCustomSort } from '@riosst100/pwa-marketplace/src/hooks/useCustomSort';
14
+ // import Breadcrumbs from '@magento/venia-ui/lib/components/Breadcrumbs';
15
+
16
+ const ShopByFilters = props => {
17
+ const { activeFilter, handleActiveFilter, category } = props;
18
+
19
+ const classes = useStyle(defaultClasses);
20
+
21
+ // const talonProps = useShopByFilters({ activeFilter, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
22
+
23
+ // const { error, loading, shopByBrands, categoryUrlSuffix, categoryUrlKey, productType, filteredShopByBrands, availableGroups, category } = talonProps;
24
+
25
+ // if (loading && !shopByBrands)
26
+ // return <ShopByBrandsShimmer />;
27
+ // if (error && !shopByBrands) return <ErrorView />;
28
+
29
+ // if (!shopByBrands && !loading && !error) {
30
+ // return <ShopByBrandsShimmer />;
31
+ // }
32
+
33
+ // url_path
34
+
35
+ let availableShopByFilters = [];
36
+
37
+ if (category.url_path.includes('model-railway')) {
38
+ availableShopByFilters = [
39
+ 'N Scale',
40
+ 'HO Scale',
41
+ 'O Scale',
42
+ 'G Scale',
43
+ 'S Scale',
44
+ 'Z Scale'
45
+ ];
46
+ }
47
+
48
+ return (
49
+ <ul className={classes.nav}>
50
+ {availableShopByFilters.map((label, index) => (
51
+ <li key={index} className={classes.nav_item}>
52
+ <button
53
+ onClick={() => {
54
+ handleActiveFilter(label)
55
+ }}
56
+ >
57
+ {activeFilter == label ? <b>{label}</b> : label}
58
+ </button>
59
+ </li>
60
+ ))}
61
+ <li className={classes.nav_item}>
62
+ <button
63
+ onClick={() => {
64
+ handleActiveFilter('')
65
+ }}
66
+ >
67
+ {!activeFilter ? <b>All</b> : 'All'}
68
+ </button>
69
+ </li>
70
+ </ul>
71
+ );
72
+ }
73
+
74
+ export default ShopByFilters;
@@ -0,0 +1,21 @@
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
+ }
@@ -17,7 +17,7 @@ import SportCardsSets from '@riosst100/pwa-marketplace/src/components/SportCards
17
17
  import NonSportCardsSets from '@riosst100/pwa-marketplace/src/components/NonSportCardsSets/nonSportCardsSets';
18
18
  import LegoSets from '@riosst100/pwa-marketplace/src/components/LegoSets/legoSets';
19
19
  import TrainsSets from '@riosst100/pwa-marketplace/src/components/TrainsSets/trainsSets';
20
- import ShopByVehicles from '@riosst100/pwa-marketplace/src/components/ShopByVehicles/shopByVehicles';
20
+ import ShopByBrands from '@riosst100/pwa-marketplace/src/components/ShopByBrands/shopByBrands';
21
21
 
22
22
  const MESSAGES = new Map().set(
23
23
  'NOT_FOUND',
@@ -94,9 +94,6 @@ const Category = props => {
94
94
  isLoading={loading} /> : shopby && parentCategoryUrlKey == "non-sports-cards" ? <NonSportCardsSets
95
95
  categoryId={uid}
96
96
  shopby={shopby}
97
- isLoading={loading} /> : shopby == "trains_brands" || shopby == "trains_roadname" ? <TrainsSets
98
- categoryId={uid}
99
- shopby={shopby}
100
97
  isLoading={loading} /> : shopby == "sc_baseball_players" || shopby == "sc_baseball_teams" || shopby == "release" && parentCategoryUrlKey == "sport-cards" ? <SportCardsSets
101
98
  categoryId={uid}
102
99
  shopby={shopby}
@@ -266,7 +266,7 @@ const CategoryContent = props => {
266
266
  if (label == "Singles") {
267
267
  isSingles = true;
268
268
  }
269
- if (key == "toys_product_line" && urlKey == "brands" || key == "toys_product_line" && urlKey == "franchise" || key == "toys_franchise" && urlKey == "brands" || key == "toys_franchise" && urlKey == "franchise" || key == "toys_brands" && urlKey == "franchise" || key == "toys_brands" && urlKey == "brands" || virtualCategoryFilters.includes(key)) {
269
+ if (key == "toys_product_line" && urlKey == "brands" || key == "toys_product_line" && urlKey == "franchise" || key == "toys_franchise" && urlKey == "brands" || key == "toys_franchise" && urlKey == "franchise" || key == "toys_brands" && urlKey == "franchise" || key == "toys_brands" && urlKey == "brands" || virtualCategoryFilters && virtualCategoryFilters.includes(key)) {
270
270
  activeFilters.push(
271
271
  {
272
272
  'label': label,
@@ -30,7 +30,7 @@ const CustomSubmenuColumn = props => {
30
30
  );
31
31
 
32
32
  return (
33
- <li key={index} className={cn(classes.submenuChildItem, 'mt-4')}>
33
+ <li key={index} className={cn(classes.submenuChildItem, 'mt-1')}>
34
34
  <Link
35
35
  className={classes.link}
36
36
  data-cy="MegaMenu-CustomSubmenuColumn-link"
@@ -51,7 +51,7 @@ const ShopByColumn = props => {
51
51
  ;
52
52
 
53
53
  return (
54
- <li key={index} className={cn(classes.submenuChildItem, 'mt-4')}>
54
+ <li key={index} className={cn(classes.submenuChildItem, 'mt-0')}>
55
55
  <Link
56
56
  {...keyboardProps}
57
57
  // className={isActive ? classes.linkActive : classes.link}
@@ -3,7 +3,7 @@
3
3
  composes: bg-white from global;
4
4
  composes: left-0 from global;
5
5
  composes: px-3 from global;
6
- composes: py-5 from global;
6
+ composes: py-1 from global;
7
7
  composes: right-0 from global;
8
8
  top: 130px;
9
9
  box-shadow: 0 3px rgb(var(--venia-global-color-gray-100));
@@ -41,7 +41,7 @@
41
41
 
42
42
  .submenuItems {
43
43
  composes: grid from global;
44
- composes: grid-cols-6 from global;
44
+ composes: grid-cols-6 pb-2 from global;
45
45
  /* composes: justify-between from global; */
46
46
  /* composes: ml-auto from global; */
47
47
  /* composes: mr-auto from global; */
@@ -74,7 +74,7 @@ const SubmenuColumn = props => {
74
74
  ) : '';
75
75
 
76
76
  return (
77
- <li key={index} className={cn(classes.submenuChildItem, 'mt-4')}>
77
+ <li key={index} className={cn(classes.submenuChildItem, 'mt-0')}>
78
78
  {customMenuItems.length ? (
79
79
  <>
80
80
  <Link
@@ -1,6 +1,6 @@
1
1
  .submenuColumn {
2
2
  /* composes: max-w-[235px] from global; */
3
- composes: p-2 from global;
3
+ composes: pl-4 pt-2 from global;
4
4
  }
5
5
 
6
6
  .heading {
@@ -1,8 +1,8 @@
1
1
  import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_CUSTOM_FILTERS = gql`
4
- query GetCustomFilters($filterBy: String, $shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
5
- customSubFilters(filterBy: $filterBy, shopby: $shopby, category: $category, filters: $filters) {
4
+ query GetCustomFilters($search: String, $filterBy: String, $shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
5
+ customSubFilters(search: $search, filterBy: $filterBy, shopby: $shopby, category: $category, filters: $filters) {
6
6
  label
7
7
  count
8
8
  attribute_code
@@ -79,7 +79,8 @@ export const useFilterTop = props => {
79
79
  filters: newFilters,
80
80
  category: category?.url_path,
81
81
  shopby: shopby,
82
- filterBy: filterBy
82
+ filterBy: filterBy,
83
+ search: search
83
84
  }
84
85
  });
85
86
  }, [
@@ -12,8 +12,8 @@ export const GET_STORE_CONFIG_DATA = gql`
12
12
  `;
13
13
 
14
14
  export const GET_SHOP_BY_DATA_QUERY = gql`
15
- query getShopByData($activeFilter: String, $categoryUrlKey: String!, $attributeCode: String, $filters: ProductAttributeFilterInput!) {
16
- shopByData(activeFilter: $activeFilter, categoryUrlKey: $categoryUrlKey, attributeCode: $attributeCode, filters: $filters) {
15
+ query getShopByData($search: String, $activeFilter: String, $categoryUrlKey: String!, $attributeCode: String, $filters: ProductAttributeFilterInput!) {
16
+ shopByData(search: $search, activeFilter: $activeFilter, categoryUrlKey: $categoryUrlKey, attributeCode: $attributeCode, filters: $filters) {
17
17
  label
18
18
  count
19
19
  attribute_code
@@ -93,7 +93,8 @@ export const useShopBy = props => {
93
93
  filters: newFilters,
94
94
  categoryUrlKey: categoryUrlKey,
95
95
  attributeCode: shopby,
96
- activeFilter: activeFilter
96
+ activeFilter: activeFilter,
97
+ search: search
97
98
  }
98
99
  });
99
100
  }, [
@@ -103,7 +104,7 @@ export const useShopBy = props => {
103
104
  // categoryUrlKey,
104
105
  // filters
105
106
  // filterTypeMap,
106
- // search
107
+ search
107
108
  ]);
108
109
 
109
110
  // console.log(activeFilters)
@@ -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_LEGO_SETS_QUERY = gql`
15
+ query getShopByBrands($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
16
+ shopByBrands(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
+ getShopByBrandsQuery: GET_LEGO_SETS_QUERY,
57
+ getCategoryContentQuery: GET_CATEGORY_CONTENT,
58
+ getFilterInputsQuery: GET_FILTER_INPUTS,
59
+ };
@@ -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_LEGO_SETS_QUERY = gql`
15
+ query getShopByBrands($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
16
+ shopByBrands(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
+ getShopByBrandsQuery: GET_LEGO_SETS_QUERY,
57
+ getCategoryContentQuery: GET_CATEGORY_CONTENT,
58
+ getFilterInputsQuery: GET_FILTER_INPUTS,
59
+ };
@@ -0,0 +1,218 @@
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 './shopByBrands.gql';
8
+ import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
9
+
10
+ export const useShopByBrands = 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, getShopByBrandsQuery, getCategoryContentQuery, getFilterInputsQuery } = operations;
18
+ const { pathname, search } = useLocation();
19
+ const [runQuery, queryResponse] = useLazyQuery(getShopByBrandsQuery, {
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(getShopByBrandsQuery, {
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
+ // Construct the filter arg object.
55
+ const newFilters = {};
56
+ filters.forEach((values, key) => {
57
+ newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
58
+
59
+ if (key == "sc_baseball_release") {
60
+ for(let item of values) {
61
+ if(item) {
62
+ // console.log(item.split(',')[0])
63
+ const data = search.split('&');
64
+ data.pop();
65
+ activeFilters.push(
66
+ {
67
+ 'label': item.split(',')[0],
68
+ 'path': data
69
+ }
70
+ )
71
+ }
72
+ }
73
+ }
74
+ });
75
+
76
+ useEffect(() => {
77
+ // console.log("MASUK")
78
+
79
+ // if (queryResponse.data) {
80
+
81
+
82
+
83
+ // Use the category uid for the current category page regardless of the
84
+ // applied filters. Follow-up in PWA-404.
85
+ // newFilters['category_uid'] = { eq: id };
86
+
87
+ runQuery({
88
+ variables: {
89
+ filters: newFilters,
90
+ categoryUrlKey: categoryUrlKey,
91
+ activeTab: activeTab,
92
+ shopby: shopby,
93
+ activeFilter: activeFilter
94
+ }
95
+ });
96
+ // }
97
+ }, [
98
+ runQuery,
99
+ activeTab,
100
+ activeFilter
101
+ // queryResponse
102
+ // filterTypeMap,
103
+ // search,
104
+ // newFilters,
105
+ // shopby,
106
+ // categoryUrlKey
107
+ ]);
108
+
109
+ const { data: storeConfigData } = useQuery(getStoreConfigData, {
110
+ fetchPolicy: 'cache-and-network',
111
+ nextFetchPolicy: 'cache-first'
112
+ });
113
+
114
+ const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
115
+
116
+ // { data: queryResponse, error, loading }
117
+
118
+
119
+
120
+ // console.log(data)
121
+
122
+ // const isBackgroundLoading = !!data && loading;
123
+
124
+ const availableLeagues = [];
125
+
126
+ // console.log(queryResponse.data)
127
+
128
+ const shopByBrands = useMemo(() => {
129
+ if (!queryResponse) {
130
+ return null;
131
+ }
132
+
133
+ // console.log(data)
134
+
135
+ const shopByBrands = queryResponse?.data?.shopByBrands;
136
+ if (!shopByBrands) {
137
+ return null;
138
+ }
139
+
140
+ return shopByBrands.slice().sort((a, b) =>a.group.toLowerCase().localeCompare(b.group.toLowerCase()));
141
+ }, [queryResponse]);
142
+
143
+ const availableGroups = shopByBrands && shopByBrands.length ? shopByBrands.map(({ group }) => group) : [];
144
+
145
+ // const availableLeagues = shopByBrands && shopByBrands.length ? shopByBrands.map(({ sets }) => shopByBrands.map(({ sc_league }) => sc_league)) : [];
146
+ // console.log(availableLeagues)
147
+ // sc_league
148
+
149
+ const filteredShopByBrands = useMemo(() => {
150
+ if (!shopByBrands) {
151
+ return null;
152
+ }
153
+
154
+ const filteredSets = [];
155
+
156
+ if (searchQuery) {
157
+
158
+ // useEffect(() => {
159
+ // setActive('all')
160
+ // }, [active]);
161
+
162
+ shopByBrands.map(({ group, sets }, index) => {
163
+ const newSets = sets.filter(function(set) {
164
+ return set.set_name.search(new RegExp(searchQuery, "i")) != -1 || group.search(new RegExp(searchQuery, "i")) != -1;
165
+ // return set.set_name.includes(searchQuery);
166
+ });
167
+
168
+ if (newSets && newSets.length) {
169
+ filteredSets.push({
170
+ 'group': group,
171
+ 'sets': newSets
172
+ })
173
+ }
174
+ })
175
+ }
176
+
177
+ return searchQuery ? filteredSets : shopByBrands;
178
+ }, [shopByBrands, searchQuery]);
179
+
180
+ // useEffect(() => {
181
+ // setPageLoading(isBackgroundLoading);
182
+ // }, [isBackgroundLoading, setPageLoading]);
183
+
184
+ const { data: categoryData, loading: categoryLoading } = useQuery(
185
+ getCategoryContentQuery,
186
+ {
187
+ fetchPolicy: 'cache-and-network',
188
+ nextFetchPolicy: 'cache-first',
189
+ skip: !categoryId,
190
+ variables: {
191
+ id: categoryId
192
+ }
193
+ }
194
+ );
195
+
196
+ const category =
197
+ categoryData && categoryData.categories.items.length
198
+ ? categoryData.categories.items[0]
199
+ : null;
200
+
201
+ const error = queryResponse?.error;
202
+ const loading = queryResponse?.loading;
203
+
204
+ // console.log(shopByBrands)
205
+
206
+ return {
207
+ error,
208
+ loading,
209
+ shopByBrands,
210
+ filteredShopByBrands,
211
+ categoryUrlSuffix,
212
+ categoryUrlKey,
213
+ productType,
214
+ availableGroups,
215
+ category,
216
+ // availableLeagues
217
+ };
218
+ };