@riosst100/pwa-marketplace 2.3.9 → 2.4.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/componentOverrideMapping.js +1 -0
- package/src/components/ProductContent/productContent.js +0 -1
- package/src/overwrites/peregrine/lib/talons/FilterModal/filterModal.gql.js +31 -0
- package/src/overwrites/peregrine/lib/talons/FilterModal/useFilterList.js +2 -4
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +41 -4
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +50 -12
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +8 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock.js +6 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/filterModal.js +1 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +19 -14
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = componentOverrideMapping = {
|
|
|
14
14
|
[`@magento/peregrine/lib/talons/SignIn/useSignIn.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js',
|
|
15
15
|
[`@magento/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js',
|
|
16
16
|
[`@magento/peregrine/lib/talons/MegaMenu/megaMenu.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/MegaMenu/megaMenu.gql.js',
|
|
17
|
+
[`@magento/peregrine/lib/talons/FilterModal/filterModal.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/FilterModal/filterModal.gql.js',
|
|
17
18
|
[`@magento/peregrine/lib/talons/RootComponents/Product/productDetailFragment.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/RootComponents/Product/productDetailFragment.gql.js',
|
|
18
19
|
[`@magento/peregrine/lib/talons/RootComponents/Product/useProduct.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/RootComponents/Product/useProduct.js',
|
|
19
20
|
[`@magento/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js',
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const GET_FILTER_INPUTS = gql`
|
|
4
|
+
query GetFilterInputsForModal {
|
|
5
|
+
__type(name: "ProductAttributeFilterInput") {
|
|
6
|
+
inputFields {
|
|
7
|
+
name
|
|
8
|
+
type {
|
|
9
|
+
name
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const GET_SUB_FILTERS = gql`
|
|
17
|
+
query GetSubFilters {
|
|
18
|
+
subFilters {
|
|
19
|
+
attribute_code
|
|
20
|
+
options {
|
|
21
|
+
option_label
|
|
22
|
+
sub_option_labels
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
getFilterInputsQuery: GET_FILTER_INPUTS,
|
|
30
|
+
getSubFiltersQuery: GET_SUB_FILTERS
|
|
31
|
+
};
|
|
@@ -10,9 +10,7 @@ export const useFilterList = props => {
|
|
|
10
10
|
() =>
|
|
11
11
|
items.some((item, index) => {
|
|
12
12
|
return (
|
|
13
|
-
filterState &&
|
|
14
|
-
filterState.has(item) &&
|
|
15
|
-
index >= itemCountToShow
|
|
13
|
+
filterState && filterState.has(item) && index >= itemCountToShow
|
|
16
14
|
);
|
|
17
15
|
}),
|
|
18
16
|
[filterState, itemCountToShow, items]
|
|
@@ -46,7 +44,7 @@ export const useFilterList = props => {
|
|
|
46
44
|
if (!overlay) {
|
|
47
45
|
setActiveFilter(false)
|
|
48
46
|
}
|
|
49
|
-
}, [overlay])
|
|
47
|
+
}, [overlay]);
|
|
50
48
|
|
|
51
49
|
// const handleShowMore = useCallback(() => {
|
|
52
50
|
// handleShowAllOptions();
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
sortFiltersArray,
|
|
13
13
|
stripHtml
|
|
14
14
|
} from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
15
|
-
|
|
15
|
+
import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
16
16
|
import DEFAULT_OPERATIONS from '@magento/peregrine/lib/talons/FilterModal/filterModal.gql';
|
|
17
17
|
|
|
18
18
|
const DRAWER_NAME = 'filter';
|
|
@@ -21,7 +21,7 @@ export const useFilterSidebar = props => {
|
|
|
21
21
|
const { filters } = props;
|
|
22
22
|
|
|
23
23
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
24
|
-
const { getFilterInputsQuery } = operations;
|
|
24
|
+
const { getFilterInputsQuery, getSubFiltersQuery } = operations;
|
|
25
25
|
|
|
26
26
|
const [isApplying, setIsApplying] = useState(false);
|
|
27
27
|
const [{ drawer }, { toggleDrawer, closeDrawer }] = useAppContext();
|
|
@@ -32,8 +32,20 @@ export const useFilterSidebar = props => {
|
|
|
32
32
|
const history = useHistory();
|
|
33
33
|
const { pathname, search } = useLocation();
|
|
34
34
|
|
|
35
|
+
const allActiveFilters = getFiltersFromSearch(search);
|
|
36
|
+
|
|
35
37
|
const { data: introspectionData } = useQuery(getFilterInputsQuery);
|
|
36
38
|
|
|
39
|
+
const {
|
|
40
|
+
called: subFilterItemsCalled,
|
|
41
|
+
data: subFilterItems,
|
|
42
|
+
loading: subFilterItemsLoading
|
|
43
|
+
} = useQuery(getSubFiltersQuery,
|
|
44
|
+
{
|
|
45
|
+
fetchPolicy: 'cache-and-network',
|
|
46
|
+
nextFetchPolicy: 'cache-first'
|
|
47
|
+
});
|
|
48
|
+
|
|
37
49
|
const attributeCodes = useMemo(
|
|
38
50
|
() => filters.map(({ attribute_code }) => attribute_code),
|
|
39
51
|
[filters]
|
|
@@ -236,10 +248,34 @@ export const useFilterSidebar = props => {
|
|
|
236
248
|
closeDrawer();
|
|
237
249
|
}, [closeDrawer]);
|
|
238
250
|
|
|
239
|
-
const handleApply = useCallback(() => {
|
|
251
|
+
const handleApply = useCallback((...args) => {
|
|
252
|
+
const group = args[0];
|
|
253
|
+
const item = args[1];
|
|
254
|
+
|
|
255
|
+
// REMOVE ACTIVE FILTER
|
|
256
|
+
if (group.includes('card_release')) {
|
|
257
|
+
const subFilter = group.replace("card_release", "card_set");
|
|
258
|
+
filterApi.removeGroup({ group: subFilter });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (group.includes('card_set')) {
|
|
262
|
+
const subFilter = group.replace("card_set", "card_release");
|
|
263
|
+
filterApi.removeGroup({ group: subFilter });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (group.includes('card_game')) {
|
|
267
|
+
if (allActiveFilters && allActiveFilters.size > 0) {
|
|
268
|
+
allActiveFilters.forEach((value, key) => {
|
|
269
|
+
if (key !== 'card_game') {
|
|
270
|
+
filterApi.removeGroup({ group: key });
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
240
276
|
setIsApplying(true);
|
|
241
277
|
handleClose();
|
|
242
|
-
}, [handleClose]);
|
|
278
|
+
}, [handleClose, filterApi, allActiveFilters]);
|
|
243
279
|
|
|
244
280
|
const handleReset = useCallback(() => {
|
|
245
281
|
filterApi.clear();
|
|
@@ -298,6 +334,7 @@ export const useFilterSidebar = props => {
|
|
|
298
334
|
filterApi,
|
|
299
335
|
filterItems,
|
|
300
336
|
filterKeys,
|
|
337
|
+
subFilterItems,
|
|
301
338
|
filterNames,
|
|
302
339
|
filterFrontendInput,
|
|
303
340
|
filterState,
|
package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js
CHANGED
|
@@ -13,10 +13,10 @@ import RadioGroup from '@magento/venia-ui/lib/components/RadioGroup';
|
|
|
13
13
|
import FilterItemRadio from './filterItemRadio';
|
|
14
14
|
import { useFieldApi } from 'informed';
|
|
15
15
|
import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInformedFieldStateWrapper';
|
|
16
|
+
import FilterBlock from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock';
|
|
16
17
|
|
|
17
18
|
const FilterItemRadioGroup = props => {
|
|
18
|
-
const { filterApi, filterState, group, isSubFilter, items, onApply, labels,isListExpanded = true, itemCountToShow = 5 } = props;
|
|
19
|
-
|
|
19
|
+
const { filterApi, subFilterItems, allowedSubFilters, subFilter, filterState, group, isSubFilter, items, onApply, labels,isListExpanded = true, itemCountToShow = 5 } = props;
|
|
20
20
|
const radioItems = useMemo(() => {
|
|
21
21
|
return items.map((item,index) => {
|
|
22
22
|
if (!isListExpanded && index >= itemCountToShow) {
|
|
@@ -24,19 +24,57 @@ const FilterItemRadioGroup = props => {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const code = `item-${group}-${item.value}`;
|
|
27
|
+
|
|
28
|
+
if (allowedSubFilters.length && !allowedSubFilters.includes(item.title)) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let newAllowedSubFilters = [];
|
|
33
|
+
|
|
34
|
+
if (subFilter && subFilterItems) {
|
|
35
|
+
const result = subFilterItems.find(item => item.attribute_code === "card_release");
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// Ambil options jika ditemukan
|
|
40
|
+
const options = result ? result.options : [];
|
|
41
|
+
const option = options ? options.find(option => option.option_label === item.title) : [];
|
|
42
|
+
if (option) {
|
|
43
|
+
newAllowedSubFilters = option.sub_option_labels;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
27
48
|
return (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
<>
|
|
50
|
+
<FilterItemRadio
|
|
51
|
+
key={code}
|
|
52
|
+
filterApi={filterApi}
|
|
53
|
+
filterState={filterState}
|
|
54
|
+
group={group}
|
|
55
|
+
item={item}
|
|
56
|
+
onApply={onApply}
|
|
57
|
+
labels={labels}
|
|
58
|
+
/>
|
|
59
|
+
{subFilter && <FilterBlock
|
|
60
|
+
key={subFilter.key}
|
|
61
|
+
filterApi={subFilter.filterApi}
|
|
62
|
+
filterState={subFilter.filterState}
|
|
63
|
+
filterFrontendInput={subFilter.filterFrontendInput}
|
|
64
|
+
group={subFilter.group}
|
|
65
|
+
allowedSubFilters={newAllowedSubFilters}
|
|
66
|
+
subFilterItems={subFilterItems}
|
|
67
|
+
isSubFilter={true}
|
|
68
|
+
items={subFilter.items}
|
|
69
|
+
name={''}
|
|
70
|
+
onApply={subFilter.onApply}
|
|
71
|
+
initialOpen={true}
|
|
72
|
+
/>}
|
|
73
|
+
{/* {subFilterBlock} */}
|
|
74
|
+
</>
|
|
37
75
|
);
|
|
38
76
|
});
|
|
39
|
-
}, [filterApi, filterState, group, items, labels, onApply,isListExpanded,itemCountToShow]);
|
|
77
|
+
}, [filterApi, allowedSubFilters, subFilter, filterState, group, items, labels, onApply,isListExpanded,itemCountToShow]);
|
|
40
78
|
|
|
41
79
|
const fieldValue = useMemo(() => {
|
|
42
80
|
if (filterState) {
|
|
@@ -22,7 +22,9 @@ const FilterList = props => {
|
|
|
22
22
|
filterFrontendInput,
|
|
23
23
|
isSubFilter,
|
|
24
24
|
filterItems,
|
|
25
|
-
|
|
25
|
+
subFilterItems,
|
|
26
|
+
allowedSubFilters,
|
|
27
|
+
subFilter,
|
|
26
28
|
name,
|
|
27
29
|
group,
|
|
28
30
|
itemCountToShow,
|
|
@@ -152,6 +154,8 @@ const FilterList = props => {
|
|
|
152
154
|
const key = `item-${group}`;
|
|
153
155
|
|
|
154
156
|
const cardSetGroup = group.replace('card_release', 'card_set');
|
|
157
|
+
|
|
158
|
+
// const mewSubFilterBlock = subFilterBlock;
|
|
155
159
|
|
|
156
160
|
return (
|
|
157
161
|
<li
|
|
@@ -164,6 +168,9 @@ const FilterList = props => {
|
|
|
164
168
|
filterState={filterState}
|
|
165
169
|
group={group}
|
|
166
170
|
name={name}
|
|
171
|
+
subFilterItems={subFilterItems}
|
|
172
|
+
subFilter={subFilter}
|
|
173
|
+
allowedSubFilters={allowedSubFilters}
|
|
167
174
|
isSubFilter={isSubFilter}
|
|
168
175
|
items={items}
|
|
169
176
|
onApply={onApply}
|
|
@@ -171,7 +178,6 @@ const FilterList = props => {
|
|
|
171
178
|
isListExpanded={isListExpanded}
|
|
172
179
|
itemCountToShow={itemCountToShow}
|
|
173
180
|
/>
|
|
174
|
-
{group.includes('card_release') && subFilterBlock}
|
|
175
181
|
</li>
|
|
176
182
|
);
|
|
177
183
|
// }
|
|
@@ -20,7 +20,9 @@ const FilterBlock = props => {
|
|
|
20
20
|
filterState,
|
|
21
21
|
filterFrontendInput,
|
|
22
22
|
filterItems,
|
|
23
|
-
|
|
23
|
+
subFilter,
|
|
24
|
+
subFilterItems,
|
|
25
|
+
allowedSubFilters,
|
|
24
26
|
isSubFilter,
|
|
25
27
|
group,
|
|
26
28
|
items,
|
|
@@ -76,8 +78,10 @@ const FilterBlock = props => {
|
|
|
76
78
|
filterState={filterState}
|
|
77
79
|
name={name}
|
|
78
80
|
isSubFilter={isSubFilter}
|
|
79
|
-
|
|
81
|
+
subFilter={subFilter}
|
|
82
|
+
allowedSubFilters={allowedSubFilters}
|
|
80
83
|
filterItems={filterItems}
|
|
84
|
+
subFilterItems={subFilterItems}
|
|
81
85
|
filterFrontendInput={filterFrontendInput}
|
|
82
86
|
group={group}
|
|
83
87
|
items={items}
|
|
@@ -28,6 +28,7 @@ const FilterSidebar = props => {
|
|
|
28
28
|
filterItems,
|
|
29
29
|
filterNames,
|
|
30
30
|
filterFrontendInput,
|
|
31
|
+
subFilterItems,
|
|
31
32
|
filterState,
|
|
32
33
|
handleApply,
|
|
33
34
|
handleReset
|
|
@@ -102,25 +103,26 @@ const FilterSidebar = props => {
|
|
|
102
103
|
if (!hideFilters.includes(group) && groupName) {
|
|
103
104
|
|
|
104
105
|
// if (!allowedFiltersArr?.length && group != "category_uid" || allowedFiltersArr?.length && allowedFiltersArr.includes(group)) {
|
|
105
|
-
let
|
|
106
|
+
let subFilter = null;
|
|
106
107
|
if (group.includes('card_release')) {
|
|
107
108
|
const subGroup = group.replace('card_release', 'card_set');
|
|
108
109
|
const subBlockState = filterState.get(subGroup);
|
|
109
110
|
const subFrontendInput = filterFrontendInput.get(subGroup);
|
|
110
111
|
const subFilterItems = filterItems.get(subGroup);
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
key
|
|
114
|
-
filterApi
|
|
115
|
-
filterState
|
|
116
|
-
filterFrontendInput
|
|
117
|
-
group
|
|
118
|
-
isSubFilter
|
|
119
|
-
items
|
|
120
|
-
name
|
|
121
|
-
onApply
|
|
122
|
-
initialOpen
|
|
123
|
-
|
|
113
|
+
subFilter = {
|
|
114
|
+
key: subGroup,
|
|
115
|
+
filterApi: filterApi,
|
|
116
|
+
filterState: subBlockState,
|
|
117
|
+
filterFrontendInput: subFrontendInput,
|
|
118
|
+
group: subGroup,
|
|
119
|
+
isSubFilter: true,
|
|
120
|
+
items: subFilterItems,
|
|
121
|
+
name: '',
|
|
122
|
+
onApply: handleApplyFilter,
|
|
123
|
+
initialOpen: true
|
|
124
|
+
};
|
|
125
|
+
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
return (
|
|
@@ -128,10 +130,12 @@ const FilterSidebar = props => {
|
|
|
128
130
|
key={group}
|
|
129
131
|
filterApi={filterApi}
|
|
130
132
|
filterState={blockState}
|
|
133
|
+
allowedSubFilters={[]}
|
|
131
134
|
filterFrontendInput={frontendInput}
|
|
132
135
|
group={group}
|
|
136
|
+
subFilterItems={subFilterItems?.subFilters}
|
|
133
137
|
filterItems={filterItems}
|
|
134
|
-
|
|
138
|
+
subFilter={subFilter}
|
|
135
139
|
items={items}
|
|
136
140
|
name={groupName}
|
|
137
141
|
onApply={group == "category_uid" ? handleCategoryApplyFilter : handleApplyFilter}
|
|
@@ -147,6 +151,7 @@ const FilterSidebar = props => {
|
|
|
147
151
|
filterNames,
|
|
148
152
|
filterFrontendInput,
|
|
149
153
|
filterState,
|
|
154
|
+
subFilterItems,
|
|
150
155
|
filterCountToOpen,
|
|
151
156
|
handleApplyFilter
|
|
152
157
|
]
|