@riosst100/pwa-marketplace 2.1.2 → 2.1.4
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/FavoriteSellerPage/favoriteSeller.js +32 -0
- package/src/components/FavoriteSellerPage/index.js +14 -0
- package/src/components/FavoriteSellerPage/item.js +140 -0
- package/src/components/SetsData/index.js +2 -0
- package/src/components/SetsData/setsData.js +349 -0
- package/src/components/SetsData/setsData.module.css +76 -0
- package/src/components/SetsData/setsData.shimmer.js +50 -0
- package/src/components/ShopBy/shopBy.js +3 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +11 -3
- package/src/talons/Seller/useSeller.js +1 -1
- package/src/talons/SetsData/setsData.gql.js +70 -0
- package/src/talons/SetsData/useSetsData.js +225 -0
- package/src/talons/ShopBy/shopBy.gql.js +12 -6
- package/src/talons/ShopBy/useShopBy.js +13 -4
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import Item from './item';
|
|
5
|
+
|
|
6
|
+
const favoriteSeller = () => {
|
|
7
|
+
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
const PAGE_TITLE = formatMessage({
|
|
10
|
+
id: 'favoriteSellerPage.pageTitleText',
|
|
11
|
+
defaultMessage: 'Favorite Seller'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className='relative'>
|
|
16
|
+
<StoreTitle>{PAGE_TITLE}</StoreTitle>
|
|
17
|
+
<div aria-live="polite" className="text-xl font-medium text-left mb-[30px]">
|
|
18
|
+
{PAGE_TITLE}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div className='flex flex-col gap-5'>
|
|
22
|
+
{
|
|
23
|
+
[...Array(5)].map(() => (
|
|
24
|
+
<Item />
|
|
25
|
+
))
|
|
26
|
+
}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default favoriteSeller
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import FavoriteSeller from './favoriteSeller'
|
|
2
|
+
import AccountLayout from '@riosst100/pwa-marketplace/src/components/AccountLayout';
|
|
3
|
+
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
const index = () => {
|
|
7
|
+
return (
|
|
8
|
+
<AccountLayout>
|
|
9
|
+
<FavoriteSeller />
|
|
10
|
+
</AccountLayout>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default index
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form } from 'informed';
|
|
3
|
+
import Button from '@magento/venia-ui/lib/components/Button';
|
|
4
|
+
import Image from '@magento/venia-ui/lib/components/Image';
|
|
5
|
+
import Verify from '@riosst100/pwa-marketplace/src/components/CrossSeller/verifyIcon';
|
|
6
|
+
import Star from '@riosst100/pwa-marketplace/src/components/CrossSeller/starIcon';
|
|
7
|
+
import logoImage from '@riosst100/pwa-marketplace/src/components/CrossSeller/logo_seller.png';
|
|
8
|
+
import { Share, Trash } from 'iconsax-react';
|
|
9
|
+
import SocialShare from '@riosst100/pwa-marketplace/src/components/SocialMediaShare';
|
|
10
|
+
import { X } from 'react-feather';
|
|
11
|
+
import Modal from '@riosst100/pwa-marketplace/src/components/Modal';
|
|
12
|
+
import cn from 'classnames';
|
|
13
|
+
import { primary900 } from '@riosst100/pwa-marketplace/src/theme/vars';
|
|
14
|
+
import { FormattedMessage } from 'react-intl';
|
|
15
|
+
|
|
16
|
+
const item = () => {
|
|
17
|
+
const [open, setOpen] = React.useState(false);
|
|
18
|
+
|
|
19
|
+
const handleRemoveFromFavorite = () => {
|
|
20
|
+
alert('remove fav seller')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleGoToSellerPage = () => {
|
|
24
|
+
alert('to seller page')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Modal
|
|
30
|
+
open={open}
|
|
31
|
+
setOpen={setOpen}
|
|
32
|
+
className={cn(
|
|
33
|
+
'max-w-max !min-h-auto px-[30px] pt-[30px] pb-10',
|
|
34
|
+
)}
|
|
35
|
+
>
|
|
36
|
+
<div className='social_share-container flex flex-col gap-y-7'>
|
|
37
|
+
<div className='flex justify-between'>
|
|
38
|
+
<div className='text-lg font-medium'>
|
|
39
|
+
Share to your friends
|
|
40
|
+
</div>
|
|
41
|
+
<button onClick={() => { setOpen(!open) }} >
|
|
42
|
+
<X size={24} color={primary900} />
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
<div className='flex flex-row border border-gray-100 rounded-md px-5 py-2.5 gap-x-2.5 items-center'>
|
|
46
|
+
<div className='flex flex-col'>
|
|
47
|
+
<div className='text-[14px] font-normal'>
|
|
48
|
+
Zen Market.TCG
|
|
49
|
+
</div>
|
|
50
|
+
<div className='text-[12px] font-normal text-gray-200'>
|
|
51
|
+
zenmarket-tcg.link
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<SocialShare rootClassName="justify-center" />
|
|
56
|
+
</div>
|
|
57
|
+
</Modal>
|
|
58
|
+
<div className='border border-gray-100 rounded-md p-5 flex flex-col md_flex-row justify-between gap-y-4'>
|
|
59
|
+
<div className='seller_info-container flex flex-row gap-x-[15px]'>
|
|
60
|
+
<div className='logo_wrapper w-[100px] h-[100px]'>
|
|
61
|
+
<Image
|
|
62
|
+
alt='seller name'
|
|
63
|
+
className="relative mt-[-5px]"
|
|
64
|
+
src={logoImage}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<div className='flex flex-col gap-y-[15px]'>
|
|
68
|
+
<div className='flex flex-col gap-[6px]'>
|
|
69
|
+
<div className='seller_summary-wrapper flex flex-row gap-x-2.5 items-center'>
|
|
70
|
+
<div className='seller_name text-lg font-medium leading-6'>
|
|
71
|
+
Zen Market
|
|
72
|
+
</div>
|
|
73
|
+
<div className='seller_badge flex flex-row gap-x-[5px] items-center leading-6'>
|
|
74
|
+
<Verify />
|
|
75
|
+
<span className='text-xs font-medium text-gray-600-transparent capitalize'>
|
|
76
|
+
Verified
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
<div className='flex flex-row gap-x-[5px] items-center'>
|
|
81
|
+
<span className='font-normal text-[12px] text-gray-200 '>
|
|
82
|
+
Jurong West
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
<div className='flex gap-4'>
|
|
87
|
+
<Button
|
|
88
|
+
classes={{
|
|
89
|
+
content: 'gap-1.5 grid-flow-col inline-grid items-center justify-center justify-items-center capitalize font-medium text-[14px]',
|
|
90
|
+
rootClass: 'py-[0px] h-9 hover_border-blue-700'
|
|
91
|
+
}}
|
|
92
|
+
onClick={handleGoToSellerPage}
|
|
93
|
+
>
|
|
94
|
+
<FormattedMessage
|
|
95
|
+
id={'favoriteSeller.visitStore'}
|
|
96
|
+
defaultMessage={'Visit Store'}
|
|
97
|
+
/>
|
|
98
|
+
</Button>
|
|
99
|
+
<div
|
|
100
|
+
className='flex items-center justify-center gap-[5px] p-[9px] relative rounded-[30px] overflow-hidden border border-solid border-blue-600 hover_border-blue-700 cursor-pointer w-9 h-9'
|
|
101
|
+
onClick={() => { setOpen(!open) }}
|
|
102
|
+
>
|
|
103
|
+
<Share
|
|
104
|
+
size="15"
|
|
105
|
+
className='text-blue-600 group-hover_text-blue-800 left-[-1px]'
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<div className='flex flex-row justify-between md_justify-center items-center gap-5'>
|
|
112
|
+
<div className='flex flex-col gap-y-2'>
|
|
113
|
+
<div className='rating_sales flex flex-row gap-x-[5px] items-center'>
|
|
114
|
+
<Star width={18} height={18} />
|
|
115
|
+
<p className='font-medium text-[18px] text-gray-600'>
|
|
116
|
+
4.7
|
|
117
|
+
</p>
|
|
118
|
+
</div>
|
|
119
|
+
<span className='text-gray-800 text-xs'>
|
|
120
|
+
<FormattedMessage
|
|
121
|
+
id={'favoriteSeller.RatingAndReviews'}
|
|
122
|
+
defaultMessage={'Rating & Reviews'}
|
|
123
|
+
/>
|
|
124
|
+
</span>
|
|
125
|
+
|
|
126
|
+
</div>
|
|
127
|
+
<Button
|
|
128
|
+
data-cy="Product-Section-removeFavorite"
|
|
129
|
+
onClick={handleRemoveFromFavorite}
|
|
130
|
+
className="min-w-min border border-gray-200 rounded-full border-solid w-7 h-7 flex items-center justify-center hover_border-gray-600"
|
|
131
|
+
>
|
|
132
|
+
<Trash size="16" color="#999999" />
|
|
133
|
+
</Button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default item
|
|
@@ -0,0 +1,349 @@
|
|
|
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 { useSetsData } from '@riosst100/pwa-marketplace/src/talons/SetsData/useSetsData';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import defaultClasses from './setsData.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 { SetsDataShimmer } from '@riosst100/pwa-marketplace/src/components/SetsData';
|
|
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 SetsData = 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 = useSetsData({ activeFilter, searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab });
|
|
73
|
+
|
|
74
|
+
const { error, loading, setsData, categoryUrlSuffix, categoryUrlKey, productType, filteredSetsData, availableGroups, category, attributeData, pageInfo } = talonProps;
|
|
75
|
+
|
|
76
|
+
if (loading && !setsData)
|
|
77
|
+
return <SetsDataShimmer />;
|
|
78
|
+
if (error && !setsData) return <ErrorView />;
|
|
79
|
+
|
|
80
|
+
if (!setsData && !loading && !error) {
|
|
81
|
+
return <SetsDataShimmer />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const setsLengthArr = [];
|
|
85
|
+
|
|
86
|
+
const newSetsData = searchQuery ? filteredSetsData : setsData;
|
|
87
|
+
|
|
88
|
+
// useEffect(() => {
|
|
89
|
+
if (setsData && setsData.length) {
|
|
90
|
+
setsData.map((setRelease, index) => {
|
|
91
|
+
const { group, sets } = setRelease;
|
|
92
|
+
|
|
93
|
+
setsLengthArr[group] = sets.length
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
// }, [setsData])
|
|
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 = attributeData ? attributeData.attribute_code : '';
|
|
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 = newSetsData && newSetsData.length && newSetsData.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 || newSetsData.length == 1) {
|
|
138
|
+
setsResultSplitted = splitToNChunks(setsResult, 3);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
{active == "all" && newSetsData.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-medium 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 || newSetsData.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-medium border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
153
|
+
<div className='singles_item_group_letter text-xl font-medium 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 = pageInfo ? pageInfo.title : 'All 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
|
+
{!pageInfo.hide_title && <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
|
+
{pageInfo.filter_group && <ul className={classes.nav}>
|
|
274
|
+
{availableGroups.map((group, index) => (
|
|
275
|
+
<li key={index} className={classes.nav_item}>
|
|
276
|
+
<button
|
|
277
|
+
onClick={() => {
|
|
278
|
+
handleActive(group)
|
|
279
|
+
}}
|
|
280
|
+
>
|
|
281
|
+
{active == group ? <b>{group}</b> : group}
|
|
282
|
+
</button>
|
|
283
|
+
</li>
|
|
284
|
+
))}
|
|
285
|
+
<li className={classes.nav_item}>
|
|
286
|
+
<button
|
|
287
|
+
onClick={() => {
|
|
288
|
+
handleActive('all')
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
292
|
+
</button>
|
|
293
|
+
</li>
|
|
294
|
+
</ul>}
|
|
295
|
+
<div className='border border-gray-100 px-6'>
|
|
296
|
+
{setsData ? (
|
|
297
|
+
<div
|
|
298
|
+
className={classes.toolbar}
|
|
299
|
+
>
|
|
300
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={handleSearchQuery} /></div>
|
|
301
|
+
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
302
|
+
</div>
|
|
303
|
+
) : ''}
|
|
304
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
305
|
+
{!activeFilter && activeTab != "year" && <ul className='flex gap-2 justify-center flex-wrap'>
|
|
306
|
+
<li>
|
|
307
|
+
<button
|
|
308
|
+
className={cn(
|
|
309
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
310
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
311
|
+
)}
|
|
312
|
+
onClick={() => {
|
|
313
|
+
handleActive('all')
|
|
314
|
+
}}
|
|
315
|
+
>
|
|
316
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
317
|
+
</button>
|
|
318
|
+
</li>
|
|
319
|
+
{alpha.map((letter, index) => (
|
|
320
|
+
<li key={index}>
|
|
321
|
+
<button
|
|
322
|
+
className={cn(
|
|
323
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
324
|
+
'leading-4 font-medium text-base ',
|
|
325
|
+
setsLengthArr[letter] > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
326
|
+
)}
|
|
327
|
+
onClick={() => {
|
|
328
|
+
handleActive(letter)
|
|
329
|
+
}}
|
|
330
|
+
disabled={setsLengthArr[letter] > 0 ? false : true}
|
|
331
|
+
>
|
|
332
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
333
|
+
</button>
|
|
334
|
+
</li>
|
|
335
|
+
))}
|
|
336
|
+
</ul>}
|
|
337
|
+
</section>
|
|
338
|
+
<Divider className="mb-5 px-4 mt-5" />
|
|
339
|
+
<section className='singles-container'>
|
|
340
|
+
<div className={cn('singles-wrapper block -mx-4', classes.singlesWrapper)}>
|
|
341
|
+
{newSetsData && newSetsData.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>)}
|
|
342
|
+
</div>
|
|
343
|
+
</section>
|
|
344
|
+
</div>
|
|
345
|
+
</Fragment>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export default SetsData;
|
|
@@ -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 './setsData.module.css';
|
|
7
|
+
import cn from 'classnames';
|
|
8
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
9
|
+
|
|
10
|
+
const SetsData = 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-medium 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-medium 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-medium 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-medium 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-medium 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-medium 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 SetsData;
|
|
@@ -110,7 +110,7 @@ const ShopBy = props => {
|
|
|
110
110
|
|
|
111
111
|
const talonProps = useShopBy({ activeFilter, searchQuery, active, setActive, currentSort, categoryId, shopby });
|
|
112
112
|
|
|
113
|
-
const { error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category, activeFilters } = talonProps;
|
|
113
|
+
const { error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category, activeFilters, pageInfo } = talonProps;
|
|
114
114
|
|
|
115
115
|
if (loading && !dataResult)
|
|
116
116
|
return <ShopByShimmer />;
|
|
@@ -233,7 +233,8 @@ const ShopBy = props => {
|
|
|
233
233
|
}
|
|
234
234
|
];
|
|
235
235
|
|
|
236
|
-
const title = attributeData ? (attributeData.attribute_code == "sc_baseball_parallel" ? "Parallel Sets" : (attributeData.attribute_code == "sc_baseball_inserts" ? "Insert Sets" : attributeData.label)) : "Shop By"
|
|
236
|
+
// const title = attributeData ? (attributeData.attribute_code == "sc_baseball_parallel" ? "Parallel Sets" : (attributeData.attribute_code == "sc_baseball_inserts" ? "Insert Sets" : attributeData.label)) : "Shop By"
|
|
237
|
+
const title = pageInfo ? pageInfo.title : '';
|
|
237
238
|
|
|
238
239
|
let availableFilterOption = [];
|
|
239
240
|
|
|
@@ -18,7 +18,7 @@ import SportCardsSets from '@riosst100/pwa-marketplace/src/components/SportCards
|
|
|
18
18
|
import NonSportCardsSets from '@riosst100/pwa-marketplace/src/components/NonSportCardsSets/nonSportCardsSets';
|
|
19
19
|
import LegoSets from '@riosst100/pwa-marketplace/src/components/LegoSets/legoSets';
|
|
20
20
|
import TrainsSets from '@riosst100/pwa-marketplace/src/components/TrainsSets/trainsSets';
|
|
21
|
-
import
|
|
21
|
+
import SetsData from '@riosst100/pwa-marketplace/src/components/SetsData/setsData';
|
|
22
22
|
|
|
23
23
|
const MESSAGES = new Map().set(
|
|
24
24
|
'NOT_FOUND',
|
|
@@ -81,6 +81,8 @@ const Category = props => {
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
const allowedShopby = ['card_artist'];
|
|
85
|
+
|
|
84
86
|
return (
|
|
85
87
|
<Fragment>
|
|
86
88
|
<Meta name="description" content={metaDescription} />
|
|
@@ -89,7 +91,13 @@ const Category = props => {
|
|
|
89
91
|
categoryId={uid}
|
|
90
92
|
isLoading={loading} />
|
|
91
93
|
) : (
|
|
92
|
-
shopby
|
|
94
|
+
allowedShopby.includes(shopby) ? <ShopBy
|
|
95
|
+
categoryId={uid}
|
|
96
|
+
shopby={shopby}
|
|
97
|
+
isLoading={loading} /> : shopby == "release_year" || shopby == "expansion_sets" || shopby == "sets" ? <SetsData
|
|
98
|
+
categoryId={uid}
|
|
99
|
+
shopby={shopby}
|
|
100
|
+
isLoading={loading} /> : shopby == "singles" || shopby == "lego_set_name" && parentCategoryUrlKey == "lego" ? <LegoSets
|
|
93
101
|
categoryId={uid}
|
|
94
102
|
shopby={shopby}
|
|
95
103
|
isLoading={loading} /> : shopby && parentCategoryUrlKey == "non-sports-cards" ? <NonSportCardsSets
|
|
@@ -98,7 +106,7 @@ const Category = props => {
|
|
|
98
106
|
isLoading={loading} /> : shopby == "sc_baseball_players" || shopby == "sc_baseball_teams" || shopby == "release" && parentCategoryUrlKey == "sport-cards" ? <SportCardsSets
|
|
99
107
|
categoryId={uid}
|
|
100
108
|
shopby={shopby}
|
|
101
|
-
isLoading={loading} /> : shopby == "
|
|
109
|
+
isLoading={loading} /> : shopby == "release_year" ? <ShopBySets
|
|
102
110
|
categoryId={uid}
|
|
103
111
|
shopby={shopby}
|
|
104
112
|
isLoading={loading} /> : shopby == "card" ? <ShopByCard
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const GET_STORE_CONFIG_DATA = gql`
|
|
4
|
+
query getStoreConfigData {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
|
+
storeConfig {
|
|
7
|
+
store_code
|
|
8
|
+
product_url_suffix
|
|
9
|
+
category_url_suffix
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const GET_SETS_DATA_QUERY = gql`
|
|
15
|
+
query getSetsData($categoryUrlKey: String!, $activeTab: String, $filters: ProductAttributeFilterInput!, $shopby: String, $activeFilter: String) {
|
|
16
|
+
getSetsData(categoryUrlKey: $categoryUrlKey, activeTab: $activeTab, filters: $filters, shopby: $shopby, activeFilter: $activeFilter) {
|
|
17
|
+
attribute {
|
|
18
|
+
attribute_code
|
|
19
|
+
label
|
|
20
|
+
}
|
|
21
|
+
page_info {
|
|
22
|
+
title
|
|
23
|
+
hide_title
|
|
24
|
+
filter_group
|
|
25
|
+
}
|
|
26
|
+
data {
|
|
27
|
+
group
|
|
28
|
+
sets {
|
|
29
|
+
set_name
|
|
30
|
+
option_id
|
|
31
|
+
release_year
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export const GET_CATEGORY_CONTENT = gql`
|
|
39
|
+
query getCategoryData($id: String!) {
|
|
40
|
+
categories(filters: { category_uid: { in: [$id] } }) {
|
|
41
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
42
|
+
items {
|
|
43
|
+
uid
|
|
44
|
+
name
|
|
45
|
+
url_key
|
|
46
|
+
url_path
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export const GET_FILTER_INPUTS = gql`
|
|
53
|
+
query GetFilterInputsForCategory {
|
|
54
|
+
__type(name: "ProductAttributeFilterInput") {
|
|
55
|
+
inputFields {
|
|
56
|
+
name
|
|
57
|
+
type {
|
|
58
|
+
name
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
getStoreConfigData: GET_STORE_CONFIG_DATA,
|
|
67
|
+
getSetsDataQuery: GET_SETS_DATA_QUERY,
|
|
68
|
+
getCategoryContentQuery: GET_CATEGORY_CONTENT,
|
|
69
|
+
getFilterInputsQuery: GET_FILTER_INPUTS,
|
|
70
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
6
|
+
import DEFAULT_OPERATIONS from './setsData.gql';
|
|
7
|
+
import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
8
|
+
|
|
9
|
+
export const useSetsData = props => {
|
|
10
|
+
|
|
11
|
+
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter } = props
|
|
12
|
+
|
|
13
|
+
const { value: sortby } = currentSort
|
|
14
|
+
|
|
15
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, null);
|
|
16
|
+
const { getStoreConfigData, getSetsDataQuery, getCategoryContentQuery, getFilterInputsQuery } = operations;
|
|
17
|
+
const { pathname, search } = useLocation();
|
|
18
|
+
const [runQuery, queryResponse] = useLazyQuery(getSetsDataQuery, {
|
|
19
|
+
fetchPolicy: 'cache-and-network',
|
|
20
|
+
nextFetchPolicy: 'cache-first'
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const pathnameArr = pathname.split('/');
|
|
24
|
+
|
|
25
|
+
const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
|
|
26
|
+
const parentCategoryUrlKey = pathnameArr[pathnameArr.length - 2].replace('.html','');
|
|
27
|
+
const productType = shopby;
|
|
28
|
+
|
|
29
|
+
const { data: introspectionData } = useQuery(getFilterInputsQuery);
|
|
30
|
+
|
|
31
|
+
const filterTypeMap = useMemo(() => {
|
|
32
|
+
const typeMap = new Map();
|
|
33
|
+
if (introspectionData) {
|
|
34
|
+
introspectionData.__type.inputFields.forEach(({ name, type }) => {
|
|
35
|
+
typeMap.set(name, type.name);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return typeMap;
|
|
39
|
+
}, [introspectionData]);
|
|
40
|
+
const filters = getFiltersFromSearch(search);
|
|
41
|
+
|
|
42
|
+
// console.log(search)
|
|
43
|
+
|
|
44
|
+
// Construct the filter arg object.
|
|
45
|
+
const newFilters = {};
|
|
46
|
+
filters.forEach((values, key) => {
|
|
47
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
48
|
+
// console.log(key)
|
|
49
|
+
// console.log(values)
|
|
50
|
+
|
|
51
|
+
if (key == "sc_baseball_release") {
|
|
52
|
+
for(let item of values) {
|
|
53
|
+
if(item) {
|
|
54
|
+
// console.log(item.split(',')[0])
|
|
55
|
+
const data = search.split('&');
|
|
56
|
+
data.pop();
|
|
57
|
+
activeFilters.push(
|
|
58
|
+
{
|
|
59
|
+
'label': item.split(',')[0],
|
|
60
|
+
'path': data
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
// console.log("MASUK")
|
|
70
|
+
|
|
71
|
+
// if (queryResponse.data) {
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// Use the category uid for the current category page regardless of the
|
|
76
|
+
// applied filters. Follow-up in PWA-404.
|
|
77
|
+
// newFilters['category_uid'] = { eq: id };
|
|
78
|
+
|
|
79
|
+
runQuery({
|
|
80
|
+
variables: {
|
|
81
|
+
filters: newFilters,
|
|
82
|
+
categoryUrlKey: pathname,
|
|
83
|
+
activeTab: activeTab,
|
|
84
|
+
shopby: shopby,
|
|
85
|
+
activeFilter: activeFilter
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
// }
|
|
89
|
+
}, [
|
|
90
|
+
runQuery,
|
|
91
|
+
activeTab,
|
|
92
|
+
activeFilter
|
|
93
|
+
// queryResponse
|
|
94
|
+
// filterTypeMap,
|
|
95
|
+
// search,
|
|
96
|
+
// newFilters,
|
|
97
|
+
// shopby,
|
|
98
|
+
// categoryUrlKey
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
const { data: storeConfigData } = useQuery(getStoreConfigData, {
|
|
102
|
+
fetchPolicy: 'cache-and-network',
|
|
103
|
+
nextFetchPolicy: 'cache-first'
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
|
|
107
|
+
|
|
108
|
+
// { data: queryResponse, error, loading }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
// console.log(data)
|
|
113
|
+
|
|
114
|
+
// const isBackgroundLoading = !!data && loading;
|
|
115
|
+
|
|
116
|
+
const availableLeagues = [];
|
|
117
|
+
|
|
118
|
+
// console.log(queryResponse.data)
|
|
119
|
+
|
|
120
|
+
const setsData = useMemo(() => {
|
|
121
|
+
if (!queryResponse) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// console.log(data)
|
|
126
|
+
|
|
127
|
+
const setsData = queryResponse?.data?.getSetsData?.data;
|
|
128
|
+
if (!setsData) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// return setsData.slice().sort((a, b) =>a.group.toLowerCase().localeCompare(b.group.toLowerCase()));
|
|
133
|
+
return setsData;
|
|
134
|
+
}, [queryResponse]);
|
|
135
|
+
|
|
136
|
+
const availableGroups = setsData && setsData.length ? setsData.map(({ group }) => group) : [];
|
|
137
|
+
|
|
138
|
+
// const availableLeagues = setsData && setsData.length ? setsData.map(({ sets }) => setsData.map(({ sc_league }) => sc_league)) : [];
|
|
139
|
+
// console.log(availableLeagues)
|
|
140
|
+
// sc_league
|
|
141
|
+
const attributeData = useMemo(() => {
|
|
142
|
+
if (!queryResponse) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return queryResponse?.data?.getSetsData?.attribute;
|
|
147
|
+
}, [queryResponse]);
|
|
148
|
+
|
|
149
|
+
const pageInfo = useMemo(() => {
|
|
150
|
+
if (!queryResponse) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return queryResponse?.data?.getSetsData?.page_info;
|
|
155
|
+
}, [queryResponse]);
|
|
156
|
+
|
|
157
|
+
const filteredSetsData = useMemo(() => {
|
|
158
|
+
if (!setsData) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const filteredSets = [];
|
|
163
|
+
|
|
164
|
+
if (searchQuery) {
|
|
165
|
+
|
|
166
|
+
// useEffect(() => {
|
|
167
|
+
// setActive('all')
|
|
168
|
+
// }, [active]);
|
|
169
|
+
|
|
170
|
+
setsData.map(({ group, sets }, index) => {
|
|
171
|
+
const newSets = sets.filter(function(set) {
|
|
172
|
+
return set.set_name.search(new RegExp(searchQuery, "i")) != -1 || group.search(new RegExp(searchQuery, "i")) != -1;
|
|
173
|
+
// return set.set_name.includes(searchQuery);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (newSets && newSets.length) {
|
|
177
|
+
filteredSets.push({
|
|
178
|
+
'group': group,
|
|
179
|
+
'sets': newSets
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return searchQuery ? filteredSets : setsData;
|
|
186
|
+
}, [setsData, searchQuery]);
|
|
187
|
+
|
|
188
|
+
// useEffect(() => {
|
|
189
|
+
// setPageLoading(isBackgroundLoading);
|
|
190
|
+
// }, [isBackgroundLoading, setPageLoading]);
|
|
191
|
+
|
|
192
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
193
|
+
getCategoryContentQuery,
|
|
194
|
+
{
|
|
195
|
+
fetchPolicy: 'cache-and-network',
|
|
196
|
+
nextFetchPolicy: 'cache-first',
|
|
197
|
+
skip: !categoryId,
|
|
198
|
+
variables: {
|
|
199
|
+
id: categoryId
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const category =
|
|
205
|
+
categoryData && categoryData.categories.items.length
|
|
206
|
+
? categoryData.categories.items[0]
|
|
207
|
+
: null;
|
|
208
|
+
|
|
209
|
+
const error = queryResponse?.error;
|
|
210
|
+
const loading = queryResponse?.loading;
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
error,
|
|
214
|
+
loading,
|
|
215
|
+
setsData,
|
|
216
|
+
filteredSetsData,
|
|
217
|
+
categoryUrlSuffix,
|
|
218
|
+
categoryUrlKey,
|
|
219
|
+
productType,
|
|
220
|
+
availableGroups,
|
|
221
|
+
category,
|
|
222
|
+
attributeData,
|
|
223
|
+
pageInfo
|
|
224
|
+
};
|
|
225
|
+
};
|
|
@@ -14,14 +14,20 @@ export const GET_STORE_CONFIG_DATA = gql`
|
|
|
14
14
|
export const GET_SHOP_BY_DATA_QUERY = gql`
|
|
15
15
|
query getShopByData($search: String, $activeFilter: String, $categoryUrlKey: String!, $attributeCode: String, $filters: ProductAttributeFilterInput!) {
|
|
16
16
|
shopByData(search: $search, activeFilter: $activeFilter, categoryUrlKey: $categoryUrlKey, attributeCode: $attributeCode, filters: $filters) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
page_info {
|
|
18
|
+
title
|
|
19
|
+
filter_group
|
|
20
|
+
}
|
|
21
|
+
data {
|
|
21
22
|
label
|
|
22
|
-
|
|
23
|
+
count
|
|
24
|
+
attribute_code
|
|
25
|
+
options {
|
|
26
|
+
label
|
|
27
|
+
value
|
|
28
|
+
}
|
|
29
|
+
position
|
|
23
30
|
}
|
|
24
|
-
position
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
`;
|
|
@@ -130,7 +130,7 @@ export const useShopBy = props => {
|
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
const rawData = queryResponse?.data?.shopByData;
|
|
133
|
+
const rawData = queryResponse?.data?.shopByData?.data;
|
|
134
134
|
if (!rawData) {
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
@@ -160,7 +160,7 @@ export const useShopBy = props => {
|
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
const rawData = queryResponse?.data?.shopByData;
|
|
163
|
+
const rawData = queryResponse?.data?.shopByData?.data;
|
|
164
164
|
if (!rawData) {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
@@ -227,7 +227,7 @@ export const useShopBy = props => {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
const attributeData = queryResponse?.data?.shopByData && queryResponse?.data?.shopByData.length ? queryResponse.data.shopByData[0] : null
|
|
230
|
+
const attributeData = queryResponse?.data?.shopByData?.data && queryResponse?.data?.shopByData.data.length ? queryResponse.data.shopByData.data[0] : null
|
|
231
231
|
|
|
232
232
|
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
233
233
|
getCategoryContentQuery,
|
|
@@ -241,6 +241,14 @@ export const useShopBy = props => {
|
|
|
241
241
|
}
|
|
242
242
|
);
|
|
243
243
|
|
|
244
|
+
const pageInfo = useMemo(() => {
|
|
245
|
+
if (!queryResponse) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return queryResponse?.data?.shopByData?.page_info;
|
|
250
|
+
}, [queryResponse]);
|
|
251
|
+
|
|
244
252
|
const category =
|
|
245
253
|
categoryData && categoryData.categories.items.length
|
|
246
254
|
? categoryData.categories.items[0]
|
|
@@ -258,7 +266,8 @@ export const useShopBy = props => {
|
|
|
258
266
|
attributeData,
|
|
259
267
|
alpha,
|
|
260
268
|
category,
|
|
261
|
-
activeFilters
|
|
269
|
+
activeFilters,
|
|
270
|
+
pageInfo
|
|
262
271
|
// productType
|
|
263
272
|
};
|
|
264
273
|
};
|