@riosst100/pwa-marketplace 3.1.8 → 3.1.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": "3.1.8",
4
+ "version": "3.1.9",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -76,7 +76,7 @@ const SellerDetail = props => {
76
76
  [
77
77
  {
78
78
  id: 'product-tab',
79
- title: 'All Products',
79
+ title: 'Products',
80
80
  content:
81
81
  <SellerProducts
82
82
  sellerId={seller?.seller_id}
@@ -31,11 +31,10 @@ const SellerMegaMenu = (props) => {
31
31
  handleClickOutside
32
32
  } = useSellerMegaMenu({ mainNavRef });
33
33
 
34
- const allowedCategoryUids = props.allowedCategoryUids || ['NTI=', 'NTA=', 'NTM=', 'MjY='];
34
+ // const allowedCategoryUids = props.allowedCategoryUids || ['NTI=', 'NTA=', 'NTM=', 'MjY='];
35
35
 
36
36
  const filteredChildren = Array.isArray(megaMenuData?.children)
37
- ? megaMenuData.children.filter(c => allowedCategoryUids.includes(c.uid))
38
- : [];
37
+ ? megaMenuData.children : [];
39
38
 
40
39
  const [mainNavWidth, setMainNavWidth] = useState(0);
41
40
  const shouldRenderItems = useIsInViewport({
@@ -65,21 +65,7 @@ const SellerMegaMenuItem = props => {
65
65
  const arrow = <ArrowDown2 className='ml-2 stroke-current' size="14" color={textPrimary} variant="Outline" />;
66
66
 
67
67
  const children = useMemo(() => {
68
- return category.children.length || category.name == "Lego" ? (
69
- <SellerSubmenu
70
- isFocused={isFocused}
71
- sellerSubMenuState={sellerSubMenuState}
72
- items={category.children}
73
- seller={seller}
74
- parentCategory={category}
75
- shopByItems={category.shop_by}
76
- mainNavWidth={mainNavWidth}
77
- handleCloseSellerSubMenu={handleCloseSellerSubMenu}
78
- categoryUrlSuffix={categoryUrlSuffix}
79
- onNavigate={onNavigate}
80
- arrow={arrow}
81
- />
82
- ) : null;
68
+ return null;
83
69
  }, [
84
70
  category,
85
71
  isFocused,
@@ -124,7 +110,6 @@ const SellerMegaMenuItem = props => {
124
110
  >
125
111
  <Link
126
112
  {...linkAttributes}
127
- onKeyDown={handleKeyDown}
128
113
  className={cn(
129
114
  isActive ? classes.sellerMegaMenuLinkActive : classes.sellerMegaMenuLink,
130
115
  titleClassName,
@@ -132,12 +117,9 @@ const SellerMegaMenuItem = props => {
132
117
  )}
133
118
  data-cy="SellerMegaMenu-SellerMegaMenuItem-link"
134
119
  to={'/seller/' + seller?.url_key + categoryUrl}
135
- onClick={onNavigate}
136
120
  >
137
121
  {category.name}
138
- {/* {maybeDownArrowIcon} */}
139
122
  </Link>
140
- {children}
141
123
  </div>
142
124
  );
143
125
  };
@@ -85,7 +85,7 @@ const ProductContent = props => {
85
85
  const shouldShowFilterShimmer = filters === null;
86
86
 
87
87
  const sidebar = shouldShowFilterButtons ? (
88
- <FilterSidebar children={[]} filters={filters} />
88
+ <FilterSidebar category={category} children={[]} filters={filters} />
89
89
  ) : shouldShowFilterShimmer ? (
90
90
  <FilterSidebarShimmer />
91
91
  ) : null;
@@ -266,11 +266,6 @@ const ProductContent = props => {
266
266
  </span>
267
267
  </h1>
268
268
  </div>
269
- <>
270
- {currentFilter && <AlphaFilter isSingles={isSingles} items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
271
- {shopby != "gauge" && category?.name != "Collectible Card Games" ? <SubCategory parent={parent} children={children} /> : ''}
272
-
273
- </>
274
269
  <FilterTop shopby={shopby} filters={filters} category={category} children={children} />
275
270
  </div>
276
271
  <div className='w-full flex items-start gap-x-[30px]'>
package/src/intercept.js CHANGED
@@ -87,6 +87,20 @@ module.exports = targets => {
87
87
  authed: true,
88
88
  redirectTo: "/sign-in"
89
89
  },
90
+ {
91
+ exact: true,
92
+ name: "HelpCenter",
93
+ pattern: "/help-center",
94
+ path: require.resolve("./components/HelpCenter/index.js"),
95
+ authed: false,
96
+ },
97
+ {
98
+ exact: true,
99
+ name: "HelpCenterQuestionDetail",
100
+ pattern: "/help-center/question/:questionId",
101
+ path: require.resolve("./components/HelpCenter/questionDetail.js"),
102
+ authed: false,
103
+ },
90
104
  {
91
105
  exact: true,
92
106
  name: "VerifyEmailPage",
@@ -12,7 +12,7 @@ const CurrentFilters = props => {
12
12
  const classes = useStyle(defaultClasses, props.classes);
13
13
  const { formatMessage } = useIntl();
14
14
 
15
- const defaultTopFilterAttrCode = category.default_top_filter.attribute_code;
15
+ const defaultTopFilterAttrCode = category && category.default_top_filter ? category.default_top_filter.attribute_code : null;
16
16
 
17
17
  // create elements and params at the same time for efficiency
18
18
  const filterElements = useMemo(() => {
@@ -10,7 +10,7 @@ const getToKnowUsLinks = new Map()
10
10
  .set('About TCG Collective', null)
11
11
  .set('Career', '/')
12
12
  .set('Contact Us', '/')
13
- .set('Help Center', '/')
13
+ .set('Help Center', '/help-center')
14
14
  .set('Intelectual Property Claims', '/');
15
15
 
16
16
  const aboutLinks = new Map()
@@ -10,9 +10,9 @@ export const GET_STORE_CONFIG_DATA = gql`
10
10
  `;
11
11
 
12
12
  export const GET_MEGA_MENU = gql`
13
- query getMegaMenu {
13
+ query getSellerMegaMenu {
14
14
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
15
- categoryList {
15
+ sellerCategories {
16
16
  uid
17
17
  name
18
18
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
@@ -22,22 +22,10 @@ export const GET_MEGA_MENU = gql`
22
22
  name
23
23
  position
24
24
  url_path
25
- custom_submenu {
26
- name
27
- attribute {
28
- code
29
- value
30
- }
31
- path
32
- }
33
- shop_by {
34
- name
35
- code
36
- items {
37
- name
38
- option_id
39
- url_path
40
- }
25
+ default_top_filter {
26
+ attribute_code
27
+ label
28
+ value
41
29
  }
42
30
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
43
31
  children {
@@ -46,6 +34,11 @@ export const GET_MEGA_MENU = gql`
46
34
  name
47
35
  position
48
36
  url_path
37
+ default_top_filter {
38
+ attribute_code
39
+ label
40
+ value
41
+ }
49
42
  custom_submenu {
50
43
  name
51
44
  attribute {
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState, useCallback, useEffect } from 'react';
2
- import { useLocation } from 'react-router-dom';
2
+ import { useLocation, useHistory } from 'react-router-dom';
3
3
  import { useInternalLink } from '@magento/peregrine/lib/hooks/useInternalLink';
4
4
 
5
5
  import { useQuery } from '@apollo/client';
@@ -8,6 +8,7 @@ import { useEventListener } from '@magento/peregrine/lib/hooks/useEventListener'
8
8
  import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
9
9
  import DEFAULT_OPERATIONS from './megaMenu.gql';
10
10
 
11
+
11
12
  /**
12
13
  * The useSellerMegaMenu talon complements the SellerMegaMenu component.
13
14
  *
@@ -107,9 +108,65 @@ export const useSellerMegaMenu = (props = {}) => {
107
108
  );
108
109
 
109
110
  const megaMenuData = useMemo(() => {
110
- return data ? processData(data.categoryList[0]) : {};
111
+ return data ? processData(data.sellerCategories[0]) : {};
111
112
  }, [data, processData]);
112
113
 
114
+ const category = useMemo(() => {
115
+ return Array.isArray(megaMenuData?.children)
116
+ ? megaMenuData.children[0]
117
+ : [];
118
+ }, [megaMenuData]);
119
+
120
+ const history = useHistory();
121
+
122
+ const setQueryParam = ({ history, location, parameter, replace, value }) => {
123
+ const { search } = location;
124
+ const queryParams = new URLSearchParams(search);
125
+
126
+ queryParams.set(parameter, value);
127
+ const destination = { search: queryParams.toString() };
128
+
129
+ if (replace) {
130
+ history.replace(destination);
131
+ } else {
132
+ history.push(destination);
133
+ }
134
+ };
135
+
136
+ const setDefaultSubcategoryAndTopFilter = useCallback(
137
+ (value, searchParam, replace = false) => {
138
+ // Update the query parameter.
139
+ setQueryParam({
140
+ history,
141
+ location,
142
+ parameter: searchParam,
143
+ replace,
144
+ value: value
145
+ });
146
+ },
147
+ [history, location]
148
+ );
149
+
150
+ useEffect(() => {
151
+ const { search } = location;
152
+
153
+ // if (category && category.default_top_filter) {
154
+ // const defaultTopFilter = category.default_top_filter;
155
+
156
+ // const attrCode = defaultTopFilter.attribute_code;
157
+ // const label = defaultTopFilter.label;
158
+ // const value = defaultTopFilter.value;
159
+
160
+ // if (!search.includes(attrCode)) {
161
+ // setDefaultSubcategoryAndTopFilter(
162
+ // label + ',' + value,
163
+ // attrCode + '[filter]',
164
+ // true
165
+ // );
166
+ // }
167
+ // }
168
+ }, [category, location, setDefaultSubcategoryAndTopFilter]);
169
+
113
170
  const findActiveCategory = useCallback(
114
171
  (pathname, category) => {
115
172
  if (isActive(category)) {
@@ -35,6 +35,11 @@ export const GET_CATEGORY_CONTENT = gql`
35
35
  url_key
36
36
  url_path
37
37
  prefixes
38
+ default_top_filter {
39
+ attribute_code
40
+ label
41
+ value
42
+ }
38
43
  parent {
39
44
  uid
40
45
  name
@@ -1,6 +1,6 @@
1
- import React, { useEffect, useMemo } from 'react';
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { useLazyQuery, useQuery } from '@apollo/client';
3
-
3
+ import { useLocation, useHistory } from 'react-router-dom';
4
4
  import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
5
  import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
6
6
 
@@ -48,6 +48,8 @@ export const useProductContent = props => {
48
48
  }
49
49
  );
50
50
 
51
+
52
+
51
53
  const { data: categoryData, loading: categoryLoading } = useQuery(
52
54
  getCategoryContentQuery,
53
55
  {
@@ -60,6 +62,9 @@ export const useProductContent = props => {
60
62
  }
61
63
  );
62
64
 
65
+ console.log('categoryData',categoryData)
66
+ console.log('categoryId',categoryId)
67
+
63
68
  const [, { dispatch }] = useEventingContext();
64
69
 
65
70
  useEffect(() => {
@@ -94,6 +99,7 @@ export const useProductContent = props => {
94
99
  categoryData && categoryData.categories.items.length
95
100
  ? categoryData.categories.items[0]
96
101
  : null;
102
+ console.log('categorycategory',category)
97
103
  const children =
98
104
  categoryData && categoryData.categories.items.length
99
105
  ? categoryData.categories.items[0].children
@@ -101,6 +107,59 @@ export const useProductContent = props => {
101
107
 
102
108
  const filters = [];
103
109
 
110
+ const history = useHistory();
111
+ const location = useLocation();
112
+
113
+ const setQueryParam = ({ history, location, parameter, replace, value }) => {
114
+ const { search } = location;
115
+ const queryParams = new URLSearchParams(search);
116
+
117
+ queryParams.set(parameter, value);
118
+ const destination = { search: queryParams.toString() };
119
+
120
+ if (replace) {
121
+ history.replace(destination);
122
+ } else {
123
+ history.push(destination);
124
+ }
125
+ };
126
+
127
+ const setDefaultSubcategoryAndTopFilter = useCallback(
128
+ (value, searchParam, replace = false) => {
129
+ // Update the query parameter.
130
+ setQueryParam({
131
+ history,
132
+ location,
133
+ parameter: searchParam,
134
+ replace,
135
+ value: value
136
+ });
137
+ },
138
+ [history, location]
139
+ );
140
+
141
+ console.log('category category',category)
142
+
143
+ useEffect(() => {
144
+ const { search } = location;
145
+
146
+ if (category && category.default_top_filter) {
147
+ const defaultTopFilter = category.default_top_filter;
148
+
149
+ const attrCode = defaultTopFilter.attribute_code;
150
+ const label = defaultTopFilter.label;
151
+ const value = defaultTopFilter.value;
152
+
153
+ if (!search.includes(attrCode)) {
154
+ setDefaultSubcategoryAndTopFilter(
155
+ label + ',' + value,
156
+ attrCode + '[filter]',
157
+ true
158
+ );
159
+ }
160
+ }
161
+ }, [category, location, setDefaultSubcategoryAndTopFilter]);
162
+
104
163
  rawFilters && rawFilters.map((filter, index) => {
105
164
 
106
165
  const filterOptions = [];