@riosst100/pwa-marketplace 1.5.8 → 1.5.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "1.5.8",
4
+ "version": "1.5.9",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -26,9 +26,6 @@ const CustomFilter = props => {
26
26
  }
27
27
  );
28
28
 
29
- console.log(group)
30
- console.log(item)
31
-
32
29
  const normalizedData = [
33
30
  {
34
31
  'label': 'Sealed Products',
@@ -140,8 +140,8 @@ export const useFilterSidebar = props => {
140
140
  // Add frontend input type
141
141
  frontendInput.set(group, null);
142
142
  // add items
143
- for (const { label, value } of options) {
144
- items.push({ title: stripHtml(label), value });
143
+ for (const { label, value, path } of options) {
144
+ items.push({ title: stripHtml(label), value, path });
145
145
  }
146
146
  }
147
147
  itemsByGroup.set(group, items);
@@ -106,7 +106,8 @@ export const useCategoryContent = props => {
106
106
  children && children.map((category, index) => {
107
107
  filterOptions.push({
108
108
  'label': category.name,
109
- 'value': category.uid
109
+ 'value': category.uid,
110
+ 'path': category.url_path
110
111
  });
111
112
  });
112
113
 
@@ -117,6 +118,7 @@ export const useCategoryContent = props => {
117
118
  attribute_code: filter.attribute_code,
118
119
  count: filter.count,
119
120
  label: label,
121
+ position: filter.position,
120
122
  options: filterOptions.length ? filterOptions : filter.options
121
123
  };
122
124
 
@@ -71,7 +71,8 @@ FilterItem.propTypes = {
71
71
  group: string.isRequired,
72
72
  item: shape({
73
73
  title: string.isRequired,
74
- value: oneOfType([number, string]).isRequired
74
+ value: oneOfType([number, string]).isRequired,
75
+ path: string
75
76
  }).isRequired,
76
77
  onChange: func
77
78
  };
@@ -26,9 +26,11 @@ const FilterItemRadio = props => {
26
26
 
27
27
  const handleOnchange = useCallback(
28
28
  e => {
29
- removeGroup({ group });
30
- if (e.target.value === item.value) {
31
- toggleItem({ group, item });
29
+ if (group != "category_uid") {
30
+ removeGroup({ group });
31
+ if (e.target.value === item.value) {
32
+ toggleItem({ group, item });
33
+ }
32
34
  }
33
35
  if (typeof onApply === 'function') {
34
36
  onApply(group, item);
@@ -67,7 +69,8 @@ FilterItemRadio.propTypes = {
67
69
  item: shape({
68
70
  title: string.isRequired,
69
71
  value: oneOfType([number, string]).isRequired,
70
- label: string
72
+ label: string,
73
+ path: string
71
74
  }).isRequired,
72
75
  onApply: func,
73
76
  labels: instanceOf(Map).isRequired
@@ -76,7 +76,8 @@ FilterItemRadioGroup.propTypes = {
76
76
  items: arrayOf(
77
77
  shape({
78
78
  title: string.isRequired,
79
- value: oneOfType([number, string]).isRequired
79
+ value: oneOfType([number, string]).isRequired,
80
+ path: string
80
81
  })
81
82
  ).isRequired,
82
83
  onApply: func,
@@ -10,6 +10,8 @@ import FilterBlock from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/
10
10
  import defaultClasses from './filterSidebar.module.css';
11
11
  import { Filter } from 'iconsax-react';
12
12
  import cn from 'classnames';
13
+ import { useHistory } from 'react-router-dom';
14
+
13
15
 
14
16
  const SCROLL_OFFSET = 150;
15
17
 
@@ -52,6 +54,30 @@ const FilterSidebar = props => {
52
54
  [handleApply, filterRef]
53
55
  );
54
56
 
57
+ const history = useHistory();
58
+
59
+ const handleCategoryApplyFilter = useCallback(
60
+ (...args) => {
61
+ // const filterElement = filterRef.current;
62
+ // if (
63
+ // filterElement &&
64
+ // typeof filterElement.getBoundingClientRect === 'function'
65
+ // ) {
66
+ // const filterTop = filterElement.getBoundingClientRect().top;
67
+ // const windowScrollY =
68
+ // window.scrollY + filterTop - SCROLL_OFFSET;
69
+ // window.scrollTo(0, windowScrollY);
70
+ // }
71
+
72
+ history.push('/'+args[1].path+'.html');
73
+
74
+ if (args[0] != "category_uid") {
75
+ handleApply(...args);
76
+ }
77
+ },
78
+ [handleApply, filterRef]
79
+ );
80
+
55
81
  const allowedFiltersArr = [];
56
82
 
57
83
  allowedFilters.length && allowedFilters.map((val, index) => {
@@ -65,6 +91,8 @@ const FilterSidebar = props => {
65
91
  const groupName = filterNames.get(group);
66
92
  const frontendInput = filterFrontendInput.get(group);
67
93
  if (!allowedFiltersArr.length && group != "category_uid" || allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
94
+
95
+
68
96
  return (
69
97
  <FilterBlock
70
98
  key={group}
@@ -74,7 +102,7 @@ const FilterSidebar = props => {
74
102
  group={group}
75
103
  items={items}
76
104
  name={groupName}
77
- onApply={handleApplyFilter}
105
+ onApply={group == "category_uid" ? handleCategoryApplyFilter : handleApplyFilter}
78
106
  initialOpen={iteration < filterCountToOpen}
79
107
  />
80
108
  );