@riosst100/pwa-marketplace 3.0.9 → 3.1.1

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": "3.0.9",
4
+ "version": "3.1.1",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -4,7 +4,7 @@ import { useStyle } from '@magento/venia-ui/lib/classify';
4
4
  import { Link } from 'react-router-dom';
5
5
 
6
6
  const FilterTopItem = props => {
7
- const { setFilterBy, filterBy, filterApi, group, item, onApply, labels, activeFilters, search } = props;
7
+ const { selectedOption, setFilterBy, filterBy, filterApi, group, item, onApply, labels, activeFilters, search } = props;
8
8
  const { removeGroup, toggleItem, clear } = filterApi;
9
9
  const { title, value } = item;
10
10
 
@@ -76,6 +76,7 @@ const FilterTopItem = props => {
76
76
 
77
77
  // console.log('--filterSearch--')
78
78
  // console.log(filterSearch)
79
+ // console.log('pathname',pathname)
79
80
 
80
81
  const element = group == "filterby" ? (
81
82
  filterBy == value ? (
@@ -84,7 +85,7 @@ const FilterTopItem = props => {
84
85
  <span className={classes.item} onClick={() => setFilterBy(value)}>{title}</span>
85
86
  )
86
87
  ) : group == "category" ? (
87
- <Link className={classes.item} to={'/'+value}>{title}</Link>
88
+ selectedOption == value ? <span className={classes.item}><b>{title}</b></span> : <Link className={classes.item} to={'/'+value}>{title}</Link>
88
89
  ) : value == "shopby_all" ? (
89
90
  <Link className={classes.item} to={search ? filterSearch + '&show_more=' + group : '?show_more=' + group}>{title}</Link>
90
91
  ) : group == "shopby" || group == "shopby_with_all" ? (
@@ -5,6 +5,7 @@ import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInforme
5
5
  import { useStyle } from '@magento/venia-ui/lib/classify';
6
6
  import defaultClasses from './filterTopItemGroup.module.css';
7
7
  import CurrentTopFilter from '@riosst100/pwa-marketplace/src/components/FilterTop/CurrentTopFilters/currentTopFilter';
8
+ import { useLocation } from 'react-router-dom';
8
9
 
9
10
  const FilterTopItemGroup = props => {
10
11
  const { customFiltersData, setFilterBy, filterBy, filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState, search } = props;
@@ -15,6 +16,9 @@ const FilterTopItemGroup = props => {
15
16
  const { removeItem } = filterApi;
16
17
  const activeFilters = [];
17
18
 
19
+ const location = useLocation();
20
+ const { pathname } = location
21
+
18
22
  // Current Filters
19
23
  const filterElements = useMemo(() => {
20
24
  const elements = [];
@@ -41,11 +45,19 @@ const FilterTopItemGroup = props => {
41
45
  }, [originalFilterState, removeItem, onApply]);
42
46
 
43
47
  const radioItems = useMemo(() => {
48
+ let selected = items.find(item => pathname.includes(item.value));
49
+ if (!selected) {
50
+ selected = items[0];
51
+ }
52
+
53
+ const selectedOption = selected ? selected.value : null;
54
+
44
55
  return items.map(item => {
45
56
  const code = `item-${group}-${item.value}`;
46
57
  return (
47
58
  <FilterTopItem
48
59
  key={code}
60
+ selectedOption={selectedOption}
49
61
  setFilterBy={setFilterBy}
50
62
  filterBy={filterBy}
51
63
  filterApi={filterApi}
@@ -59,7 +71,7 @@ const FilterTopItemGroup = props => {
59
71
  />
60
72
  );
61
73
  });
62
- }, [filterApi, filterState, group, items, labels, onApply]);
74
+ }, [pathname, filterApi, filterState, group, items, labels, onApply]);
63
75
 
64
76
  const fieldValue = useMemo(() => {
65
77
  if (filterState) {
@@ -87,7 +99,9 @@ const FilterTopItemGroup = props => {
87
99
 
88
100
 
89
101
  const customFilterData = useMemo(() => {
90
- const filtered = customFiltersData.filters.filter(item => item.attribute_code === group);
102
+ const filterNull = customFiltersData.filters.filter(item => item !== null);
103
+ // console.log('customFiltersData',customFiltersData)
104
+ const filtered = filterNull.filter(item => item.attribute_code === group);
91
105
  // console.log('filtered ' + group,filtered);
92
106
  if (filtered) {
93
107
  // console.log('filtered ' + group,filtered);
@@ -0,0 +1,27 @@
1
+ .submenuColumn {
2
+ /* composes: max-w-[235px] from global; */
3
+ composes: p-5 from global;
4
+ }
5
+
6
+ .heading {
7
+ /* composes: font-medium from global; */
8
+ font-weight: 600;
9
+ }
10
+
11
+ .link {
12
+ composes: whitespace-nowrap from global;
13
+ composes: focus_underline from global;
14
+ composes: hover_underline from global;
15
+ }
16
+
17
+ .linkActive {
18
+ composes: underline from global;
19
+ }
20
+
21
+ .submenuChild {
22
+ composes: mt-0 from global;
23
+ }
24
+
25
+ .submenuChildItem {
26
+ composes: mb-3 from global;
27
+ }
@@ -314,7 +314,7 @@ const CategoryContent = props => {
314
314
  <>
315
315
  {/* {currentFilter && <AlphaFilter isSingles={isSingles} items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />} */}
316
316
  {!currentFilter && <CustomSubCategory categoryName={category ? category.name : null} customSubCategory={category ? category.custom_subcategory : null} />}
317
- {shopby != "gauge" && category?.name != "Collectible Card Games" ? <SubCategory parent={parent} children={children} /> : ''}
317
+ {/* {shopby != "gauge" && category?.name != "Collectible Card Games" ? <SubCategory parent={parent} children={children} /> : ''} */}
318
318
  </>
319
319
  {/* ) : ( */}
320
320
  <>
@@ -1,8 +1,8 @@
1
1
  import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_CUSTOM_FILTERS = gql`
4
- query GetCustomFilters($search: String, $filterBy: String, $shopby: String, $category: String, $filters: ProductAttributeFilterInput) {
5
- customSubFilters(search: $search, filterBy: $filterBy, shopby: $shopby, category: $category, filters: $filters) {
4
+ query GetCustomFilters($search: String, $filterBy: String, $shopby: String, $categoryId: String, $category: String, $filters: ProductAttributeFilterInput) {
5
+ customSubFilters(search: $search, filterBy: $filterBy, shopby: $shopby, categoryId: $categoryId, category: $category, filters: $filters) {
6
6
  filter_id
7
7
  filters {
8
8
  label
@@ -78,6 +78,7 @@ export const useFilterTop = props => {
78
78
  variables: {
79
79
  filters: newFilters,
80
80
  category: category?.url_path,
81
+ categoryId: category?.uid,
81
82
  shopby: shopby,
82
83
  filterBy: filterBy,
83
84
  search: search
@@ -183,27 +184,36 @@ export const useFilterTop = props => {
183
184
  const frontendInput = new Map();
184
185
  const itemsByGroup = new Map();
185
186
  const customFiltersMap = [];
187
+
188
+ // console.log('customFiltersData',customFiltersData)
186
189
 
187
190
  if (customFiltersData && customFiltersData.filters) {
188
- customFiltersData.filters.map(({ attribute_code, options }, index) => {
191
+ customFiltersData.filters.map((data, index) => {
189
192
 
190
- customFiltersMap.push(attribute_code)
191
-
193
+ if (data) {
194
+ // console.log(data)
195
+ const { attribute_code, options } = data;
192
196
 
193
- const items = [];
197
+ // console.log(attribute_code)
194
198
 
195
- names.set(attribute_code, '');
196
- frontendInput.set(attribute_code, null);
199
+ customFiltersMap.push(attribute_code)
200
+
197
201
 
198
- // add filter key permutations
199
- keys.add(`${attribute_code}[filter]`);
202
+ const items = [];
200
203
 
201
- // add items
202
- for (const { label, value, path } of options) {
203
- items.push({ title: stripHtml(label), value, path });
204
- }
204
+ names.set(attribute_code, '');
205
+ frontendInput.set(attribute_code, null);
206
+
207
+ // add filter key permutations
208
+ keys.add(`${attribute_code}[filter]`);
205
209
 
206
- itemsByGroup.set(attribute_code, items);
210
+ // add items
211
+ for (const { label, value, path } of options) {
212
+ items.push({ title: stripHtml(label), value, path });
213
+ }
214
+
215
+ itemsByGroup.set(attribute_code, items);
216
+ }
207
217
  })
208
218
  }
209
219