@riosst100/pwa-marketplace 1.8.1 → 1.8.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/i18n/id_ID.json +508 -508
- package/package.json +1 -1
- package/src/components/CustomSubCategory/subCategory.js +0 -14
- package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.module.css +1 -1
- package/src/components/FilterTop/filterTop.js +2 -2
- package/src/components/FilterTop/filterTop.module.css +1 -1
- package/src/components/FilterTopBackup/CustomFilters/customFilter.js +83 -83
- package/src/components/FilterTopBackup/CustomFilters/customFilter.module.css +21 -21
- package/src/components/FilterTopBackup/CustomFilters/customFilters.js +131 -131
- package/src/components/FilterTopBackup/CustomFilters/customFilters.module.css +22 -22
- package/src/components/FilterTopBackup/CustomFilters/index.js +1 -1
- package/src/components/FilterTopBackup/filterTop.js +14 -14
- package/src/components/FilterTopBackup/filterTop.module.css +22 -22
- package/src/components/FilterTopBackup/filterTop.shimmer.js +24 -24
- package/src/components/FilterTopBackup/index.js +2 -2
- package/src/components/Header/websiteSwitcher.shimmer.js +6 -6
- package/src/components/Header/websiteSwitcherItem.js +47 -47
- package/src/components/Header/websiteSwitcherItem.module.css +20 -20
- package/src/components/PhoneTextInput/index.js +1 -1
- package/src/components/PhoneTextInput/phoneTextInput.js +62 -62
- package/src/components/ProductListTab/index.js +4 -4
- package/src/components/ProductListTab/productListTab.module.css +64 -64
- package/src/components/ProductListTab/productListTab.shimmer.js +24 -24
- package/src/components/SellerCountry/index.js +1 -1
- package/src/components/SellerCountry/sellerCountry.js +71 -71
- package/src/components/SellerCountry/sellerCountry.module.css +3 -3
- package/src/components/ShopByCategory/index.js +2 -2
- package/src/components/ShopByCategory/shopByCategory.js +69 -69
- package/src/components/ShopByCategory/shopByCategory.module.css +58 -58
- package/src/components/ShopByCategory/shopByCategory.shimmer.js +24 -24
- package/src/components/SubCategory/subCategory.js +1 -1
- package/src/components/WebsiteSwitcher/websiteSwitcher.shimmer.js +6 -6
- package/src/components/WebsiteSwitcher/websiteSwitcherItem.js +47 -47
- package/src/components/WebsiteSwitcher/websiteSwitcherItem.module.css +20 -20
- package/src/overwrites/peregrine/lib/talons/MegaMenu/megaMenu.gql.js +96 -96
- package/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenu.js +199 -199
- package/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenuItem.js +66 -66
- package/src/overwrites/peregrine/lib/talons/MegaMenu/useSubMenu.js +20 -20
- package/src/overwrites/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js +642 -642
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/category.gql.js +49 -49
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategory.js +227 -227
- package/src/overwrites/peregrine/lib/talons/RootComponents/Product/product.gql.js +31 -31
- package/src/overwrites/peregrine/lib/talons/RootComponents/Product/productDetailFragment.gql.js +235 -235
- package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.module.css +47 -47
- package/src/overwrites/venia-ui/lib/components/RadioGroup/radio.js +60 -60
- package/src/overwrites/venia-ui/lib/components/RadioGroup/radio.module.css +70 -70
- package/src/talons/AttributesBlock/attributesBlock.gql.js +15 -15
- package/src/talons/CustomFilters/customFilters.gql.js +45 -45
- package/src/talons/CustomFilters/useCustomFilters.js +5 -2
- package/src/talons/FilterTop/filterTop.gql.js +45 -45
- package/src/talons/FilterTop/index.js +1 -1
- package/src/talons/FilterTop/useFilterTop.js +5 -4
- package/src/talons/Header/websiteSwitcher.gql.js +45 -45
- package/src/talons/SellerReview/sellerReview.gql.js +53 -53
- package/src/talons/ShopByCategory/index.js +1 -1
- package/src/talons/ShopByCategory/shopByCategory.gql.js +38 -38
- package/src/talons/ShopByCategory/useShopByCategory.js +69 -69
- package/src/talons/SubCategory/subCategory.gql.js +15 -15
- package/src/talons/SubCategory/useSubCategory.js +3 -3
- package/src/talons/WebsiteSwitcher/websiteSwitcher.gql.js +45 -45
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { useSubCategory } from '@riosst100/pwa-marketplace/src/talons/SubCategory/useSubCategory';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
|
-
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
5
4
|
import defaultClasses from './subCategory.module.css';
|
|
6
5
|
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
-
import { useFilterSidebar } from '@magento/peregrine/lib/talons/FilterSidebar';
|
|
8
|
-
import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets/collectibleGameSets';
|
|
9
6
|
|
|
10
7
|
const SubCategory = props => {
|
|
11
8
|
const { children } = props;
|
|
@@ -34,17 +31,6 @@ const SubCategory = props => {
|
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
return subCategory.length ? <ul className={classes.root}>{subCategory}</ul> : '';
|
|
37
|
-
|
|
38
|
-
// const [activeTab, setActiveTab] = useState('singles')
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<>
|
|
42
|
-
<ul className={classes.root}>
|
|
43
|
-
<li className={classes.item}>All Sets</li>
|
|
44
|
-
<li className={classes.item}>Expansion Sets</li>
|
|
45
|
-
</ul>
|
|
46
|
-
</>
|
|
47
|
-
)
|
|
48
34
|
};
|
|
49
35
|
|
|
50
36
|
export default SubCategory;
|
|
@@ -22,8 +22,8 @@ const SCROLL_OFFSET = 150;
|
|
|
22
22
|
* @param {Object} props.filters - filters to display
|
|
23
23
|
*/
|
|
24
24
|
const FilterTop = props => {
|
|
25
|
-
const { filters, filterCountToOpen, allowedFilters } = props;
|
|
26
|
-
const talonProps = useFilterTop({ filters });
|
|
25
|
+
const { filters, filterCountToOpen, allowedFilters, category } = props;
|
|
26
|
+
const talonProps = useFilterTop({ filters, category });
|
|
27
27
|
const {
|
|
28
28
|
filterApi,
|
|
29
29
|
filterItems,
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import { shape, string, func } from 'prop-types';
|
|
4
|
-
import { X as Remove } from 'react-feather';
|
|
5
|
-
|
|
6
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
-
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
8
|
-
import Trigger from '@magento/venia-ui/lib/components/Trigger';
|
|
9
|
-
import defaultClasses from './customFilter.module.css';
|
|
10
|
-
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
11
|
-
|
|
12
|
-
import { Link } from 'react-router-dom';
|
|
13
|
-
|
|
14
|
-
const CustomFilter = props => {
|
|
15
|
-
const { group, item, onRemove } = props;
|
|
16
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
17
|
-
const { formatMessage } = useIntl();
|
|
18
|
-
|
|
19
|
-
const ariaLabel = formatMessage(
|
|
20
|
-
{
|
|
21
|
-
id: 'filterModal.action.clearFilterItem.ariaLabel',
|
|
22
|
-
defaultMessage: 'Clear filter "{name}"'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: item.label ? item.label : item.title
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const normalizedData = [
|
|
30
|
-
{
|
|
31
|
-
'label': 'Sealed Products',
|
|
32
|
-
'path': '/'
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
'label': 'Singles',
|
|
36
|
-
'path': '/'
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
'label': 'Supplies',
|
|
40
|
-
'path': '/'
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const subCategory = [];
|
|
45
|
-
|
|
46
|
-
const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
|
|
47
|
-
|
|
48
|
-
if (customAttributeLandingPage.includes(group)) {
|
|
49
|
-
normalizedData && normalizedData.map(({ label, path }, index) => {
|
|
50
|
-
subCategory.push(
|
|
51
|
-
<Link
|
|
52
|
-
key={index}
|
|
53
|
-
to={resourceUrl(path)}
|
|
54
|
-
>
|
|
55
|
-
<li className={classes.item}>{label}</li>
|
|
56
|
-
</Link>
|
|
57
|
-
)
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<ul className={classes.root}>{subCategory}</ul>
|
|
64
|
-
// <span className={classes.root} data-cy="CustomFilter-root">
|
|
65
|
-
// <span className={classes.text}>
|
|
66
|
-
// {item.label ? item.label : item.title}
|
|
67
|
-
// </span>
|
|
68
|
-
// </span>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default CustomFilter;
|
|
73
|
-
|
|
74
|
-
CustomFilter.defaultProps = {
|
|
75
|
-
onRemove: null
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
CustomFilter.propTypes = {
|
|
79
|
-
classes: shape({
|
|
80
|
-
root: string
|
|
81
|
-
}),
|
|
82
|
-
onRemove: func
|
|
83
|
-
};
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { shape, string, func } from 'prop-types';
|
|
4
|
+
import { X as Remove } from 'react-feather';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
8
|
+
import Trigger from '@magento/venia-ui/lib/components/Trigger';
|
|
9
|
+
import defaultClasses from './customFilter.module.css';
|
|
10
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
11
|
+
|
|
12
|
+
import { Link } from 'react-router-dom';
|
|
13
|
+
|
|
14
|
+
const CustomFilter = props => {
|
|
15
|
+
const { group, item, onRemove } = props;
|
|
16
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
17
|
+
const { formatMessage } = useIntl();
|
|
18
|
+
|
|
19
|
+
const ariaLabel = formatMessage(
|
|
20
|
+
{
|
|
21
|
+
id: 'filterModal.action.clearFilterItem.ariaLabel',
|
|
22
|
+
defaultMessage: 'Clear filter "{name}"'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: item.label ? item.label : item.title
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const normalizedData = [
|
|
30
|
+
{
|
|
31
|
+
'label': 'Sealed Products',
|
|
32
|
+
'path': '/'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
'label': 'Singles',
|
|
36
|
+
'path': '/'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
'label': 'Supplies',
|
|
40
|
+
'path': '/'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const subCategory = [];
|
|
45
|
+
|
|
46
|
+
const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
|
|
47
|
+
|
|
48
|
+
if (customAttributeLandingPage.includes(group)) {
|
|
49
|
+
normalizedData && normalizedData.map(({ label, path }, index) => {
|
|
50
|
+
subCategory.push(
|
|
51
|
+
<Link
|
|
52
|
+
key={index}
|
|
53
|
+
to={resourceUrl(path)}
|
|
54
|
+
>
|
|
55
|
+
<li className={classes.item}>{label}</li>
|
|
56
|
+
</Link>
|
|
57
|
+
)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<ul className={classes.root}>{subCategory}</ul>
|
|
64
|
+
// <span className={classes.root} data-cy="CustomFilter-root">
|
|
65
|
+
// <span className={classes.text}>
|
|
66
|
+
// {item.label ? item.label : item.title}
|
|
67
|
+
// </span>
|
|
68
|
+
// </span>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default CustomFilter;
|
|
73
|
+
|
|
74
|
+
CustomFilter.defaultProps = {
|
|
75
|
+
onRemove: null
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
CustomFilter.propTypes = {
|
|
79
|
+
classes: shape({
|
|
80
|
+
root: string
|
|
81
|
+
}),
|
|
82
|
+
onRemove: func
|
|
83
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
composes: flex from global;
|
|
3
|
-
composes: flex-wrap from global;
|
|
4
|
-
composes: mt-3 from global;
|
|
5
|
-
composes: gap-[15px] from global;
|
|
6
|
-
margin-bottom: 10px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.item {
|
|
10
|
-
composes: px-4 from global;
|
|
11
|
-
composes: py-2 from global;
|
|
12
|
-
composes: transition-colors from global;
|
|
13
|
-
composes: duration-150 from global;
|
|
14
|
-
composes: border from global;
|
|
15
|
-
composes: border-solid from global;
|
|
16
|
-
composes: leading-normal from global;
|
|
17
|
-
composes: text-base from global;
|
|
18
|
-
composes: text-colorDefault from global;
|
|
19
|
-
composes: bg-white from global;
|
|
20
|
-
composes: border-gray-100 from global;
|
|
21
|
-
border-radius: 5px;
|
|
1
|
+
.root {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
composes: mt-3 from global;
|
|
5
|
+
composes: gap-[15px] from global;
|
|
6
|
+
margin-bottom: 10px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.item {
|
|
10
|
+
composes: px-4 from global;
|
|
11
|
+
composes: py-2 from global;
|
|
12
|
+
composes: transition-colors from global;
|
|
13
|
+
composes: duration-150 from global;
|
|
14
|
+
composes: border from global;
|
|
15
|
+
composes: border-solid from global;
|
|
16
|
+
composes: leading-normal from global;
|
|
17
|
+
composes: text-base from global;
|
|
18
|
+
composes: text-colorDefault from global;
|
|
19
|
+
composes: bg-white from global;
|
|
20
|
+
composes: border-gray-100 from global;
|
|
21
|
+
border-radius: 5px;
|
|
22
22
|
}
|
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from 'react';
|
|
2
|
-
import { func, shape, string } from 'prop-types';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
|
|
5
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
-
import CustomFilter from './customFilter';
|
|
7
|
-
import defaultClasses from './customFilters.module.css';
|
|
8
|
-
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
9
|
-
import { Link } from 'react-router-dom';
|
|
10
|
-
import { useCustomFilters } from '@riosst100/pwa-marketplace/src/talons/CustomFilters/useCustomFilters';
|
|
11
|
-
|
|
12
|
-
const CustomFilters = props => {
|
|
13
|
-
const { onRemove, clearAll, category, filters } = props;
|
|
14
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
15
|
-
const { formatMessage } = useIntl();
|
|
16
|
-
|
|
17
|
-
const talonProps = useCustomFilters({ filters });
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
customFiltersData,
|
|
21
|
-
categoryUrlSuffix,
|
|
22
|
-
search,
|
|
23
|
-
pathname,
|
|
24
|
-
filterApi,
|
|
25
|
-
// filterItems,
|
|
26
|
-
// filterNames,
|
|
27
|
-
// filterFrontendInput,
|
|
28
|
-
filterState
|
|
29
|
-
} = talonProps;
|
|
30
|
-
|
|
31
|
-
const params = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') : {};
|
|
32
|
-
|
|
33
|
-
const { removeItem } = filterApi;
|
|
34
|
-
|
|
35
|
-
const activeFilters = useMemo(() => {
|
|
36
|
-
const elements = [];
|
|
37
|
-
for (const [group, items] of filterState) {
|
|
38
|
-
for (const item of items) {
|
|
39
|
-
elements.push(
|
|
40
|
-
{
|
|
41
|
-
group: group,
|
|
42
|
-
item: item,
|
|
43
|
-
removeItem: removeItem
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return elements;
|
|
50
|
-
}, [filterState, removeItem]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// const handleClick = useCallback(() => {
|
|
54
|
-
// removeItem({ group, item });
|
|
55
|
-
// }, [group, item, removeItem]);
|
|
56
|
-
|
|
57
|
-
// create elements and params at the same time for efficiency
|
|
58
|
-
const filterElements = useMemo(() => {
|
|
59
|
-
const elements = [];
|
|
60
|
-
customFiltersData && customFiltersData.map((filter, index) => {
|
|
61
|
-
const { label, attribute_code, options } = filter || {};
|
|
62
|
-
|
|
63
|
-
const group = attribute_code;
|
|
64
|
-
|
|
65
|
-
// const handleClick = useCallback(() => {
|
|
66
|
-
// removeItem({ group, item });
|
|
67
|
-
// if (typeof onRemove === 'function') {
|
|
68
|
-
// onRemove(group, item);
|
|
69
|
-
// }
|
|
70
|
-
// }, [group, item, removeItem, onRemove]);
|
|
71
|
-
|
|
72
|
-
if (options.length) {
|
|
73
|
-
const items = [];
|
|
74
|
-
options.map((item, index) => {
|
|
75
|
-
const { label, value } = item
|
|
76
|
-
// const path = '/';
|
|
77
|
-
|
|
78
|
-
// const path = resourceUrl(
|
|
79
|
-
// `/${category.url_path}${categoryUrlSuffix || ''}?${attribute_code}[filter]=${label},${value}`
|
|
80
|
-
// );
|
|
81
|
-
// const keyAttr = `${attribute_code}[filter]`;
|
|
82
|
-
|
|
83
|
-
if (params) {
|
|
84
|
-
Object.keys(params).forEach(function(key, index) {
|
|
85
|
-
if (index > 1) {
|
|
86
|
-
delete params[key];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (value != "all") {
|
|
92
|
-
params[`${attribute_code}[filter]`] = `${label},${value}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const finalParams = params ? Object.keys(params).map(key => `${key}=${params[key]}`).join('&') : '';
|
|
96
|
-
const path = pathname + finalParams;
|
|
97
|
-
|
|
98
|
-
if (value != "all") {
|
|
99
|
-
items.push(
|
|
100
|
-
<li key={index}>
|
|
101
|
-
<Link
|
|
102
|
-
to={path}
|
|
103
|
-
>
|
|
104
|
-
<span className={classes.item}>{label}</span>
|
|
105
|
-
</Link>
|
|
106
|
-
</li>
|
|
107
|
-
)
|
|
108
|
-
} else {
|
|
109
|
-
items.push(
|
|
110
|
-
<li key={index}>
|
|
111
|
-
<span className={classes.item} onClick={removeItem({ group, item })}>{label}</span>
|
|
112
|
-
</li>
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
elements.push(
|
|
118
|
-
<ul key={index} className={classes.root}>{items}</ul>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
return elements;
|
|
124
|
-
}, [customFiltersData]);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<>{filterElements}</>
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export default CustomFilters;
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { func, shape, string } from 'prop-types';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
+
import CustomFilter from './customFilter';
|
|
7
|
+
import defaultClasses from './customFilters.module.css';
|
|
8
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
9
|
+
import { Link } from 'react-router-dom';
|
|
10
|
+
import { useCustomFilters } from '@riosst100/pwa-marketplace/src/talons/CustomFilters/useCustomFilters';
|
|
11
|
+
|
|
12
|
+
const CustomFilters = props => {
|
|
13
|
+
const { onRemove, clearAll, category, filters } = props;
|
|
14
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
15
|
+
const { formatMessage } = useIntl();
|
|
16
|
+
|
|
17
|
+
const talonProps = useCustomFilters({ filters, category });
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
customFiltersData,
|
|
21
|
+
categoryUrlSuffix,
|
|
22
|
+
search,
|
|
23
|
+
pathname,
|
|
24
|
+
filterApi,
|
|
25
|
+
// filterItems,
|
|
26
|
+
// filterNames,
|
|
27
|
+
// filterFrontendInput,
|
|
28
|
+
filterState
|
|
29
|
+
} = talonProps;
|
|
30
|
+
|
|
31
|
+
const params = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') : {};
|
|
32
|
+
|
|
33
|
+
const { removeItem } = filterApi;
|
|
34
|
+
|
|
35
|
+
const activeFilters = useMemo(() => {
|
|
36
|
+
const elements = [];
|
|
37
|
+
for (const [group, items] of filterState) {
|
|
38
|
+
for (const item of items) {
|
|
39
|
+
elements.push(
|
|
40
|
+
{
|
|
41
|
+
group: group,
|
|
42
|
+
item: item,
|
|
43
|
+
removeItem: removeItem
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return elements;
|
|
50
|
+
}, [filterState, removeItem]);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// const handleClick = useCallback(() => {
|
|
54
|
+
// removeItem({ group, item });
|
|
55
|
+
// }, [group, item, removeItem]);
|
|
56
|
+
|
|
57
|
+
// create elements and params at the same time for efficiency
|
|
58
|
+
const filterElements = useMemo(() => {
|
|
59
|
+
const elements = [];
|
|
60
|
+
customFiltersData && customFiltersData.map((filter, index) => {
|
|
61
|
+
const { label, attribute_code, options } = filter || {};
|
|
62
|
+
|
|
63
|
+
const group = attribute_code;
|
|
64
|
+
|
|
65
|
+
// const handleClick = useCallback(() => {
|
|
66
|
+
// removeItem({ group, item });
|
|
67
|
+
// if (typeof onRemove === 'function') {
|
|
68
|
+
// onRemove(group, item);
|
|
69
|
+
// }
|
|
70
|
+
// }, [group, item, removeItem, onRemove]);
|
|
71
|
+
|
|
72
|
+
if (options.length) {
|
|
73
|
+
const items = [];
|
|
74
|
+
options.map((item, index) => {
|
|
75
|
+
const { label, value } = item
|
|
76
|
+
// const path = '/';
|
|
77
|
+
|
|
78
|
+
// const path = resourceUrl(
|
|
79
|
+
// `/${category.url_path}${categoryUrlSuffix || ''}?${attribute_code}[filter]=${label},${value}`
|
|
80
|
+
// );
|
|
81
|
+
// const keyAttr = `${attribute_code}[filter]`;
|
|
82
|
+
|
|
83
|
+
if (params) {
|
|
84
|
+
Object.keys(params).forEach(function(key, index) {
|
|
85
|
+
if (index > 1) {
|
|
86
|
+
delete params[key];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (value != "all") {
|
|
92
|
+
params[`${attribute_code}[filter]`] = `${label},${value}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const finalParams = params ? Object.keys(params).map(key => `${key}=${params[key]}`).join('&') : '';
|
|
96
|
+
const path = pathname + finalParams;
|
|
97
|
+
|
|
98
|
+
if (value != "all") {
|
|
99
|
+
items.push(
|
|
100
|
+
<li key={index}>
|
|
101
|
+
<Link
|
|
102
|
+
to={path}
|
|
103
|
+
>
|
|
104
|
+
<span className={classes.item}>{label}</span>
|
|
105
|
+
</Link>
|
|
106
|
+
</li>
|
|
107
|
+
)
|
|
108
|
+
} else {
|
|
109
|
+
items.push(
|
|
110
|
+
<li key={index}>
|
|
111
|
+
<span className={classes.item} onClick={removeItem({ group, item })}>{label}</span>
|
|
112
|
+
</li>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
elements.push(
|
|
118
|
+
<ul key={index} className={classes.root}>{items}</ul>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return elements;
|
|
124
|
+
}, [customFiltersData]);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<>{filterElements}</>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default CustomFilters;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
composes: flex from global;
|
|
3
|
-
composes: flex-wrap from global;
|
|
4
|
-
composes: mt-3 from global;
|
|
5
|
-
composes: gap-[15px] from global;
|
|
6
|
-
margin-bottom: 10px;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.item {
|
|
11
|
-
composes: px-4 from global;
|
|
12
|
-
composes: py-2 from global;
|
|
13
|
-
composes: transition-colors from global;
|
|
14
|
-
composes: duration-150 from global;
|
|
15
|
-
composes: border from global;
|
|
16
|
-
composes: border-solid from global;
|
|
17
|
-
composes: leading-normal from global;
|
|
18
|
-
composes: text-base from global;
|
|
19
|
-
composes: text-colorDefault from global;
|
|
20
|
-
composes: bg-white from global;
|
|
21
|
-
composes: border-gray-100 from global;
|
|
22
|
-
border-radius: 5px;
|
|
1
|
+
.root {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
composes: mt-3 from global;
|
|
5
|
+
composes: gap-[15px] from global;
|
|
6
|
+
margin-bottom: 10px;
|
|
7
|
+
/* justify-content: center; */
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.item {
|
|
11
|
+
composes: px-4 from global;
|
|
12
|
+
composes: py-2 from global;
|
|
13
|
+
composes: transition-colors from global;
|
|
14
|
+
composes: duration-150 from global;
|
|
15
|
+
composes: border from global;
|
|
16
|
+
composes: border-solid from global;
|
|
17
|
+
composes: leading-normal from global;
|
|
18
|
+
composes: text-base from global;
|
|
19
|
+
composes: text-colorDefault from global;
|
|
20
|
+
composes: bg-white from global;
|
|
21
|
+
composes: border-gray-100 from global;
|
|
22
|
+
border-radius: 5px;
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './customFilters';
|
|
1
|
+
export { default } from './customFilters';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import CustomFilters from './CustomFilters';
|
|
3
|
-
|
|
4
|
-
const FilterTop = props => {
|
|
5
|
-
const { category, filters } = props;
|
|
6
|
-
return (
|
|
7
|
-
<CustomFilters
|
|
8
|
-
category={category}
|
|
9
|
-
filters={filters}
|
|
10
|
-
/>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default FilterTop;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CustomFilters from './CustomFilters';
|
|
3
|
+
|
|
4
|
+
const FilterTop = props => {
|
|
5
|
+
const { category, filters } = props;
|
|
6
|
+
return (
|
|
7
|
+
<CustomFilters
|
|
8
|
+
category={category}
|
|
9
|
+
filters={filters}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default FilterTop;
|