@riosst100/pwa-marketplace 1.9.4 → 1.9.5

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.9.4",
4
+ "version": "1.9.5",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -31,7 +31,7 @@ const CurrentTopFilter = props => {
31
31
  }
32
32
  );
33
33
 
34
- return group != "trains" && group != "toys_franchise" && group != "toys_brands" && group != "trains_gauge" && group != "category" && group != "shopby" ? (
34
+ return group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "filterby" && group != "trains" && group != "toys_franchise" && group != "toys_brands" && group != "trains_gauge" && group != "category" && group != "shopby" ? (
35
35
  <span className={classes.item} data-cy="CurrentTopFilter-root">
36
36
  <Trigger
37
37
  action={handleClick}
@@ -13,13 +13,17 @@ const FilterBlockList = props => {
13
13
  onApply,
14
14
  filterNames,
15
15
  originalFilterState,
16
- search
16
+ search,
17
+ setFilterBy,
18
+ filterBy
17
19
  } = props;
18
20
 
19
21
  const itemElements = useMemo(() => {
20
22
  const key = `item-${group}`;
21
23
  return (
22
24
  <FilterTopItemGroup
25
+ setFilterBy={setFilterBy}
26
+ filterBy={filterBy}
23
27
  filterApi={filterApi}
24
28
  filterState={filterState}
25
29
  group={group}
@@ -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 { filterApi, group, item, onApply, labels, activeFilters, search } = props;
7
+ const { setFilterBy, filterBy, filterApi, group, item, onApply, labels, activeFilters, search } = props;
8
8
  const { removeGroup, toggleItem } = filterApi;
9
9
  const { title, value } = item;
10
10
 
@@ -20,6 +20,7 @@ const FilterTopItem = props => {
20
20
  toggleItem({ group, item });
21
21
  }
22
22
  }
23
+ setFilterBy('')
23
24
  if (typeof onApply === 'function') {
24
25
  onApply(group, item);
25
26
  }
@@ -27,8 +28,16 @@ const FilterTopItem = props => {
27
28
  [group, item, onApply, removeGroup, toggleItem]
28
29
  );
29
30
 
30
- const element = group == "category" ? (
31
+ const element = group == "filterby" ? (
32
+ filterBy == value ? (
33
+ <span className={classes.item}><b>{title}</b></span>
34
+ ) : (
35
+ <span className={classes.item} onClick={() => setFilterBy(value)}>{title}</span>
36
+ )
37
+ ) : group == "category" ? (
31
38
  <Link className={classes.item} to={'/'+value}>{title}</Link>
39
+ ) : value == "all_brands" ? (
40
+ <Link className={classes.item} to={search ? search + '&shopby=' + 'all_brands' : '?shopby=' + 'all_brands'}>{title}</Link>
32
41
  ) : group == "shopby" || group == "shopby_with_all" ? (
33
42
  <Link className={classes.item} to={search ? search + '&shopby=' + value : '?shopby=' + value}>{title}</Link>
34
43
  ) : (
@@ -7,7 +7,7 @@ import defaultClasses from './filterTopItemGroup.module.css';
7
7
  import CurrentTopFilter from '@riosst100/pwa-marketplace/src/components/FilterTop/CurrentTopFilters/currentTopFilter';
8
8
 
9
9
  const FilterTopItemGroup = props => {
10
- const { filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState, search } = props;
10
+ const { setFilterBy, filterBy, filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState, search } = props;
11
11
 
12
12
  const classes = useStyle(defaultClasses, props.classes);
13
13
 
@@ -46,6 +46,8 @@ const FilterTopItemGroup = props => {
46
46
  return (
47
47
  <FilterTopItem
48
48
  key={code}
49
+ setFilterBy={setFilterBy}
50
+ filterBy={filterBy}
49
51
  filterApi={filterApi}
50
52
  filterState={filterState}
51
53
  group={group}
@@ -85,7 +87,7 @@ const FilterTopItemGroup = props => {
85
87
  <div className={classes.root}>
86
88
  {radioItems}
87
89
  {filterElements && filterElements.length > 10 ? <span className={classes.item}><b>More Item</b></span> : ''}
88
- {filterElements && filterElements.length ? filterElements : group != "trains" && group != "trains_gauge" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "shopby" ? (<span className={classes.item}><b>All</b></span>) : ''}
90
+ {filterElements && filterElements.length ? filterElements : group && group != "toys_character" && group != "toys_product_series" && group != "toys_scale" && group != "toys_product_line" && group != "trains" && group != "trains_gauge" && group != "toys_franchise" && group != "toys_brands" && group != "category" && group != "filterby" && group != "shopby" ? (<span className={classes.item}><b>All</b></span>) : ''}
89
91
  </div>
90
92
  );
91
93
  };
@@ -23,7 +23,10 @@ const SCROLL_OFFSET = 150;
23
23
  */
24
24
  const FilterTop = props => {
25
25
  const { shopby, filters, filterCountToOpen, allowedFilters, category } = props;
26
- const talonProps = useFilterTop({ shopby, filters, category });
26
+ const [filterBy, setFilterBy] = useState('');
27
+
28
+ // console.log(filterBy)
29
+ const talonProps = useFilterTop({ shopby, filters, category, filterBy, setFilterBy });
27
30
  const {
28
31
  filterApi,
29
32
  filterItems,
@@ -116,6 +119,8 @@ const FilterTop = props => {
116
119
  return (
117
120
  <FilterTopBlock
118
121
  key={group}
122
+ setFilterBy={setFilterBy}
123
+ filterBy={filterBy}
119
124
  filterNames={filterNames}
120
125
  filterApi={filterApi}
121
126
  filterState={blockState}
@@ -25,7 +25,9 @@ const FilterTopBlock = props => {
25
25
  filterNames,
26
26
  initialOpen,
27
27
  originalFilterState,
28
- search
28
+ search,
29
+ setFilterBy,
30
+ filterBy
29
31
  } = props;
30
32
 
31
33
  const { formatMessage } = useIntl();
@@ -37,6 +39,8 @@ const FilterTopBlock = props => {
37
39
 
38
40
  const list = <Form>
39
41
  <FilterBlockList
42
+ setFilterBy={setFilterBy}
43
+ filterBy={filterBy}
40
44
  filterApi={filterApi}
41
45
  filterState={filterState}
42
46
  originalFilterState={originalFilterState}
@@ -56,6 +56,11 @@ export const useCategory = props => {
56
56
 
57
57
  const sortProps = useSort({ sortFromSearch: false });
58
58
  const [currentSort] = sortProps;
59
+
60
+ const { pathname } = useLocation();
61
+
62
+ const pathnameArr = pathname.split('/');
63
+ const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
59
64
 
60
65
  // Keep track of the sort criteria so we can tell when they change.
61
66
  const previousSort = useRef(currentSort);
@@ -132,7 +137,9 @@ export const useCategory = props => {
132
137
 
133
138
  // Use the category uid for the current category page regardless of the
134
139
  // applied filters. Follow-up in PWA-404.
135
- newFilters['category_uid'] = { eq: id };
140
+ if (categoryUrlKey != "brands" && categoryUrlKey != "franchise") {
141
+ newFilters['category_uid'] = { eq: id };
142
+ }
136
143
 
137
144
  runQuery({
138
145
  variables: {
@@ -93,8 +93,8 @@ const CategoryContent = props => {
93
93
  history.replace('/cards/non-sports-cards/comics.html')
94
94
  }
95
95
 
96
- if (urlKey == "age-level" || urlKey == "lego" || urlKey == "minifigures" || urlKey == "sub-theme" || urlKey == "theme" || urlKey == "interest") {
97
- history.replace('/lego-toys/lego/sets.html')
96
+ if (urlKey == "lego") {
97
+ history.replace('/lego/lego-sets.html')
98
98
  }
99
99
  }
100
100
  }, [category]);
@@ -266,7 +266,7 @@ const CategoryContent = props => {
266
266
  if (label == "Singles") {
267
267
  isSingles = true;
268
268
  }
269
- if (key == "toys_franchise" && urlKey == "franchise" || key == "toys_brands" && urlKey == "brands" || virtualCategoryFilters.includes(key)) {
269
+ if (key == "toys_product_line" && urlKey == "brands" || key == "toys_product_line" && urlKey == "franchise" || key == "toys_franchise" && urlKey == "brands" || key == "toys_franchise" && urlKey == "franchise" || key == "toys_brands" && urlKey == "franchise" || key == "toys_brands" && urlKey == "brands" || virtualCategoryFilters.includes(key)) {
270
270
  activeFilters.push(
271
271
  {
272
272
  'label': label,
@@ -286,7 +286,7 @@ const CategoryContent = props => {
286
286
 
287
287
  let title = activeFilters && activeFilters.length ? (
288
288
  activeFilters.length > 1 ?
289
- activeFilters.map(u => u.label).join(': ')
289
+ activeFilters[activeFilters.length - 1].label
290
290
  : currentFilter
291
291
  ) : categoryName;
292
292
 
@@ -313,8 +313,9 @@ const CategoryContent = props => {
313
313
  {/* {activeFilters.size <= 0 && category && category.custom_landing_page ? ( */}
314
314
  <>
315
315
  {currentFilter && <AlphaFilter isSingles={isSingles} items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
316
- {shopby != "gauge" ? <SubCategory parent={parent} children={children} /> : ''}
317
316
  {!currentFilter && <CustomSubCategory categoryName={category ? category.name : null} customSubCategory={category ? category.custom_subcategory : null} />}
317
+ {shopby != "gauge" ? <SubCategory parent={parent} children={children} /> : ''}
318
+
318
319
  </>
319
320
  {/* ) : ( */}
320
321
  <>
@@ -30,7 +30,7 @@ const CustomSubmenuColumn = props => {
30
30
  );
31
31
 
32
32
  return (
33
- <li key={index} className={cn(classes.submenuChildItem, 'mb-1.5')}>
33
+ <li key={index} className={cn(classes.submenuChildItem, 'mt-4')}>
34
34
  <Link
35
35
  className={classes.link}
36
36
  data-cy="MegaMenu-CustomSubmenuColumn-link"
@@ -47,10 +47,29 @@ const CustomSubmenuColumn = props => {
47
47
  );
48
48
  });
49
49
 
50
- children = <ul className={cn(classes.submenuChild, 'pt-1')}>{childrenItems}</ul>;
50
+ children = <>
51
+ <ul className={cn(classes.submenuChild, 'pt-1')}><span className={classes.heading}>Categories</span>{childrenItems}</ul>
52
+ </>;
51
53
  }
52
54
 
53
55
  return children;
56
+ // return (
57
+ // <div className={classes.submenuColumn}>
58
+ // <Link
59
+ // // {...keyboardProps}
60
+ // className={classes.link}
61
+ // data-cy="MegaMenu-SubmenuColumn-link"
62
+ // // to={categoryUrl}
63
+ // // onClick={() => {
64
+ // // handleCloseSubMenu();
65
+ // // onNavigate();
66
+ // // }}
67
+ // >
68
+ // <span className={classes.heading}>{category.name}</span>
69
+ // </Link>
70
+ // {children}
71
+ // </div>
72
+ // );
54
73
  };
55
74
 
56
75
  export default CustomSubmenuColumn;
@@ -7,6 +7,7 @@ import { useStyle } from '@magento/venia-ui/lib/classify';
7
7
  import defaultClasses from './submenu.module.css';
8
8
  import SubmenuColumn from './submenuColumn';
9
9
  import ShopByColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn';
10
+ import CustomSubmenuColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/customSubmenuColumn';
10
11
  import cn from 'classnames';
11
12
 
12
13
  /**
@@ -44,6 +45,29 @@ const Submenu = props => {
44
45
  ? classes.submenu_active
45
46
  : classes.submenu_inactive;
46
47
 
48
+ // const subMenus = items.map((category, index) => {
49
+ // const keyboardProps =
50
+ // index === items.length - 1 ? talonProps.keyboardProps : {};
51
+ // return (
52
+ // <SubmenuColumn
53
+ // index={index}
54
+ // keyboardProps={keyboardProps}
55
+ // key={category.uid}
56
+ // category={category}
57
+ // categoryUrlSuffix={categoryUrlSuffix}
58
+ // onNavigate={onNavigate}
59
+ // arrow={arrow}
60
+ // handleCloseSubMenu={handleCloseSubMenu}
61
+ // />
62
+ // );
63
+ // });
64
+ // const subMenus = <CustomSubmenuColumn
65
+ // categoryUrlSuffix={categoryUrlSuffix}
66
+ // onNavigate={onNavigate}
67
+ // arrow={arrow}
68
+ // handleCloseSubMenu={handleCloseSubMenu}
69
+ // customMenuItems={items}
70
+ // />;
47
71
  const subMenus = items.map((category, index) => {
48
72
  const keyboardProps =
49
73
  index === items.length - 1 ? talonProps.keyboardProps : {};
@@ -61,7 +85,16 @@ const Submenu = props => {
61
85
  );
62
86
  });
63
87
 
64
- // const shopByItems = [
88
+ // const shopByItems2 = [
89
+ // {
90
+ // name: 'Shop By Franchise',
91
+ // items: [
92
+ // {
93
+ // name: 'Hasbro',
94
+ // url: '/'
95
+ // }
96
+ // ]
97
+ // },
65
98
  // {
66
99
  // name: 'Shop By Franchise',
67
100
  // items: [
@@ -101,10 +134,12 @@ const Submenu = props => {
101
134
  <div
102
135
  className={cn(
103
136
  classes.submenuItems,
104
- 'grid grid-cols-4',
137
+ 'grid grid-cols-6',
105
138
  )}
106
139
  >
107
- {subMenus}
140
+ {shopByItems.length ? (<div className={classes.submenuColumn}>
141
+ {subMenus}
142
+ </div>) : subMenus}
108
143
  {shopBy}
109
144
  </div>
110
145
  </div>
@@ -41,7 +41,7 @@
41
41
 
42
42
  .submenuItems {
43
43
  composes: grid from global;
44
- composes: grid-cols-4 from global;
44
+ composes: grid-cols-6 from global;
45
45
  /* composes: justify-between from global; */
46
46
  /* composes: ml-auto from global; */
47
47
  /* composes: mr-auto from global; */
@@ -1,8 +1,8 @@
1
1
  import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_CUSTOM_FILTERS = gql`
4
- query GetCustomFilters($shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
5
- customSubFilters(shopby: $shopby, category: $category, filters: $filters) {
4
+ query GetCustomFilters($filterBy: String, $shopby: String, $category: String!, $filters: ProductAttributeFilterInput!) {
5
+ customSubFilters(filterBy: $filterBy, shopby: $shopby, category: $category, filters: $filters) {
6
6
  label
7
7
  count
8
8
  attribute_code
@@ -21,7 +21,7 @@ import DEFAULT_OPERATIONS from './filterTop.gql';
21
21
  const DRAWER_NAME = 'filter';
22
22
 
23
23
  export const useFilterTop = props => {
24
- const { filters, category, shopby } = props;
24
+ const { filters, category, shopby, filterBy, setFilterBy } = props;
25
25
 
26
26
  const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
27
27
  const { getFilterInputsQuery, getCustomFilters } = operations;
@@ -78,14 +78,16 @@ export const useFilterTop = props => {
78
78
  variables: {
79
79
  filters: newFilters,
80
80
  category: category?.url_path,
81
- shopby: shopby
81
+ shopby: shopby,
82
+ filterBy: filterBy
82
83
  }
83
84
  });
84
85
  }, [
85
86
  runQuery,
86
87
  filterTypeMap,
87
88
  search,
88
- category
89
+ category,
90
+ filterBy
89
91
  ]);
90
92
 
91
93
  const attributeCodes = useMemo(