@riosst100/pwa-marketplace 3.0.7 → 3.0.8

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.7",
4
+ "version": "3.0.8",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -95,13 +95,6 @@ const FilterTop = props => {
95
95
  [handleApply, filterRef]
96
96
  );
97
97
 
98
- // const allowedFiltersArr = [];
99
-
100
- // allowedFilters.length && allowedFilters.map((val, index) => {
101
- // allowedFiltersArr.push(val.code);
102
- // });
103
- // const allowedFiltersArr = ['card_rarity','card_print_version','card_set', 'card_product_type'];
104
-
105
98
  const filtersList = useMemo(
106
99
  () =>
107
100
  Array.from(filterItems, ([group, items], iteration) => {
@@ -339,7 +339,6 @@ const ShowMore = props => {
339
339
  <StoreTitle>{title}</StoreTitle>
340
340
  <Breadcrumbs categoryId={categoryId} customPage={title} currentFilter={activeFilters} />
341
341
  {category?.url_path.includes('model-railway') && <FilterTop shopby={shopby} filters={[]} category={category} children={[]} allowedFilters={category ? category.allowed_filters : []} />}
342
- {/* <ShopByFilters handleActiveFilter={handleActiveFilter} activeFilter={activeFilter} category={category} /> */}
343
342
  {availableFilterOption.length ?
344
343
  <ul className={classes.nav}>
345
344
  {availableFilterOption.map((filter, index) => (
@@ -43,6 +43,7 @@ export const GET_CATEGORY_CONTENT = gql`
43
43
  allowed_filters {
44
44
  code
45
45
  }
46
+ prefixes
46
47
  custom_subcategory {
47
48
  name
48
49
  path
@@ -165,7 +165,7 @@ const CategoryContent = props => {
165
165
  ) : null;
166
166
 
167
167
  const sidebar = shouldShowFilterButtons ? (
168
- <FilterSidebar hideFilters={category && category.hide_filters ? true : false} children={children} filters={filters} allowedFilters={category ? category.allowed_filters : []} />
168
+ <FilterSidebar hideFilters={category && category.hide_filters ? true : false} children={children} filters={filters} allowedFilters={category ? category.allowed_filters : []} prefixes={category ? category.prefixes : []} />
169
169
  ) : shouldShowFilterShimmer ? (
170
170
  <FilterSidebarShimmer />
171
171
  ) : null;
@@ -21,7 +21,7 @@ const SCROLL_OFFSET = 150;
21
21
  * @param {Object} props.filters - filters to display
22
22
  */
23
23
  const FilterSidebar = props => {
24
- const { filters, filterCountToOpen, allowedFilters, hideFilters } = props;
24
+ const { filters, filterCountToOpen, allowedFilters, prefixes, hideFilters } = props;
25
25
  const talonProps = useFilterSidebar({ filters });
26
26
  const {
27
27
  filterApi,
@@ -116,7 +116,15 @@ const FilterSidebar = props => {
116
116
  // // console.log([...sorted.entries()]);
117
117
  // const filterItems = [...sorted.entries()];
118
118
 
119
- // console.log('filterItems',filterItems)
119
+ const removePrefix = (attrCode) => {
120
+ if (prefixes) {
121
+ return prefixes.reduce((s, p) =>
122
+ s.startsWith(p + "_") ? s.replace(p + "_", "") : s
123
+ , attrCode);
124
+ }
125
+
126
+ return attrCode;
127
+ };
120
128
 
121
129
  const filtersList = useMemo(
122
130
  () =>
@@ -124,10 +132,10 @@ const FilterSidebar = props => {
124
132
  const blockState = filterState.get(group);
125
133
  const groupName = filterNames.get(group);
126
134
  const frontendInput = filterFrontendInput.get(group);
127
-
128
- const hideFilters = ['card_game','bricks_categories','sc_sports_categories','trains','trains_locomotives','trains_supplies_type','lof_preorder','card_pre_orders','auction','special_price','sc_baseball_inserts','sc_baseball_parallel','sale','sc_set_type','sc_brands'];
129
- if (!allowedFiltersArr?.length || filterState.size && allowedFiltersArr.length || !filterState.size && allowedFiltersArr.length && allowedFiltersArr.includes(group)) {
130
- if (!hideFilters.includes(group) && groupName && !group.includes('card_release') && !group.includes('card_set') && !group.includes('sc_set_name')) {
135
+
136
+ if (!allowedFiltersArr.length || allowedFiltersArr.length && allowedFiltersArr.includes(removePrefix(group))) {
137
+ console.log('removePrefix(group)',removePrefix(group))
138
+ // if (!hideFilters.includes(group) && groupName && !group.includes('card_release') && !group.includes('card_set') && !group.includes('sc_set_name')) {
131
139
 
132
140
  // if (!allowedFiltersArr?.length && group != "category_uid" || allowedFiltersArr?.length && allowedFiltersArr.includes(group)) {
133
141
  let subFilter = null;
@@ -177,7 +185,7 @@ const FilterSidebar = props => {
177
185
  initialOpen={true}
178
186
  />
179
187
  );
180
- }
188
+ // }
181
189
  }
182
190
  }),
183
191
  [
@@ -254,6 +262,7 @@ FilterSidebar.propTypes = {
254
262
  root: string,
255
263
  root_open: string
256
264
  }),
265
+ prefixes: [],
257
266
  filters: arrayOf(
258
267
  shape({
259
268
  attribute_code: string,
@@ -33,6 +33,7 @@ export const GET_CATEGORY_CONTENT = gql`
33
33
  allowed_filters {
34
34
  code
35
35
  }
36
+ prefixes
36
37
  custom_subcategory {
37
38
  name
38
39
  path
@@ -34,6 +34,7 @@ export const GET_CATEGORY_CONTENT = gql`
34
34
  allowed_filters {
35
35
  code
36
36
  }
37
+ prefixes
37
38
  custom_subcategory {
38
39
  name
39
40
  path
@@ -1 +0,0 @@
1
- export { default } from './relatedProducts';
@@ -1,44 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { useRelatedProducts } from '@riosst100/pwa-marketplace/src/talons/RelatedProducts/useRelatedProducts';
4
- import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
5
- import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
6
- import mapSeller from '@riosst100/pwa-marketplace/src/util/mapSeller';
7
- import SellerDetail from '@riosst100/pwa-marketplace/src/components/SellerDetail/sellerDetail';
8
-
9
- const RelatedProducts = props => {
10
- const { categoryUrlKey } = props;
11
-
12
- const talonProps = useRelatedProducts({
13
- mapSeller
14
- });
15
-
16
- const { error, loading, seller } = talonProps;
17
-
18
- if (loading && !seller)
19
- return '';
20
- // return <SellerShimmer />;
21
- if (error && !seller) return <ErrorView />;
22
- if (!seller) {
23
- return (
24
- <h1>
25
- <FormattedMessage
26
- id={'seller.notFound'}
27
- defaultMessage={
28
- 'Seller Not Found.'
29
- }
30
- />
31
- </h1>
32
- );
33
- }
34
-
35
- return (
36
- <Fragment>
37
- <StoreTitle>{seller.name}</StoreTitle>
38
- <Meta name="description" content={seller.description} />
39
- {seller && <SellerDetail seller={seller} />}
40
- </Fragment>
41
- );
42
- };
43
-
44
- export default RelatedProducts;
@@ -1,112 +0,0 @@
1
- import { useQuery } from '@apollo/client';
2
- import { useEffect, useMemo } from 'react';
3
- import { useLocation } from 'react-router-dom';
4
- import { useAppContext } from '@magento/peregrine/lib/context/app';
5
- import { useIntl } from 'react-intl';
6
-
7
- import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
8
- import DEFAULT_OPERATIONS from './relatedProducts.gql';
9
-
10
- export const useRelatedProducts = props => {
11
- const { mapSeller } = props;
12
-
13
- const { formatMessage } = useIntl();
14
-
15
- const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
16
- const { getStoreConfigData, getSellerDetailQuery, getCouponCodeQuery } = operations;
17
- const { pathname } = useLocation();
18
- const [
19
- ,
20
- {
21
- actions: { setPageLoading }
22
- }
23
- ] = useAppContext();
24
-
25
- const { data: storeConfigData } = useQuery(getStoreConfigData, {
26
- fetchPolicy: 'cache-and-network',
27
- nextFetchPolicy: 'cache-first'
28
- });
29
-
30
- const slug = pathname.split('/')[2];
31
- const productUrlSuffix = storeConfigData?.storeConfig?.product_url_suffix;
32
- const urlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
33
-
34
- const getOtherInfo = true;
35
- const getProducts = true;
36
-
37
- const { error, loading, data } = useQuery(getSellerDetailQuery, {
38
- fetchPolicy: 'cache-and-network',
39
- nextFetchPolicy: 'cache-first',
40
- skip: !storeConfigData,
41
- variables: {
42
- urlKey,
43
- getOtherInfo,
44
- getProducts
45
- }
46
- });
47
-
48
- const {
49
- data: couponData,
50
- error: couponError,
51
- loading: couponLoading
52
- } = useQuery(getCouponCodeQuery, {
53
- fetchPolicy: 'cache-and-network',
54
- nextFetchPolicy: 'cache-first',
55
- variables: {
56
- sellerUrl: urlKey,
57
- pageSize: 20,
58
- currentPage: 1,
59
- filters: {
60
- is_public: {
61
- eq: '1'
62
- }
63
- }
64
- },
65
- skip: !urlKey
66
- });
67
-
68
- const isBackgroundLoading = !!data && loading;
69
-
70
- const seller = useMemo(() => {
71
- if (!data) {
72
- return null;
73
- }
74
-
75
- const seller = data.sellerByUrl;
76
-
77
- if (!seller) {
78
- return null;
79
- }
80
-
81
- return mapSeller(seller);
82
- }, [data, mapSeller, urlKey]);
83
-
84
- // Update the page indicator if the GraphQL query is in flight.
85
- useEffect(() => {
86
- setPageLoading(isBackgroundLoading);
87
- }, [isBackgroundLoading, setPageLoading]);
88
-
89
- const favoriteSellerOptions = useMemo(() => {
90
- const options = {
91
- seller_id: seller?.seller_id
92
- };
93
-
94
- return options;
95
- }, [seller]);
96
-
97
- const favoriteSellerButtonProps = {
98
- buttonText: '',
99
- item: favoriteSellerOptions,
100
- storeConfig: storeConfigData ? storeConfigData.storeConfig : {}
101
- };
102
-
103
- return {
104
- error,
105
- loading,
106
- seller,
107
- favoriteSellerButtonProps,
108
- couponData,
109
- couponError,
110
- couponLoading
111
- };
112
- };