@riosst100/pwa-marketplace 1.9.4 → 1.9.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/FilterTop/CurrentTopFilters/currentTopFilter.js +1 -1
- package/src/components/FilterTop/FilterBlockList/filterBlockList.js +5 -1
- package/src/components/FilterTop/FilterBlockList/filterTopItem.js +11 -2
- package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.js +4 -2
- package/src/components/FilterTop/filterTop.js +6 -1
- package/src/components/FilterTop/filterTopBlock.js +5 -1
- package/src/components/ShopByBrands/index.js +2 -0
- package/src/components/ShopByBrands/legoSets.shimmer.js +50 -0
- package/src/components/ShopByBrands/shopByBrands.js +327 -0
- package/src/components/ShopByBrands/shopByBrands.module.css +76 -0
- package/src/components/ShopByBrands/shopByBrands.shimmer.js +50 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategory.js +8 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +5 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +6 -5
- package/src/overwrites/venia-ui/lib/components/MegaMenu/customSubmenuColumn.js +21 -2
- package/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +38 -3
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +2 -2
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +1 -1
- package/src/talons/FilterTop/filterTop.gql.js +2 -2
- package/src/talons/FilterTop/useFilterTop.js +5 -3
- package/src/talons/ShopByBrands/shopByBrands.gql.js +59 -0
- package/src/talons/ShopByBrands/shopByBrands.js +59 -0
- package/src/talons/ShopByBrands/useShopByBrands.js +218 -0
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ const CurrentTopFilter = props => {
|
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
return 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 != "trains_gauge" && group != "category" && group != "shopby" ? (
|
|
35
35
|
<span className={classes.item} data-cy="CurrentTopFilter-root">
|
|
36
36
|
<Trigger
|
|
37
37
|
action={handleClick}
|
|
@@ -13,13 +13,17 @@ const FilterBlockList = props => {
|
|
|
13
13
|
onApply,
|
|
14
14
|
filterNames,
|
|
15
15
|
originalFilterState,
|
|
16
|
-
search
|
|
16
|
+
search,
|
|
17
|
+
setFilterBy,
|
|
18
|
+
filterBy
|
|
17
19
|
} = props;
|
|
18
20
|
|
|
19
21
|
const itemElements = useMemo(() => {
|
|
20
22
|
const key = `item-${group}`;
|
|
21
23
|
return (
|
|
22
24
|
<FilterTopItemGroup
|
|
25
|
+
setFilterBy={setFilterBy}
|
|
26
|
+
filterBy={filterBy}
|
|
23
27
|
filterApi={filterApi}
|
|
24
28
|
filterState={filterState}
|
|
25
29
|
group={group}
|
|
@@ -4,7 +4,7 @@ import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
5
|
|
|
6
6
|
const FilterTopItem = props => {
|
|
7
|
-
const { filterApi, group, item, onApply, labels, activeFilters, search } = props;
|
|
7
|
+
const { setFilterBy, filterBy, filterApi, group, item, onApply, labels, activeFilters, search } = props;
|
|
8
8
|
const { removeGroup, toggleItem } = filterApi;
|
|
9
9
|
const { title, value } = item;
|
|
10
10
|
|
|
@@ -20,6 +20,7 @@ const FilterTopItem = props => {
|
|
|
20
20
|
toggleItem({ group, item });
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
setFilterBy('')
|
|
23
24
|
if (typeof onApply === 'function') {
|
|
24
25
|
onApply(group, item);
|
|
25
26
|
}
|
|
@@ -27,8 +28,16 @@ const FilterTopItem = props => {
|
|
|
27
28
|
[group, item, onApply, removeGroup, toggleItem]
|
|
28
29
|
);
|
|
29
30
|
|
|
30
|
-
const element = group == "
|
|
31
|
+
const element = group == "filterby" ? (
|
|
32
|
+
filterBy == value ? (
|
|
33
|
+
<span className={classes.item}><b>{title}</b></span>
|
|
34
|
+
) : (
|
|
35
|
+
<span className={classes.item} onClick={() => setFilterBy(value)}>{title}</span>
|
|
36
|
+
)
|
|
37
|
+
) : group == "category" ? (
|
|
31
38
|
<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>
|
|
32
41
|
) : group == "shopby" || group == "shopby_with_all" ? (
|
|
33
42
|
<Link className={classes.item} to={search ? search + '&shopby=' + value : '?shopby=' + value}>{title}</Link>
|
|
34
43
|
) : (
|
|
@@ -7,7 +7,7 @@ import defaultClasses from './filterTopItemGroup.module.css';
|
|
|
7
7
|
import CurrentTopFilter from '@riosst100/pwa-marketplace/src/components/FilterTop/CurrentTopFilters/currentTopFilter';
|
|
8
8
|
|
|
9
9
|
const FilterTopItemGroup = props => {
|
|
10
|
-
const { filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState, search } = props;
|
|
10
|
+
const { setFilterBy, filterBy, filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState, search } = props;
|
|
11
11
|
|
|
12
12
|
const classes = useStyle(defaultClasses, props.classes);
|
|
13
13
|
|
|
@@ -46,6 +46,8 @@ const FilterTopItemGroup = props => {
|
|
|
46
46
|
return (
|
|
47
47
|
<FilterTopItem
|
|
48
48
|
key={code}
|
|
49
|
+
setFilterBy={setFilterBy}
|
|
50
|
+
filterBy={filterBy}
|
|
49
51
|
filterApi={filterApi}
|
|
50
52
|
filterState={filterState}
|
|
51
53
|
group={group}
|
|
@@ -85,7 +87,7 @@ const FilterTopItemGroup = props => {
|
|
|
85
87
|
<div className={classes.root}>
|
|
86
88
|
{radioItems}
|
|
87
89
|
{filterElements && filterElements.length > 10 ? <span className={classes.item}><b>More Item</b></span> : ''}
|
|
88
|
-
{filterElements && filterElements.length ? filterElements : group != "trains" && group != "trains_gauge" && group != "toys_franchise" && group != "toys_brands" && group != "category" && 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 != "trains_gauge" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "filterby" && group != "shopby" ? (<span className={classes.item}><b>All</b></span>) : ''}
|
|
89
91
|
</div>
|
|
90
92
|
);
|
|
91
93
|
};
|
|
@@ -23,7 +23,10 @@ const SCROLL_OFFSET = 150;
|
|
|
23
23
|
*/
|
|
24
24
|
const FilterTop = props => {
|
|
25
25
|
const { shopby, filters, filterCountToOpen, allowedFilters, category } = props;
|
|
26
|
-
const
|
|
26
|
+
const [filterBy, setFilterBy] = useState('');
|
|
27
|
+
|
|
28
|
+
// console.log(filterBy)
|
|
29
|
+
const talonProps = useFilterTop({ shopby, filters, category, filterBy, setFilterBy });
|
|
27
30
|
const {
|
|
28
31
|
filterApi,
|
|
29
32
|
filterItems,
|
|
@@ -116,6 +119,8 @@ const FilterTop = props => {
|
|
|
116
119
|
return (
|
|
117
120
|
<FilterTopBlock
|
|
118
121
|
key={group}
|
|
122
|
+
setFilterBy={setFilterBy}
|
|
123
|
+
filterBy={filterBy}
|
|
119
124
|
filterNames={filterNames}
|
|
120
125
|
filterApi={filterApi}
|
|
121
126
|
filterState={blockState}
|
|
@@ -25,7 +25,9 @@ const FilterTopBlock = props => {
|
|
|
25
25
|
filterNames,
|
|
26
26
|
initialOpen,
|
|
27
27
|
originalFilterState,
|
|
28
|
-
search
|
|
28
|
+
search,
|
|
29
|
+
setFilterBy,
|
|
30
|
+
filterBy
|
|
29
31
|
} = props;
|
|
30
32
|
|
|
31
33
|
const { formatMessage } = useIntl();
|
|
@@ -37,6 +39,8 @@ const FilterTopBlock = props => {
|
|
|
37
39
|
|
|
38
40
|
const list = <Form>
|
|
39
41
|
<FilterBlockList
|
|
42
|
+
setFilterBy={setFilterBy}
|
|
43
|
+
filterBy={filterBy}
|
|
40
44
|
filterApi={filterApi}
|
|
41
45
|
filterState={filterState}
|
|
42
46
|
originalFilterState={originalFilterState}
|
|
@@ -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;
|
|
@@ -56,6 +56,11 @@ export const useCategory = props => {
|
|
|
56
56
|
|
|
57
57
|
const sortProps = useSort({ sortFromSearch: false });
|
|
58
58
|
const [currentSort] = sortProps;
|
|
59
|
+
|
|
60
|
+
const { pathname } = useLocation();
|
|
61
|
+
|
|
62
|
+
const pathnameArr = pathname.split('/');
|
|
63
|
+
const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
|
|
59
64
|
|
|
60
65
|
// Keep track of the sort criteria so we can tell when they change.
|
|
61
66
|
const previousSort = useRef(currentSort);
|
|
@@ -132,7 +137,9 @@ export const useCategory = props => {
|
|
|
132
137
|
|
|
133
138
|
// Use the category uid for the current category page regardless of the
|
|
134
139
|
// applied filters. Follow-up in PWA-404.
|
|
135
|
-
|
|
140
|
+
if (categoryUrlKey != "brands" && categoryUrlKey != "franchise") {
|
|
141
|
+
newFilters['category_uid'] = { eq: id };
|
|
142
|
+
}
|
|
136
143
|
|
|
137
144
|
runQuery({
|
|
138
145
|
variables: {
|
|
@@ -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
|
|
20
|
+
import ShopByBrands from '@riosst100/pwa-marketplace/src/components/ShopByBrands/shopByBrands';
|
|
21
21
|
|
|
22
22
|
const MESSAGES = new Map().set(
|
|
23
23
|
'NOT_FOUND',
|
|
@@ -88,7 +88,10 @@ const Category = props => {
|
|
|
88
88
|
categoryId={uid}
|
|
89
89
|
isLoading={loading} />
|
|
90
90
|
) : (
|
|
91
|
-
shopby == "
|
|
91
|
+
shopby == "all_brands" ? <ShopByBrands
|
|
92
|
+
categoryId={uid}
|
|
93
|
+
shopby={shopby}
|
|
94
|
+
isLoading={loading} /> : shopby == "singles" || shopby == "lego_set_name" && parentCategoryUrlKey == "lego" ? <LegoSets
|
|
92
95
|
categoryId={uid}
|
|
93
96
|
shopby={shopby}
|
|
94
97
|
isLoading={loading} /> : shopby && parentCategoryUrlKey == "non-sports-cards" ? <NonSportCardsSets
|
|
@@ -93,8 +93,8 @@ const CategoryContent = props => {
|
|
|
93
93
|
history.replace('/cards/non-sports-cards/comics.html')
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
if (urlKey == "
|
|
97
|
-
history.replace('/lego
|
|
96
|
+
if (urlKey == "lego") {
|
|
97
|
+
history.replace('/lego/lego-sets.html')
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}, [category]);
|
|
@@ -266,7 +266,7 @@ const CategoryContent = props => {
|
|
|
266
266
|
if (label == "Singles") {
|
|
267
267
|
isSingles = true;
|
|
268
268
|
}
|
|
269
|
-
if (key == "toys_franchise" && 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.includes(key)) {
|
|
270
270
|
activeFilters.push(
|
|
271
271
|
{
|
|
272
272
|
'label': label,
|
|
@@ -286,7 +286,7 @@ const CategoryContent = props => {
|
|
|
286
286
|
|
|
287
287
|
let title = activeFilters && activeFilters.length ? (
|
|
288
288
|
activeFilters.length > 1 ?
|
|
289
|
-
activeFilters.
|
|
289
|
+
activeFilters[activeFilters.length - 1].label
|
|
290
290
|
: currentFilter
|
|
291
291
|
) : categoryName;
|
|
292
292
|
|
|
@@ -313,8 +313,9 @@ const CategoryContent = props => {
|
|
|
313
313
|
{/* {activeFilters.size <= 0 && category && category.custom_landing_page ? ( */}
|
|
314
314
|
<>
|
|
315
315
|
{currentFilter && <AlphaFilter isSingles={isSingles} items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
|
|
316
|
-
{shopby != "gauge" ? <SubCategory parent={parent} children={children} /> : ''}
|
|
317
316
|
{!currentFilter && <CustomSubCategory categoryName={category ? category.name : null} customSubCategory={category ? category.custom_subcategory : null} />}
|
|
317
|
+
{shopby != "gauge" ? <SubCategory parent={parent} children={children} /> : ''}
|
|
318
|
+
|
|
318
319
|
</>
|
|
319
320
|
{/* ) : ( */}
|
|
320
321
|
<>
|
|
@@ -30,7 +30,7 @@ const CustomSubmenuColumn = props => {
|
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<li key={index} className={cn(classes.submenuChildItem, '
|
|
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"
|
|
@@ -47,10 +47,29 @@ const CustomSubmenuColumn = props => {
|
|
|
47
47
|
);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
children =
|
|
50
|
+
children = <>
|
|
51
|
+
<ul className={cn(classes.submenuChild, 'pt-1')}><span className={classes.heading}>Categories</span>{childrenItems}</ul>
|
|
52
|
+
</>;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
return children;
|
|
56
|
+
// return (
|
|
57
|
+
// <div className={classes.submenuColumn}>
|
|
58
|
+
// <Link
|
|
59
|
+
// // {...keyboardProps}
|
|
60
|
+
// className={classes.link}
|
|
61
|
+
// data-cy="MegaMenu-SubmenuColumn-link"
|
|
62
|
+
// // to={categoryUrl}
|
|
63
|
+
// // onClick={() => {
|
|
64
|
+
// // handleCloseSubMenu();
|
|
65
|
+
// // onNavigate();
|
|
66
|
+
// // }}
|
|
67
|
+
// >
|
|
68
|
+
// <span className={classes.heading}>{category.name}</span>
|
|
69
|
+
// </Link>
|
|
70
|
+
// {children}
|
|
71
|
+
// </div>
|
|
72
|
+
// );
|
|
54
73
|
};
|
|
55
74
|
|
|
56
75
|
export default CustomSubmenuColumn;
|
|
@@ -51,7 +51,7 @@ const ShopByColumn = props => {
|
|
|
51
51
|
;
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
|
-
<li key={index} className={cn(classes.submenuChildItem, 'mt-
|
|
54
|
+
<li key={index} className={cn(classes.submenuChildItem, 'mt-0')}>
|
|
55
55
|
<Link
|
|
56
56
|
{...keyboardProps}
|
|
57
57
|
// className={isActive ? classes.linkActive : classes.link}
|
|
@@ -7,6 +7,7 @@ import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
|
7
7
|
import defaultClasses from './submenu.module.css';
|
|
8
8
|
import SubmenuColumn from './submenuColumn';
|
|
9
9
|
import ShopByColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn';
|
|
10
|
+
import CustomSubmenuColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/customSubmenuColumn';
|
|
10
11
|
import cn from 'classnames';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -44,6 +45,29 @@ const Submenu = props => {
|
|
|
44
45
|
? classes.submenu_active
|
|
45
46
|
: classes.submenu_inactive;
|
|
46
47
|
|
|
48
|
+
// const subMenus = items.map((category, index) => {
|
|
49
|
+
// const keyboardProps =
|
|
50
|
+
// index === items.length - 1 ? talonProps.keyboardProps : {};
|
|
51
|
+
// return (
|
|
52
|
+
// <SubmenuColumn
|
|
53
|
+
// index={index}
|
|
54
|
+
// keyboardProps={keyboardProps}
|
|
55
|
+
// key={category.uid}
|
|
56
|
+
// category={category}
|
|
57
|
+
// categoryUrlSuffix={categoryUrlSuffix}
|
|
58
|
+
// onNavigate={onNavigate}
|
|
59
|
+
// arrow={arrow}
|
|
60
|
+
// handleCloseSubMenu={handleCloseSubMenu}
|
|
61
|
+
// />
|
|
62
|
+
// );
|
|
63
|
+
// });
|
|
64
|
+
// const subMenus = <CustomSubmenuColumn
|
|
65
|
+
// categoryUrlSuffix={categoryUrlSuffix}
|
|
66
|
+
// onNavigate={onNavigate}
|
|
67
|
+
// arrow={arrow}
|
|
68
|
+
// handleCloseSubMenu={handleCloseSubMenu}
|
|
69
|
+
// customMenuItems={items}
|
|
70
|
+
// />;
|
|
47
71
|
const subMenus = items.map((category, index) => {
|
|
48
72
|
const keyboardProps =
|
|
49
73
|
index === items.length - 1 ? talonProps.keyboardProps : {};
|
|
@@ -61,7 +85,16 @@ const Submenu = props => {
|
|
|
61
85
|
);
|
|
62
86
|
});
|
|
63
87
|
|
|
64
|
-
// const
|
|
88
|
+
// const shopByItems2 = [
|
|
89
|
+
// {
|
|
90
|
+
// name: 'Shop By Franchise',
|
|
91
|
+
// items: [
|
|
92
|
+
// {
|
|
93
|
+
// name: 'Hasbro',
|
|
94
|
+
// url: '/'
|
|
95
|
+
// }
|
|
96
|
+
// ]
|
|
97
|
+
// },
|
|
65
98
|
// {
|
|
66
99
|
// name: 'Shop By Franchise',
|
|
67
100
|
// items: [
|
|
@@ -101,10 +134,12 @@ const Submenu = props => {
|
|
|
101
134
|
<div
|
|
102
135
|
className={cn(
|
|
103
136
|
classes.submenuItems,
|
|
104
|
-
'grid grid-cols-
|
|
137
|
+
'grid grid-cols-6',
|
|
105
138
|
)}
|
|
106
139
|
>
|
|
107
|
-
{
|
|
140
|
+
{shopByItems.length ? (<div className={classes.submenuColumn}>
|
|
141
|
+
{subMenus}
|
|
142
|
+
</div>) : subMenus}
|
|
108
143
|
{shopBy}
|
|
109
144
|
</div>
|
|
110
145
|
</div>
|
|
@@ -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-
|
|
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-
|
|
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; */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
3
|
export const GET_CUSTOM_FILTERS = gql`
|
|
4
|
-
query GetCustomFilters($shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
|
|
5
|
-
customSubFilters(shopby: $shopby, category: $category, filters: $filters) {
|
|
4
|
+
query GetCustomFilters($filterBy: String, $shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
|
|
5
|
+
customSubFilters(filterBy: $filterBy, shopby: $shopby, category: $category, filters: $filters) {
|
|
6
6
|
label
|
|
7
7
|
count
|
|
8
8
|
attribute_code
|
|
@@ -21,7 +21,7 @@ import DEFAULT_OPERATIONS from './filterTop.gql';
|
|
|
21
21
|
const DRAWER_NAME = 'filter';
|
|
22
22
|
|
|
23
23
|
export const useFilterTop = props => {
|
|
24
|
-
const { filters, category, shopby } = props;
|
|
24
|
+
const { filters, category, shopby, filterBy, setFilterBy } = props;
|
|
25
25
|
|
|
26
26
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
27
27
|
const { getFilterInputsQuery, getCustomFilters } = operations;
|
|
@@ -78,14 +78,16 @@ export const useFilterTop = props => {
|
|
|
78
78
|
variables: {
|
|
79
79
|
filters: newFilters,
|
|
80
80
|
category: category?.url_path,
|
|
81
|
-
shopby: shopby
|
|
81
|
+
shopby: shopby,
|
|
82
|
+
filterBy: filterBy
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
85
|
}, [
|
|
85
86
|
runQuery,
|
|
86
87
|
filterTypeMap,
|
|
87
88
|
search,
|
|
88
|
-
category
|
|
89
|
+
category,
|
|
90
|
+
filterBy
|
|
89
91
|
]);
|
|
90
92
|
|
|
91
93
|
const attributeCodes = useMemo(
|
|
@@ -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
|
+
};
|