@riosst100/pwa-marketplace 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/AlphaFilter/alphaFilter.js +23 -6
- package/src/components/ArraySearchInput/arraySearchInput.js +100 -0
- package/src/components/ArraySearchInput/arraySearchInput.module.css +48 -0
- package/src/components/ArraySearchInput/index.js +1 -0
- package/src/components/CollectibleGameSets/collectibleGameSets.js +53 -25
- package/src/components/CollectibleGameSets/collectibleGameSets.module.css +8 -0
- package/src/components/CustomSortBy/customSortBy.js +9 -11
- package/src/components/CustomSubCategory/subCategory.js +2 -1
- package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.module.css +1 -1
- package/src/components/FilterTop/filterTop.js +1 -1
- package/src/components/ShopBy/index.js +2 -0
- package/src/components/ShopBy/shopBy.js +237 -0
- package/src/components/ShopBy/shopBy.module.css +46 -0
- package/src/components/ShopBy/shopBy.shimmer.js +50 -0
- package/src/components/ShopByPage/index.js +1 -0
- package/src/components/ShopByPage/shopByPage.js +12 -0
- package/src/hooks/useCustomSort.js +21 -0
- package/src/intercept.js +1 -8
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +2 -2
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +1 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryFragments.gql.js +31 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +13 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +30 -5
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +5 -5
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.js +3 -3
- package/src/talons/ArraySearchInput/useArraySearchInput.js +58 -0
- package/src/talons/CollectibleGameSets/useCollectibleGameSets.js +75 -2
- package/src/talons/ShopBy/shopBy.gql.js +47 -0
- package/src/talons/ShopBy/useShopBy.js +171 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React, { Fragment, Suspense, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { array, number, shape, string } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
|
|
6
|
+
import { useCategoryContent } from '@magento/peregrine/lib/talons/RootComponents/Category';
|
|
7
|
+
|
|
8
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
9
|
+
import Breadcrumbs from '@magento/venia-ui/lib/components/Breadcrumbs';
|
|
10
|
+
import FilterModalOpenButton, {
|
|
11
|
+
FilterModalOpenButtonShimmer
|
|
12
|
+
} from '@magento/venia-ui/lib/components/FilterModalOpenButton';
|
|
13
|
+
import { FilterSidebarShimmer } from '@magento/venia-ui/lib/components/FilterSidebar';
|
|
14
|
+
import Gallery, { GalleryShimmer } from '@magento/venia-ui/lib/components/Gallery';
|
|
15
|
+
import Pagination from '@magento/venia-ui/lib/components/Pagination';
|
|
16
|
+
import ProductSort, { ProductSortShimmer } from '@magento/venia-ui/lib/components/ProductSort';
|
|
17
|
+
import RichContent from '@magento/venia-ui/lib/components/RichContent';
|
|
18
|
+
import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
|
|
19
|
+
import SortedByContainer, {
|
|
20
|
+
SortedByContainerShimmer
|
|
21
|
+
} from '@magento/venia-ui/lib/components/SortedByContainer';
|
|
22
|
+
import NoProductsFound from '@magento/venia-ui/lib/RootComponents/Category/NoProductsFound';
|
|
23
|
+
import cn from 'classnames';
|
|
24
|
+
import ProductListTab, { ProductListTabShimmer } from '@riosst100/pwa-marketplace/src/components/ProductListTab';
|
|
25
|
+
import SubCategory from '@riosst100/pwa-marketplace/src/components/SubCategory/subCategory';
|
|
26
|
+
import AttributesBlock from '@riosst100/pwa-marketplace/src/components/AttributesBlock/attributesBlock';
|
|
27
|
+
|
|
28
|
+
import BrandSlider from '@riosst100/pwa-marketplace/src/components/BrandSlider';
|
|
29
|
+
import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets/collectibleGameSets';
|
|
30
|
+
import { useLocation } from 'react-router-dom';
|
|
31
|
+
import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
32
|
+
import CustomSubCategory from '@riosst100/pwa-marketplace/src/components/SubCategory/customSubCategory';
|
|
33
|
+
import AlphaFilter from '@riosst100/pwa-marketplace/src/components/AlphaFilter';
|
|
34
|
+
|
|
35
|
+
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
36
|
+
import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
|
|
37
|
+
import { Link } from 'react-router-dom';
|
|
38
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
39
|
+
import defaultClasses from './shopBy.module.css';
|
|
40
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
41
|
+
import { ShopByShimmer } from '@riosst100/pwa-marketplace/src/components/ShopBy';
|
|
42
|
+
import CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
|
|
43
|
+
import ArraySearchInput from '@riosst100/pwa-marketplace/src/components/ArraySearchInput';
|
|
44
|
+
import { useCustomSort } from '@riosst100/pwa-marketplace/src/hooks/useCustomSort';
|
|
45
|
+
import { useShopBy } from '@riosst100/pwa-marketplace/src/talons/ShopBy/useShopBy';
|
|
46
|
+
|
|
47
|
+
const FilterModal = React.lazy(() => import('@magento/venia-ui/lib/components/FilterModal'));
|
|
48
|
+
const FilterSidebar = React.lazy(() =>
|
|
49
|
+
import('@magento/venia-ui/lib/components/FilterSidebar')
|
|
50
|
+
);
|
|
51
|
+
const FilterTop = React.lazy(() =>
|
|
52
|
+
import('@riosst100/pwa-marketplace/src/components/FilterTop')
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const ShopBy = props => {
|
|
56
|
+
const {
|
|
57
|
+
categoryId,
|
|
58
|
+
shopby
|
|
59
|
+
// data,
|
|
60
|
+
// isLoading,
|
|
61
|
+
// pageControl,
|
|
62
|
+
// sortProps,
|
|
63
|
+
// pageSize
|
|
64
|
+
} = props;
|
|
65
|
+
// const [currentSort] = sortProps;
|
|
66
|
+
|
|
67
|
+
// const talonProps = useCategoryContent({
|
|
68
|
+
// categoryId,
|
|
69
|
+
// data,
|
|
70
|
+
// pageSize
|
|
71
|
+
// });
|
|
72
|
+
|
|
73
|
+
// const {
|
|
74
|
+
// availableSortMethods,
|
|
75
|
+
// categoryName,
|
|
76
|
+
// categoryDescription,
|
|
77
|
+
// filters,
|
|
78
|
+
// items,
|
|
79
|
+
// children,
|
|
80
|
+
// parent,
|
|
81
|
+
// totalCount,
|
|
82
|
+
// totalPagesFromData,
|
|
83
|
+
// attributesBlock,
|
|
84
|
+
// category,
|
|
85
|
+
// virtualCategoryFilters
|
|
86
|
+
// } = talonProps;
|
|
87
|
+
|
|
88
|
+
const [active, setActive] = useState('all');
|
|
89
|
+
|
|
90
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const sortProps = useCustomSort({ sortFromSearch: false, defaultSort: {
|
|
94
|
+
sortText: 'All (A-Z)',
|
|
95
|
+
value: 'all'
|
|
96
|
+
}});
|
|
97
|
+
|
|
98
|
+
const [currentSort] = sortProps;
|
|
99
|
+
|
|
100
|
+
// const [sortBy, setSortBy] = useState({
|
|
101
|
+
// sortText: 'All (A-Z)',
|
|
102
|
+
// value: 'all'
|
|
103
|
+
// });
|
|
104
|
+
|
|
105
|
+
// console.log(currentSort)
|
|
106
|
+
|
|
107
|
+
const classes = useStyle(defaultClasses);
|
|
108
|
+
|
|
109
|
+
const talonProps = useShopBy({ searchQuery, setActive, currentSort, categoryId, shopby });
|
|
110
|
+
|
|
111
|
+
const { error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category } = talonProps;
|
|
112
|
+
|
|
113
|
+
if (loading && !dataResult)
|
|
114
|
+
return <ShopByShimmer />;
|
|
115
|
+
if (error && !dataResult) return <ErrorView />;
|
|
116
|
+
|
|
117
|
+
if (!dataResult && !loading && !error) {
|
|
118
|
+
return <ShopByShimmer />;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const newAvailableGroups = searchQuery ? filteredAvailableGroups : availableGroups;
|
|
122
|
+
|
|
123
|
+
const setRelases = newAvailableGroups.map((group, index) => {
|
|
124
|
+
const optionsResult = [];
|
|
125
|
+
|
|
126
|
+
if (active === 'all' || active === group) {
|
|
127
|
+
dataResult[group].map((option, index) => {
|
|
128
|
+
const { label, value } = option;
|
|
129
|
+
|
|
130
|
+
const categoryUrl = resourceUrl(
|
|
131
|
+
`/${category.url_path}${categoryUrlSuffix || ''}?${attributeData.attribute_code}[filter]=${label},${value}`
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
optionsResult.push(<li className='list-none'>
|
|
135
|
+
<Link to={categoryUrl} className="hover_bg-darkblue-900 hover_text-white w-full block text-[14px] py-[2px] px-2">
|
|
136
|
+
{label}
|
|
137
|
+
</Link>
|
|
138
|
+
</li>)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
{optionsResult ?
|
|
144
|
+
<div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>
|
|
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')}>{optionsResult}</div>
|
|
149
|
+
</div> : ''}
|
|
150
|
+
</>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return null;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const handleActive = (val) => {
|
|
158
|
+
setActive(val);
|
|
159
|
+
|
|
160
|
+
//
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
setSearchQuery('')
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let availableSortBy = [
|
|
167
|
+
{
|
|
168
|
+
'label': 'All (A-Z)',
|
|
169
|
+
'value': 'all'
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<Fragment>
|
|
175
|
+
<StoreTitle>{attributeData ? category.name + ' | ' + attributeData.label : 'Shop By'}</StoreTitle>
|
|
176
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
177
|
+
{attributeData ? category.name + ' | ' + attributeData.label : 'Shop By'}
|
|
178
|
+
</h1>
|
|
179
|
+
<div className='border border-gray-100 px-6'>
|
|
180
|
+
{dataResult ? (
|
|
181
|
+
<div
|
|
182
|
+
className={classes.toolbar}
|
|
183
|
+
>
|
|
184
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={setSearchQuery} /></div>
|
|
185
|
+
<CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} />
|
|
186
|
+
</div>
|
|
187
|
+
) : ''}
|
|
188
|
+
{productType != "expansion-sets" ? (
|
|
189
|
+
<>
|
|
190
|
+
<section className='single_list-indexing-container relative m-auto py-10'>
|
|
191
|
+
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
192
|
+
<li>
|
|
193
|
+
<button
|
|
194
|
+
className={cn(
|
|
195
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
196
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
197
|
+
)}
|
|
198
|
+
onClick={() => {
|
|
199
|
+
handleActive('all')
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
203
|
+
</button>
|
|
204
|
+
</li>
|
|
205
|
+
{alpha.map((letter, index) => (
|
|
206
|
+
<li key={index}>
|
|
207
|
+
<button
|
|
208
|
+
className={cn(
|
|
209
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
210
|
+
'leading-4 font-medium text-base ',
|
|
211
|
+
availableGroups.includes(letter) > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
212
|
+
)}
|
|
213
|
+
onClick={() => {
|
|
214
|
+
handleActive(letter)
|
|
215
|
+
}}
|
|
216
|
+
disabled={availableGroups.includes(letter) > 0 ? false : true}
|
|
217
|
+
>
|
|
218
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
219
|
+
</button>
|
|
220
|
+
</li>
|
|
221
|
+
))}
|
|
222
|
+
</ul>
|
|
223
|
+
</section>
|
|
224
|
+
</>
|
|
225
|
+
) : ''}
|
|
226
|
+
<Divider className="mb-5 px-4 mt-5" />
|
|
227
|
+
<section className='singles-container'>
|
|
228
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
229
|
+
{Object.keys(dataResult).length != 0 ? setRelases : (searchQuery ? <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found for <b>{searchQuery}</b> search query.</div> : <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No data found.</div>)}
|
|
230
|
+
</div>
|
|
231
|
+
</section>
|
|
232
|
+
</div>
|
|
233
|
+
</Fragment>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export default ShopBy;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.toolbar {
|
|
2
|
+
composes: relative from global;
|
|
3
|
+
composes: ml-2xs from global;
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
margin-top: 20px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.tabs {
|
|
10
|
+
composes: flex from global;
|
|
11
|
+
composes: flex-wrap from global;
|
|
12
|
+
composes: mt-3 from global;
|
|
13
|
+
composes: gap-[15px] from global;
|
|
14
|
+
margin-bottom: 30px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tabs_item {
|
|
18
|
+
composes: px-4 from global;
|
|
19
|
+
composes: py-2 from global;
|
|
20
|
+
composes: transition-colors from global;
|
|
21
|
+
composes: duration-150 from global;
|
|
22
|
+
composes: border from global;
|
|
23
|
+
composes: border-solid from global;
|
|
24
|
+
composes: leading-normal from global;
|
|
25
|
+
composes: text-base from global;
|
|
26
|
+
composes: text-colorDefault from global;
|
|
27
|
+
composes: bg-white from global;
|
|
28
|
+
composes: border-gray-100 from global;
|
|
29
|
+
border-radius: 5px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.singlesWrapper {
|
|
33
|
+
column-count: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media screen and (min-width: 768px) {
|
|
37
|
+
.singlesWrapper {
|
|
38
|
+
column-count: 2;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media screen and (min-width: 1023px) {
|
|
43
|
+
.singlesWrapper {
|
|
44
|
+
column-count: 3;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -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 './shopBy';
|
|
7
|
+
import cn from 'classnames';
|
|
8
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
9
|
+
|
|
10
|
+
const ShopBy = 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 py-10'>
|
|
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 ShopBy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './shopByPage';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
// TODO: Read the default/initial sort from config.
|
|
4
|
+
const searchSort = {
|
|
5
|
+
sortText: 'Best Match',
|
|
6
|
+
sortId: 'sortItem.relevance',
|
|
7
|
+
sortAttribute: 'relevance',
|
|
8
|
+
sortDirection: 'DESC'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param props
|
|
14
|
+
* @returns {[{sortDirection: string, sortAttribute: string, sortText: string}, React.Dispatch<React.SetStateAction<{sortDirection: string, sortAttribute: string, sortText: string}>>]}
|
|
15
|
+
*/
|
|
16
|
+
export const useCustomSort = (props = {}) => {
|
|
17
|
+
const { sortFromSearch = false, defaultSort } = props;
|
|
18
|
+
return useState(() =>
|
|
19
|
+
Object.assign({}, sortFromSearch ? searchSort : defaultSort, props)
|
|
20
|
+
);
|
|
21
|
+
};
|
package/src/intercept.js
CHANGED
|
@@ -116,14 +116,7 @@ module.exports = targets => {
|
|
|
116
116
|
pattern: "/brand",
|
|
117
117
|
path: require.resolve("./components/BrandLandingPage/index.js"),
|
|
118
118
|
authed: false,
|
|
119
|
-
}
|
|
120
|
-
{
|
|
121
|
-
exact: true,
|
|
122
|
-
name: "MtgSinglesPage",
|
|
123
|
-
pattern: "/mtg-singles",
|
|
124
|
-
path: require.resolve("./components/MtgSinglesPage/index.js"),
|
|
125
|
-
authed: false,
|
|
126
|
-
},
|
|
119
|
+
}
|
|
127
120
|
];
|
|
128
121
|
|
|
129
122
|
// Apply DefinePlugin using the results of the asynchronous operation
|
|
@@ -44,8 +44,8 @@ export const useFilterSidebar = props => {
|
|
|
44
44
|
const disabled = new Set();
|
|
45
45
|
// Disable category filtering when not on a search page.
|
|
46
46
|
if (pathname !== '/search.html') {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
disabled.add('category_id');
|
|
48
|
+
disabled.add('category_uid');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return disabled;
|
package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryFragments.gql.js
CHANGED
|
@@ -19,6 +19,37 @@ export const ProductsFragment = gql`
|
|
|
19
19
|
seller {
|
|
20
20
|
name
|
|
21
21
|
}
|
|
22
|
+
custom_attributes {
|
|
23
|
+
selected_attribute_options {
|
|
24
|
+
attribute_option {
|
|
25
|
+
uid
|
|
26
|
+
label
|
|
27
|
+
is_default
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
entered_attribute_value {
|
|
31
|
+
value
|
|
32
|
+
}
|
|
33
|
+
attribute_metadata {
|
|
34
|
+
uid
|
|
35
|
+
code
|
|
36
|
+
label
|
|
37
|
+
attribute_labels {
|
|
38
|
+
store_code
|
|
39
|
+
label
|
|
40
|
+
}
|
|
41
|
+
data_type
|
|
42
|
+
is_system
|
|
43
|
+
entity_type
|
|
44
|
+
ui_input {
|
|
45
|
+
ui_input_type
|
|
46
|
+
is_html_allowed
|
|
47
|
+
}
|
|
48
|
+
... on ProductAttributeMetadata {
|
|
49
|
+
used_in_components
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
22
53
|
price_range {
|
|
23
54
|
maximum_price {
|
|
24
55
|
final_price {
|
|
@@ -9,6 +9,7 @@ import { Meta } from '@magento/venia-ui/lib/components/Head';
|
|
|
9
9
|
import { GET_PAGE_SIZE } from './category.gql';
|
|
10
10
|
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
11
11
|
import { useIntl } from 'react-intl';
|
|
12
|
+
import ShopBy from '@riosst100/pwa-marketplace/src/components/ShopBy/shopBy';
|
|
12
13
|
|
|
13
14
|
const MESSAGES = new Map().set(
|
|
14
15
|
'NOT_FOUND',
|
|
@@ -19,6 +20,12 @@ const Category = props => {
|
|
|
19
20
|
const { uid } = props;
|
|
20
21
|
const { formatMessage } = useIntl();
|
|
21
22
|
|
|
23
|
+
const { location } = globalThis;
|
|
24
|
+
|
|
25
|
+
const query = new URLSearchParams(location.search);
|
|
26
|
+
const shopby = query.get('shopby') || null;
|
|
27
|
+
console.log('shopyn: '+shopby)
|
|
28
|
+
|
|
22
29
|
const talonProps = useCategory({
|
|
23
30
|
id: uid,
|
|
24
31
|
queries: {
|
|
@@ -58,11 +65,15 @@ const Category = props => {
|
|
|
58
65
|
/>
|
|
59
66
|
);
|
|
60
67
|
}
|
|
68
|
+
console.log(categoryData)
|
|
61
69
|
|
|
62
70
|
return (
|
|
63
71
|
<Fragment>
|
|
64
72
|
<Meta name="description" content={metaDescription} />
|
|
65
|
-
<
|
|
73
|
+
{shopby ? <ShopBy
|
|
74
|
+
categoryId={uid}
|
|
75
|
+
shopby={shopby}
|
|
76
|
+
isLoading={loading} /> : <CategoryContent
|
|
66
77
|
categoryId={uid}
|
|
67
78
|
classes={classes}
|
|
68
79
|
data={categoryData}
|
|
@@ -70,7 +81,7 @@ const Category = props => {
|
|
|
70
81
|
pageControl={pageControl}
|
|
71
82
|
sortProps={sortProps}
|
|
72
83
|
pageSize={pageSize}
|
|
73
|
-
/>
|
|
84
|
+
/>}
|
|
74
85
|
</Fragment>
|
|
75
86
|
);
|
|
76
87
|
};
|
|
@@ -85,15 +85,35 @@ const CategoryContent = props => {
|
|
|
85
85
|
useMemo(() => {
|
|
86
86
|
items && items.map((item, index) => {
|
|
87
87
|
if (item) {
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
|
|
88
|
+
const { custom_attributes } = item;
|
|
89
|
+
if (custom_attributes) {
|
|
90
|
+
let cardName = '';
|
|
91
|
+
custom_attributes.some((attribute, index) => {
|
|
92
|
+
const { attribute_metadata, entered_attribute_value, selected_attribute_options } = attribute
|
|
93
|
+
if (attribute_metadata.code == "card_name") {
|
|
94
|
+
cardName = selected_attribute_options.attribute_option[0].label;
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return false;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (cardName) {
|
|
103
|
+
const firstLetter = cardName.charAt(0).toUpperCase();
|
|
104
|
+
console.log(firstLetter + " dan " + activeLetter)
|
|
105
|
+
if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
|
|
106
|
+
return galleryItems.push(item);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
110
|
}
|
|
93
111
|
}),
|
|
94
112
|
[items, activeLetter]
|
|
95
113
|
});
|
|
96
114
|
|
|
115
|
+
console.log(galleryItems)
|
|
116
|
+
|
|
97
117
|
const sidebarRef = useRef(null);
|
|
98
118
|
const classes = useStyle(defaultClasses, props.classes);
|
|
99
119
|
const shouldRenderSidebarContent = useIsInViewport({
|
|
@@ -203,6 +223,8 @@ const CategoryContent = props => {
|
|
|
203
223
|
|
|
204
224
|
const activeFilters = [];
|
|
205
225
|
|
|
226
|
+
let isSingles = false;
|
|
227
|
+
|
|
206
228
|
if (allActiveFilters && allActiveFilters.size > 0) {
|
|
207
229
|
allActiveFilters.forEach((value, key) => {
|
|
208
230
|
value.forEach((value) => {
|
|
@@ -210,6 +232,9 @@ const CategoryContent = props => {
|
|
|
210
232
|
|
|
211
233
|
const label = filterArr[0];
|
|
212
234
|
const optionId = filterArr[1];
|
|
235
|
+
if (label == "Singles") {
|
|
236
|
+
isSingles = true;
|
|
237
|
+
}
|
|
213
238
|
if (virtualCategoryFilters && virtualCategoryFilters.includes(key)) {
|
|
214
239
|
activeFilters.push(
|
|
215
240
|
{
|
|
@@ -241,7 +266,7 @@ const CategoryContent = props => {
|
|
|
241
266
|
</div>
|
|
242
267
|
{/* {activeFilters.size <= 0 && category && category.custom_landing_page ? ( */}
|
|
243
268
|
<>
|
|
244
|
-
{currentFilter && <AlphaFilter items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
|
|
269
|
+
{currentFilter && <AlphaFilter isSingles={isSingles} items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
|
|
245
270
|
<SubCategory parent={parent} children={children} />
|
|
246
271
|
{!currentFilter && <CustomSubCategory customSubCategory={category ? category.custom_subcategory : null} />}
|
|
247
272
|
</>
|
|
@@ -256,7 +281,7 @@ const CategoryContent = props => {
|
|
|
256
281
|
<div className={classes.contentWrapper}>
|
|
257
282
|
<div ref={sidebarRef} className={classes.sidebar}>
|
|
258
283
|
<Suspense fallback={<FilterSidebarShimmer />}>
|
|
259
|
-
{shouldRenderSidebarContent ? sidebar : null}
|
|
284
|
+
{shouldRenderSidebarContent && category && !category.hide_filters ? sidebar : null}
|
|
260
285
|
</Suspense>
|
|
261
286
|
</div>
|
|
262
287
|
<div className={classes.categoryContent}>
|
|
@@ -80,9 +80,9 @@ const FilterSidebar = props => {
|
|
|
80
80
|
|
|
81
81
|
const allowedFiltersArr = [];
|
|
82
82
|
|
|
83
|
-
allowedFilters.length && allowedFilters.map((val, index) => {
|
|
84
|
-
|
|
85
|
-
});
|
|
83
|
+
// allowedFilters && allowedFilters.length && allowedFilters.map((val, index) => {
|
|
84
|
+
// allowedFiltersArr.push(val.code);
|
|
85
|
+
// });
|
|
86
86
|
|
|
87
87
|
const filtersList = useMemo(
|
|
88
88
|
() =>
|
|
@@ -90,7 +90,7 @@ const FilterSidebar = props => {
|
|
|
90
90
|
const blockState = filterState.get(group);
|
|
91
91
|
const groupName = filterNames.get(group);
|
|
92
92
|
const frontendInput = filterFrontendInput.get(group);
|
|
93
|
-
if (!allowedFiltersArr.length && group != "category_uid" || allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
|
|
93
|
+
// if (!allowedFilters && !allowedFiltersArr.length && group != "category_uid" || allowedFilters && allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
return (
|
|
@@ -106,7 +106,7 @@ const FilterSidebar = props => {
|
|
|
106
106
|
initialOpen={iteration < filterCountToOpen}
|
|
107
107
|
/>
|
|
108
108
|
);
|
|
109
|
-
}
|
|
109
|
+
// }
|
|
110
110
|
}),
|
|
111
111
|
[
|
|
112
112
|
filterApi,
|
|
@@ -26,9 +26,9 @@ const Gallery = props => {
|
|
|
26
26
|
return <GalleryItemShimmer key={index} />;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const firstLetter = item.name.charAt(0).toUpperCase();
|
|
29
|
+
// const firstLetter = item.name.charAt(0).toUpperCase();
|
|
30
30
|
|
|
31
|
-
if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
|
|
31
|
+
// if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
|
|
32
32
|
return (
|
|
33
33
|
<GalleryItem
|
|
34
34
|
key={item.id}
|
|
@@ -36,7 +36,7 @@ const Gallery = props => {
|
|
|
36
36
|
storeConfig={storeConfig}
|
|
37
37
|
/>
|
|
38
38
|
);
|
|
39
|
-
}
|
|
39
|
+
// }
|
|
40
40
|
}),
|
|
41
41
|
[items, storeConfig, activeLetter]
|
|
42
42
|
);
|