@riosst100/pwa-marketplace 2.5.8 → 2.6.0
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/FilterContent/filterContent.js +376 -0
- package/src/components/FilterContent/filterContent.module.css +76 -0
- package/src/components/FilterContent/filterDefault.js +84 -0
- package/src/components/FilterContent/filterDefault.module.css +0 -0
- package/src/components/FilterContent/filterItem.js +80 -0
- package/src/components/FilterContent/index.js +1 -0
- package/src/components/FilterListContent/filterListPage.js +414 -0
- package/src/components/FilterListContent/index.js +1 -0
- package/src/components/FilterListPage/index.js +1 -0
- package/src/components/FilterTop/filterTop.js +3 -3
- package/src/components/Seller/seller.js +0 -6
- package/src/components/SetsData/setsData.js +1 -1
- package/src/overwrites/peregrine/lib/store/actions/cart/asyncActions.js +0 -21
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +4 -14
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +2 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +14 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +2 -6
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +0 -9
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentMethods.js +0 -9
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.js +12 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.module.css +4 -3
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +5 -4
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.module.css +7 -4
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +13 -3
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +3 -6
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/OrderDetails/item.js +0 -1
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/OrderDetails/orderDetails.js +0 -1
- package/src/talons/FilterContent/useFilterContent.js +291 -0
- package/src/talons/FilterTop/useFilterTop.js +0 -2
- package/src/talons/SellerProducts/productContent.gql.js +1 -0
- package/src/talons/SellerProducts/useSellerProducts.js +0 -2
- package/src/talons/ShopBy/useShopBy.js +17 -25
package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentMethods.js
CHANGED
|
@@ -37,12 +37,6 @@ const PaymentMethods = props => {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
console.log('payments')
|
|
41
|
-
console.log(payments)
|
|
42
|
-
|
|
43
|
-
console.log('availablePaymentMethods')
|
|
44
|
-
console.log(availablePaymentMethods)
|
|
45
|
-
|
|
46
40
|
const radios = availablePaymentMethods
|
|
47
41
|
.map(({ code, title }) => {
|
|
48
42
|
// If we don't have an implementation for a method type, ignore it.
|
|
@@ -80,9 +74,6 @@ const PaymentMethods = props => {
|
|
|
80
74
|
})
|
|
81
75
|
.filter(paymentMethod => !!paymentMethod);
|
|
82
76
|
|
|
83
|
-
console.log('radios != [] harusny')
|
|
84
|
-
console.log(radios)
|
|
85
|
-
|
|
86
77
|
const noPaymentMethodMessage = !radios.length ? (
|
|
87
78
|
<div className={classes.payment_errors}>
|
|
88
79
|
<span>
|
|
@@ -9,7 +9,7 @@ import Trigger from '@magento/venia-ui/lib/components/Trigger';
|
|
|
9
9
|
import defaultClasses from './currentFilter.module.css';
|
|
10
10
|
|
|
11
11
|
const CurrentFilter = props => {
|
|
12
|
-
const { group, item, removeItem, onRemove } = props;
|
|
12
|
+
const { group, item, removeItem, onRemove, filterNames } = props;
|
|
13
13
|
const classes = useStyle(defaultClasses, props.classes);
|
|
14
14
|
const { formatMessage } = useIntl();
|
|
15
15
|
|
|
@@ -30,17 +30,27 @@ const CurrentFilter = props => {
|
|
|
30
30
|
}
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
+
const groupName = filterNames.get(group);
|
|
34
|
+
|
|
33
35
|
return (
|
|
34
36
|
<span className={classes.root} data-cy="CurrentFilter-root">
|
|
35
37
|
<Trigger
|
|
36
38
|
action={handleClick}
|
|
39
|
+
style={{
|
|
40
|
+
"width":"30px"
|
|
41
|
+
}}
|
|
37
42
|
aria-label={ariaLabel}
|
|
38
43
|
data-cy="CurrentFilter-trigger"
|
|
39
44
|
>
|
|
40
45
|
<Icon size={14} src={Remove} />
|
|
41
46
|
</Trigger>
|
|
42
47
|
<span className={classes.text}>
|
|
43
|
-
{
|
|
48
|
+
<div style={{
|
|
49
|
+
"fontSize": "10px",
|
|
50
|
+
"color": "grey",
|
|
51
|
+
"fontWeight": "normal"
|
|
52
|
+
}}>{groupName}</div>
|
|
53
|
+
<div>{item.label ? item.label : item.title}</div>
|
|
44
54
|
</span>
|
|
45
55
|
</span>
|
|
46
56
|
);
|
package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.module.css
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
composes: font-medium from global;
|
|
6
6
|
composes: gap-2xs from global;
|
|
7
7
|
composes: grid-flow-col from global;
|
|
8
|
-
composes: inline-
|
|
8
|
+
composes: inline-flex from global;
|
|
9
9
|
composes: items-center from global;
|
|
10
|
-
composes: justify-
|
|
11
|
-
composes: px-
|
|
10
|
+
composes: justify-left from global;
|
|
11
|
+
composes: px-1 from global;
|
|
12
12
|
composes: py-1 from global;
|
|
13
13
|
composes: rounded-md from global;
|
|
14
14
|
/* composes: text-white from global; */
|
|
15
15
|
composes: text-base from global;
|
|
16
|
+
composes: w-full from global;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/* TODO @TW: cannot compose */
|
|
@@ -7,7 +7,7 @@ import CurrentFilter from './currentFilter';
|
|
|
7
7
|
import defaultClasses from './currentFilters.module.css';
|
|
8
8
|
|
|
9
9
|
const CurrentFilters = props => {
|
|
10
|
-
const { filterApi, filterState, onRemove } = props;
|
|
10
|
+
const { filterApi, filterState, onRemove, filterNames } = props;
|
|
11
11
|
const { removeItem } = filterApi;
|
|
12
12
|
const classes = useStyle(defaultClasses, props.classes);
|
|
13
13
|
const { formatMessage } = useIntl();
|
|
@@ -20,20 +20,21 @@ const CurrentFilters = props => {
|
|
|
20
20
|
const { title, value } = item || {};
|
|
21
21
|
const key = `${group}::${title}_${value}`;
|
|
22
22
|
|
|
23
|
-
const customAttributeLandingPage = ['bricks_categories','sc_sports_categories','card_game',
|
|
23
|
+
const customAttributeLandingPage = ['bricks_categories','sc_sports_categories','card_game', 'sc_baseball_release','auction','special_price','lof_preorder','sc_baseball_inserts','sc_baseball_parallel','sc_set_type'];
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
if (!customAttributeLandingPage.includes(group)) {
|
|
26
26
|
elements.push(
|
|
27
27
|
<li key={key} className={classes.item}>
|
|
28
28
|
<CurrentFilter
|
|
29
29
|
group={group}
|
|
30
|
+
filterNames={filterNames}
|
|
30
31
|
item={item}
|
|
31
32
|
removeItem={removeItem}
|
|
32
33
|
onRemove={onRemove}
|
|
33
34
|
/>
|
|
34
35
|
</li>
|
|
35
36
|
);
|
|
36
|
-
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.module.css
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
composes: overflow-auto from global;
|
|
5
5
|
composes: flex from global;
|
|
6
6
|
composes: flex-wrap from global;
|
|
7
|
-
composes: gap-
|
|
7
|
+
composes: gap-0 from global;
|
|
8
|
+
composes: flex-col from global;
|
|
9
|
+
composes: items-start from global;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
/* TODO @TW: cannot compose */
|
|
@@ -14,8 +16,9 @@
|
|
|
14
16
|
|
|
15
17
|
.item {
|
|
16
18
|
composes: float-left from global;
|
|
17
|
-
composes:
|
|
19
|
+
composes: pt-0 from global;
|
|
18
20
|
composes: pl-0 from global;
|
|
19
|
-
composes: pr-2 from global;
|
|
20
|
-
composes:
|
|
21
|
+
/* composes: pr-2 from global; */
|
|
22
|
+
composes: pb-2 from global;
|
|
23
|
+
composes: w-full from global;
|
|
21
24
|
}
|
|
@@ -9,6 +9,7 @@ import FilterItem from './filterItem';
|
|
|
9
9
|
import defaultClasses from './filterList.module.css';
|
|
10
10
|
import FilterItemRadioGroup from './filterItemRadioGroup';
|
|
11
11
|
import SubFilterItemRadioGroup from './subFilterItemRadioGroup';
|
|
12
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
12
13
|
|
|
13
14
|
const labels = new WeakMap();
|
|
14
15
|
const labels2 = new WeakMap();
|
|
@@ -256,6 +257,8 @@ const FilterList = props => {
|
|
|
256
257
|
classes
|
|
257
258
|
]);
|
|
258
259
|
|
|
260
|
+
const { pathname, search } = useLocation();
|
|
261
|
+
|
|
259
262
|
const showMoreItem = useMemo(() => {
|
|
260
263
|
if (items.length <= itemCountToShow) {
|
|
261
264
|
return null;
|
|
@@ -266,15 +269,22 @@ const FilterList = props => {
|
|
|
266
269
|
defaultMessage: 'View All'
|
|
267
270
|
});
|
|
268
271
|
|
|
272
|
+
const params = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') : {};
|
|
273
|
+
|
|
274
|
+
params[`filterby`] = `${group}`;
|
|
275
|
+
|
|
276
|
+
const finalParams = params ? Object.keys(params).map(key => `${key}=${params[key]}`).join('&') : '';
|
|
277
|
+
const path = pathname + finalParams;
|
|
278
|
+
|
|
269
279
|
return (
|
|
270
280
|
<li className={classes.showMoreLessItem}>
|
|
271
|
-
<
|
|
272
|
-
|
|
281
|
+
<Link
|
|
282
|
+
to={path}
|
|
273
283
|
className={classes.showMoreLessButton}
|
|
274
284
|
data-cy="FilterList-showMoreLessButton"
|
|
275
285
|
>
|
|
276
286
|
{label}
|
|
277
|
-
</
|
|
287
|
+
</Link>
|
|
278
288
|
</li>
|
|
279
289
|
);
|
|
280
290
|
}, [
|
|
@@ -34,8 +34,6 @@ const FilterSidebar = props => {
|
|
|
34
34
|
handleReset
|
|
35
35
|
} = talonProps;
|
|
36
36
|
|
|
37
|
-
console.log('subFilterItems')
|
|
38
|
-
console.log(subFilterItems)
|
|
39
37
|
// console.log(filters)
|
|
40
38
|
// console.log('filterCountToOpen'+filterCountToOpen)
|
|
41
39
|
// console.log('hideFilters'+hideFilters)
|
|
@@ -51,9 +49,9 @@ const FilterSidebar = props => {
|
|
|
51
49
|
typeof filterElement.getBoundingClientRect === 'function'
|
|
52
50
|
) {
|
|
53
51
|
const filterTop = filterElement.getBoundingClientRect().top;
|
|
54
|
-
const windowScrollY =
|
|
55
|
-
|
|
56
|
-
window.scrollTo(0, windowScrollY);
|
|
52
|
+
// const windowScrollY =
|
|
53
|
+
// window.scrollY + filterTop - SCROLL_OFFSET;
|
|
54
|
+
// window.scrollTo(0, windowScrollY);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
handleApply(...args);
|
|
@@ -100,7 +98,6 @@ const FilterSidebar = props => {
|
|
|
100
98
|
|
|
101
99
|
const hideFilters = ['card_game','bricks_categories','sc_sports_categories','trains','trains_locomotives','trains_supplies_type','lof_preorder','auction','special_price','sc_baseball_inserts','sc_baseball_parallel','sale','sc_set_type','sc_brands'];
|
|
102
100
|
if (!allowedFiltersArr?.length || filterState.size && allowedFiltersArr.length || !filterState.size && allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
|
|
103
|
-
console.log(group)
|
|
104
101
|
if (!hideFilters.includes(group) && groupName && !group.includes('card_release') && !group.includes('card_set') && !group.includes('sc_set_name')) {
|
|
105
102
|
|
|
106
103
|
// if (!allowedFiltersArr?.length && group != "category_uid" || allowedFiltersArr?.length && allowedFiltersArr.includes(group)) {
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useLazyQuery, useQuery } from '@apollo/client';
|
|
3
|
+
|
|
4
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
5
|
+
import { useLocation } from 'react-router-dom';
|
|
6
|
+
import DEFAULT_OPERATIONS from '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql';
|
|
7
|
+
import {
|
|
8
|
+
getFiltersFromSearch,
|
|
9
|
+
getFilterInput
|
|
10
|
+
} from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
11
|
+
|
|
12
|
+
export const useFilterContent = props => {
|
|
13
|
+
const { searchQuery, activeFilter, active, setActive, currentSort, filterby, categoryId, data, pageSize = 6 } = props;
|
|
14
|
+
|
|
15
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
getProductFiltersByCategoryQuery,
|
|
19
|
+
getCategoryContentQuery,
|
|
20
|
+
getFilterInputsQuery,
|
|
21
|
+
getStoreConfigQuery,
|
|
22
|
+
getMasterAttributesQuery
|
|
23
|
+
} = operations;
|
|
24
|
+
|
|
25
|
+
const placeholderItems = Array.from({ length: pageSize }).fill(null);
|
|
26
|
+
|
|
27
|
+
const { data: storeConfigData } = useQuery(getStoreConfigQuery, {
|
|
28
|
+
fetchPolicy: 'cache-and-network',
|
|
29
|
+
nextFetchPolicy: 'cache-first'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const [getFilters, { data: filtersDataResponse }] = useLazyQuery(
|
|
33
|
+
getProductFiltersByCategoryQuery,
|
|
34
|
+
{
|
|
35
|
+
fetchPolicy: 'cache-and-network',
|
|
36
|
+
nextFetchPolicy: 'cache-first'
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
41
|
+
getCategoryContentQuery,
|
|
42
|
+
{
|
|
43
|
+
fetchPolicy: 'cache-and-network',
|
|
44
|
+
nextFetchPolicy: 'cache-first',
|
|
45
|
+
skip: !categoryId,
|
|
46
|
+
variables: {
|
|
47
|
+
id: categoryId
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const { pathname, search } = useLocation();
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
called: introspectionCalled,
|
|
56
|
+
data: introspectionData,
|
|
57
|
+
loading: introspectionLoading
|
|
58
|
+
} = useQuery(getFilterInputsQuery);
|
|
59
|
+
|
|
60
|
+
const filterTypeMap = useMemo(() => {
|
|
61
|
+
const typeMap = new Map();
|
|
62
|
+
if (introspectionData) {
|
|
63
|
+
introspectionData.__type.inputFields.forEach(({ name, type }) => {
|
|
64
|
+
typeMap.set(name, type.name);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return typeMap;
|
|
68
|
+
}, [introspectionData]);
|
|
69
|
+
|
|
70
|
+
// MASTER ATTRIBUTES
|
|
71
|
+
const {
|
|
72
|
+
called: masterAttributesCalled,
|
|
73
|
+
data: masterAttributesData,
|
|
74
|
+
loading: masterAttributesLoading
|
|
75
|
+
} = useQuery(getMasterAttributesQuery,
|
|
76
|
+
{
|
|
77
|
+
fetchPolicy: 'cache-and-network',
|
|
78
|
+
nextFetchPolicy: 'cache-first'
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const masterAttributes = useMemo(() => {
|
|
82
|
+
const masterAttributes = [];
|
|
83
|
+
|
|
84
|
+
if (masterAttributesData) {
|
|
85
|
+
masterAttributesData.masterAttributes.forEach(({ attribute_code }) => {
|
|
86
|
+
masterAttributes.push(attribute_code);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return masterAttributes;
|
|
91
|
+
}, [masterAttributesData]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (categoryId) {
|
|
95
|
+
if (!filterTypeMap.size) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const filters = getFiltersFromSearch(search);
|
|
100
|
+
|
|
101
|
+
// Construct the filter arg object.
|
|
102
|
+
const newFilters = {};
|
|
103
|
+
filters.forEach((values, key) => {
|
|
104
|
+
if (masterAttributes.includes(key)) {
|
|
105
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
getFilters({
|
|
110
|
+
variables: {
|
|
111
|
+
filters: newFilters
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, [categoryId, getFilters, filterTypeMap, search, masterAttributes]);
|
|
116
|
+
|
|
117
|
+
const rawFilters = filtersDataResponse ? filtersDataResponse.products.aggregations : null;
|
|
118
|
+
const items = data ? data.products.items : placeholderItems;
|
|
119
|
+
const category =
|
|
120
|
+
categoryData && categoryData.categories.items.length
|
|
121
|
+
? categoryData.categories.items[0]
|
|
122
|
+
: null;
|
|
123
|
+
|
|
124
|
+
let filterData = [];
|
|
125
|
+
let title = '';
|
|
126
|
+
|
|
127
|
+
rawFilters && rawFilters.map((filter, index) => {
|
|
128
|
+
|
|
129
|
+
if (filter.attribute_code == filterby) {
|
|
130
|
+
let label = filter.label;
|
|
131
|
+
|
|
132
|
+
const filterOptions = filter.options.filter(function({ count }) {
|
|
133
|
+
return count > 0;
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const newFilter = {
|
|
137
|
+
attribute_code: filter.attribute_code,
|
|
138
|
+
count: filter.count,
|
|
139
|
+
label: label,
|
|
140
|
+
position: filter.position,
|
|
141
|
+
options: filterOptions
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
filterData = newFilter;
|
|
145
|
+
title = label;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const { value: sortby } = currentSort
|
|
150
|
+
|
|
151
|
+
// const [runQuery, queryResponse] = useLazyQuery(getShopByDataQuery, {
|
|
152
|
+
// fetchPolicy: 'cache-and-network',
|
|
153
|
+
// nextFetchPolicy: 'cache-first'
|
|
154
|
+
// });
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const pathnameArr = pathname.split('/');
|
|
159
|
+
|
|
160
|
+
const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
|
|
161
|
+
|
|
162
|
+
const categoryUrlSuffix = storeConfigData ? storeConfigData?.storeConfig?.category_url_suffix : '';
|
|
163
|
+
// const categoryUrlSuffix = 'html';
|
|
164
|
+
|
|
165
|
+
// const { data: introspectionData } = useQuery(getFilterInputsQuery);
|
|
166
|
+
|
|
167
|
+
const activeFilters = [];
|
|
168
|
+
|
|
169
|
+
const filters = getFiltersFromSearch(search);
|
|
170
|
+
|
|
171
|
+
// Construct the filter arg object.
|
|
172
|
+
const newFilters = {};
|
|
173
|
+
filters.forEach((values, key) => {
|
|
174
|
+
if (filterTypeMap.get(key)) {
|
|
175
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
176
|
+
|
|
177
|
+
if (key == "sc_baseball_release") {
|
|
178
|
+
for(let item of values) {
|
|
179
|
+
if(item) {
|
|
180
|
+
const data = search.split('&');
|
|
181
|
+
data.pop();
|
|
182
|
+
activeFilters.push(
|
|
183
|
+
{
|
|
184
|
+
'label': item.split(',')[0],
|
|
185
|
+
'path': data
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const 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'];
|
|
195
|
+
|
|
196
|
+
const originalDataResult = useMemo(() => {
|
|
197
|
+
if (!filterData) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const options = filterData?.options;
|
|
202
|
+
if (!options) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const mappingData = options.reduce((acc, item) => {
|
|
207
|
+
let firstLetter = item.label? item.label.charAt(0).toUpperCase() : '';
|
|
208
|
+
if (!alpha.includes(firstLetter)) {
|
|
209
|
+
firstLetter = '#';
|
|
210
|
+
}
|
|
211
|
+
if (filterby == "vehicles_year" || filterby == "trains_gauge" || filterby == "vehicles_scale" || filterby == "lego_theme" || filterby == "lego_subtheme" || filterby == "lego_interest") {
|
|
212
|
+
firstLetter = '#';
|
|
213
|
+
}
|
|
214
|
+
acc[firstLetter] = acc[firstLetter] || [];
|
|
215
|
+
acc[firstLetter].push(item);
|
|
216
|
+
return acc;
|
|
217
|
+
}, {});
|
|
218
|
+
|
|
219
|
+
const sortbyData = [];
|
|
220
|
+
|
|
221
|
+
return sortby != "all" ? sortbyData && sortbyData.length ? sortbyData.sort((a, b) => b.release_type.toLowerCase().localeCompare(a.release_type.toLowerCase())) : sortbyData : mappingData;
|
|
222
|
+
}, [filterData, sortby]);
|
|
223
|
+
|
|
224
|
+
const filteredOptions = useMemo(() => {
|
|
225
|
+
if (!filterData) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const options = filterData?.options;
|
|
230
|
+
if (!options) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (searchQuery) {
|
|
235
|
+
if (active != "all") {
|
|
236
|
+
setActive('all');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return options.filter(function(option) {
|
|
240
|
+
return option.label.search(new RegExp(searchQuery, "i")) != -1;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return options;
|
|
245
|
+
}, [filterData, searchQuery]);
|
|
246
|
+
|
|
247
|
+
const dataResult = useMemo(() => {
|
|
248
|
+
if (filteredOptions) {
|
|
249
|
+
return filteredOptions.reduce((acc, item) => {
|
|
250
|
+
let firstLetter = item.label ? item.label.charAt(0).toUpperCase() : '';
|
|
251
|
+
if (!alpha.includes(firstLetter)) {
|
|
252
|
+
firstLetter = '#';
|
|
253
|
+
}
|
|
254
|
+
if (filterby == "vehicles_year" || filterby == "trains_gauge" || filterby == "vehicles_scale" || filterby == "lego_theme" || filterby == "lego_subtheme" || filterby == "lego_interest") {
|
|
255
|
+
firstLetter = '#';
|
|
256
|
+
}
|
|
257
|
+
acc[firstLetter] = acc[firstLetter] || [];
|
|
258
|
+
acc[firstLetter].push(item);
|
|
259
|
+
return acc;
|
|
260
|
+
}, {});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return filteredOptions;
|
|
264
|
+
}, [filteredOptions]);
|
|
265
|
+
|
|
266
|
+
let availableGroups = originalDataResult ? Object.keys(originalDataResult).sort() : [];
|
|
267
|
+
|
|
268
|
+
let filteredAvailableGroups = dataResult ? Object.keys(dataResult).sort() : [];
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
console.log('dataResult', dataResult)
|
|
272
|
+
if (filterby == "vehicles_year" || filterby == "trains_gauge" || filterby == "vehicles_scale" || filterby == "lego_theme" || filterby == "lego_subtheme" || filterby == "lego_interest") {
|
|
273
|
+
availableGroups = ['#'];
|
|
274
|
+
filteredAvailableGroups = ['#'];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const attributeData = filterData;
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
filterData,
|
|
281
|
+
title,
|
|
282
|
+
dataResult,
|
|
283
|
+
filteredAvailableGroups,
|
|
284
|
+
categoryUrlSuffix,
|
|
285
|
+
categoryUrlKey,
|
|
286
|
+
availableGroups,
|
|
287
|
+
alpha,
|
|
288
|
+
category,
|
|
289
|
+
activeFilters
|
|
290
|
+
};
|
|
291
|
+
};
|
|
@@ -144,8 +144,6 @@ export const useSellerProducts = props => {
|
|
|
144
144
|
]);
|
|
145
145
|
|
|
146
146
|
const categoryId = useMemo(() => {
|
|
147
|
-
console.log('---===routerouterouterouteroute')
|
|
148
|
-
console.log(routeData)
|
|
149
147
|
let uid = null;
|
|
150
148
|
if (routeData) {
|
|
151
149
|
const { route } = routeData || {};
|
|
@@ -58,29 +58,24 @@ export const useShopBy = props => {
|
|
|
58
58
|
|
|
59
59
|
const filters = getFiltersFromSearch(search);
|
|
60
60
|
|
|
61
|
-
console.log('filtersfilters')
|
|
62
|
-
console.log(filterTypeMap)
|
|
63
|
-
|
|
64
61
|
// Construct the filter arg object.
|
|
65
62
|
const newFilters = {};
|
|
66
63
|
filters.forEach((values, key) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
64
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
65
|
+
|
|
66
|
+
if (key == "sc_baseball_release") {
|
|
67
|
+
for(let item of values) {
|
|
68
|
+
if(item) {
|
|
69
|
+
// console.log(item.split(',')[0])
|
|
70
|
+
const data = search.split('&');
|
|
71
|
+
data.pop();
|
|
72
|
+
activeFilters.push(
|
|
73
|
+
{
|
|
74
|
+
'label': item.split(',')[0],
|
|
75
|
+
'path': data
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
}
|
|
84
79
|
}
|
|
85
80
|
}
|
|
86
81
|
});
|
|
@@ -142,11 +137,8 @@ export const useShopBy = props => {
|
|
|
142
137
|
|
|
143
138
|
let options = rawData[0].options;
|
|
144
139
|
|
|
145
|
-
console.log(options)
|
|
146
|
-
console.log('options')
|
|
147
|
-
|
|
148
140
|
const mappingData = options.reduce((acc, item) => {
|
|
149
|
-
let firstLetter = item.label
|
|
141
|
+
let firstLetter = item.label.charAt(0).toUpperCase();
|
|
150
142
|
if (!alpha.includes(firstLetter)) {
|
|
151
143
|
firstLetter = '#';
|
|
152
144
|
}
|
|
@@ -207,7 +199,7 @@ export const useShopBy = props => {
|
|
|
207
199
|
const dataResult = useMemo(() => {
|
|
208
200
|
if (filteredOptions) {
|
|
209
201
|
return filteredOptions.reduce((acc, item) => {
|
|
210
|
-
let firstLetter = item.label
|
|
202
|
+
let firstLetter = item.label.charAt(0).toUpperCase();
|
|
211
203
|
if (!alpha.includes(firstLetter)) {
|
|
212
204
|
firstLetter = '#';
|
|
213
205
|
}
|