@riosst100/pwa-marketplace 1.4.7 → 1.4.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.4.7",
4
+ "version": "1.4.9",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -4,11 +4,13 @@ import { useSeller } from '@riosst100/pwa-marketplace/src/talons/Seller/useSelle
4
4
  import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
5
5
  import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
6
6
  import { useCollectibleGameSets } from '@riosst100/pwa-marketplace/src/talons/CollectibleGameSets/useCollectibleGameSets';
7
+ import { Link } from 'react-router-dom';
8
+ import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
7
9
 
8
10
  const CollectibleGameSets = props => {
9
11
  const talonProps = useCollectibleGameSets();
10
12
 
11
- const { error, loading, collectibleGameSets } = talonProps;
13
+ const { error, loading, collectibleGameSets, categoryUrlSuffix, categoryUrlKey } = talonProps;
12
14
 
13
15
  if (loading && !collectibleGameSets)
14
16
  return '';
@@ -28,11 +30,34 @@ const CollectibleGameSets = props => {
28
30
  );
29
31
  }
30
32
 
31
- const sets = collectibleGameSets.map((set, index) => {
32
- const { card_set } = set;
33
+ const setRelases = collectibleGameSets.map((setRelease, index) => {
34
+ const { release_type, sets } = setRelease;
35
+
36
+ const setsResult = [];
37
+
38
+ if (sets.length) {
39
+ sets.map((set, index) => {
40
+ const { set_name, option_id } = set;
41
+
42
+ const categoryUrl = resourceUrl(
43
+ `/games/collectible-game/${categoryUrlKey}${categoryUrlSuffix || ''}?card_set[filter]=${set_name},${option_id}`
44
+ );
45
+
46
+ setsResult.push(
47
+ <li>
48
+ <Link to={categoryUrl}>{set_name}</Link>
49
+ </li>
50
+ );
51
+ });
52
+ }
53
+
33
54
  return (
34
55
  <>
35
- <div><b>{card_set}</b></div>
56
+ <div>
57
+ <div className='text-[16px] pb-2'><b>{release_type}</b></div>
58
+ <hr />
59
+ <ul className='pt-2'>{setsResult}</ul>
60
+ </div>
36
61
  </>
37
62
  );
38
63
  });
@@ -41,8 +66,8 @@ const CollectibleGameSets = props => {
41
66
  return (
42
67
  <Fragment>
43
68
  <StoreTitle>Magic: The Gathering | Sets & Expansions</StoreTitle>
44
- <h3>Sets & Expansions</h3>
45
- <div>{sets}</div>
69
+ <div className='text-[20px] pb-4 pt-5'><b>Sets & Expansions</b></div>
70
+ <div className='flex flex-wrap gap-[30px]'>{setRelases}</div>
46
71
  </Fragment>
47
72
  );
48
73
  };
@@ -30,7 +30,7 @@ const CustomFilters = props => {
30
30
  // create elements and params at the same time for efficiency
31
31
  const filterElements = useMemo(() => {
32
32
  const elements = [];
33
- customFiltersData.map((filter, index) => {
33
+ customFiltersData && customFiltersData.map((filter, index) => {
34
34
  const { label, attribute_code, options } = filter || {};
35
35
 
36
36
  if (options.length) {
@@ -43,17 +43,19 @@ const CustomFilters = props => {
43
43
  // );
44
44
  // const keyAttr = `${attribute_code}[filter]`;
45
45
 
46
- Object.keys(params).forEach(function(key, index) {
47
- if (index > 1) {
48
- delete params[key];
49
- }
50
- });
46
+ if (params) {
47
+ Object.keys(params).forEach(function(key, index) {
48
+ if (index > 1) {
49
+ delete params[key];
50
+ }
51
+ });
52
+ }
51
53
 
52
54
  if (value != "all") {
53
55
  params[`${attribute_code}[filter]`] = `${label},${value}`;
54
56
  }
55
57
 
56
- const finalParams = Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
58
+ const finalParams = params ? Object.keys(params).map(key => `${key}=${params[key]}`).join('&') : '';
57
59
 
58
60
  // console.log(params)
59
61
 
@@ -1,139 +1,13 @@
1
- import React, { useMemo, useCallback, useRef } from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { array, arrayOf, shape, string, number } from 'prop-types';
4
- import { useFilterSidebar } from '@magento/peregrine/lib/talons/FilterSidebar';
5
-
6
- import { useStyle } from '@magento/venia-ui/lib/classify';
7
- import LinkButton from '@magento/venia-ui/lib/components/LinkButton';
1
+ import React from 'react';
8
2
  import CustomFilters from './CustomFilters';
9
- import FilterBlock from '@magento/venia-ui/lib/components/FilterModal/filterBlock';
10
- import defaultClasses from './filterTop.module.css';
11
-
12
- import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
13
-
14
- import { Link } from 'react-router-dom';
15
- import CurrentFilters from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters';
16
-
17
- const SCROLL_OFFSET = 150;
18
3
 
19
- /**
20
- * A view that displays applicable and applied filters.
21
- *
22
- * @param {Object} props.filters - filters to display
23
- */
24
4
  const FilterTop = props => {
25
- const { filters, filterCountToOpen, category } = props;
26
- const talonProps = useFilterSidebar({ filters });
27
- const {
28
- filterApi,
29
- filterItems,
30
- filterNames,
31
- filterFrontendInput,
32
- filterState,
33
- handleApply,
34
- handleReset
35
- } = talonProps;
36
-
37
- const filterRef = useRef();
38
- const classes = useStyle(defaultClasses, props.classes);
39
-
40
- const handleApplyFilter = useCallback(
41
- (...args) => {
42
- const filterElement = filterRef.current;
43
- if (
44
- filterElement &&
45
- typeof filterElement.getBoundingClientRect === 'function'
46
- ) {
47
- const filterTop = filterElement.getBoundingClientRect().top;
48
- const windowScrollY =
49
- window.scrollY + filterTop - SCROLL_OFFSET;
50
- window.scrollTo(0, windowScrollY);
51
- }
52
-
53
- handleApply(...args);
54
- },
55
- [handleApply, filterRef]
56
- );
57
-
58
- const filtersList = useMemo(
59
- () =>
60
- Array.from(filterItems, ([group, items], iteration) => {
61
- const blockState = filterState.get(group);
62
- const groupName = filterNames.get(group);
63
- const frontendInput = filterFrontendInput.get(group);
64
- return (
65
- <FilterBlock
66
- key={group}
67
- filterApi={filterApi}
68
- filterState={blockState}
69
- filterFrontendInput={frontendInput}
70
- group={group}
71
- items={items}
72
- name={groupName}
73
- onApply={handleApplyFilter}
74
- initialOpen={iteration < filterCountToOpen}
75
- />
76
- );
77
- }),
78
- [
79
- filterApi,
80
- filterItems,
81
- filterNames,
82
- filterFrontendInput,
83
- filterState,
84
- filterCountToOpen,
85
- handleApplyFilter
86
- ]
87
- );
88
-
89
- const clearAll = filterState.size ? (
90
- <div className={classes.action}>
91
- <LinkButton
92
- type="button"
93
- onClick={handleReset}
94
- data-cy="FilterSidebar-clearButton"
95
- >
96
- <FormattedMessage
97
- id={'filterModal.all'}
98
- defaultMessage={'All'}
99
- />
100
- </LinkButton>
101
- </div>
102
- ) : null;
103
-
5
+ const { category } = props;
104
6
  return (
105
7
  <CustomFilters
106
- filterApi={filterApi}
107
- filterNames={filterNames}
108
- filterState={filterState}
109
- clearAll={clearAll}
110
8
  category={category}
111
- onRemove={handleApplyFilter}
112
9
  />
113
10
  );
114
11
  };
115
12
 
116
- FilterTop.defaultProps = {
117
- filterCountToOpen: 3
118
- };
119
-
120
- FilterTop.propTypes = {
121
- classes: shape({
122
- action: string,
123
- blocks: string,
124
- body: string,
125
- header: string,
126
- headerTitle: string,
127
- root: string,
128
- root_open: string
129
- }),
130
- filters: arrayOf(
131
- shape({
132
- attribute_code: string,
133
- items: array
134
- })
135
- ),
136
- filterCountToOpen: number
137
- };
138
-
139
13
  export default FilterTop;
package/src/intercept.js CHANGED
@@ -99,7 +99,7 @@ module.exports = targets => {
99
99
  {
100
100
  exact: true,
101
101
  name: "CollectibleGameSetsPage",
102
- pattern: "/games/collectible-game/:urlKey/sets",
102
+ pattern: "/games/collectible-game/:urlKey/:productType",
103
103
  path: require.resolve("./components/CollectibleGameSetsPage/index.js"),
104
104
  authed: false,
105
105
  },
@@ -186,7 +186,7 @@ const CategoryContent = props => {
186
186
  </h1>
187
187
  {categoryDescriptionElement}
188
188
  </div>
189
- <SubCategory filters={filters} children={children} />
189
+ {/* <SubCategory filters={filters} children={children} /> */}
190
190
  <FilterTop filters={filters} category={category} />
191
191
  {/* <AttributesBlock category={category} attributesBlock={attributesBlock} /> */}
192
192
  {/* <section className='category_brand-slider my-5'>
@@ -6,6 +6,7 @@ export const GET_STORE_CONFIG_DATA = gql`
6
6
  storeConfig {
7
7
  store_code
8
8
  product_url_suffix
9
+ category_url_suffix
9
10
  }
10
11
  }
11
12
  `;
@@ -13,10 +14,14 @@ export const GET_STORE_CONFIG_DATA = gql`
13
14
  export const GET_COLLECTIBLE_GAME_QUERY = gql`
14
15
  query getCollectibleGameSets($categoryUrlKey: String!) {
15
16
  collectibleGameSets(categoryUrlKey: $categoryUrlKey) {
16
- card_set
17
- card_game
18
- card_set_abbreviation
19
- card_release_year
17
+ release_type
18
+ sets {
19
+ set_name
20
+ option_id
21
+ set_abbreviation
22
+ release_date
23
+ release_number
24
+ }
20
25
  }
21
26
  }
22
27
  `;
@@ -23,9 +23,14 @@ export const useCollectibleGameSets = props => {
23
23
  nextFetchPolicy: 'cache-first'
24
24
  });
25
25
 
26
+ const pathnameArr = pathname.split('/');
27
+
28
+ const categoryUrlKey = pathnameArr[pathnameArr.length - 2];
29
+
26
30
  const slug = pathname.split('/').pop();
27
31
  const productUrlSuffix = storeConfigData?.storeConfig?.product_url_suffix;
28
- const categoryUrlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
32
+ const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
33
+ // const categoryUrlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
29
34
 
30
35
  const { error, loading, data } = useQuery(getCollectibleGameQuery, {
31
36
  fetchPolicy: 'cache-and-network',
@@ -60,6 +65,8 @@ export const useCollectibleGameSets = props => {
60
65
  return {
61
66
  error,
62
67
  loading,
63
- collectibleGameSets
68
+ collectibleGameSets,
69
+ categoryUrlSuffix,
70
+ categoryUrlKey
64
71
  };
65
72
  };