@riosst100/pwa-marketplace 1.5.9 → 1.6.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": "1.5.9",
4
+ "version": "1.6.1",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -0,0 +1,75 @@
1
+ import React, { Fragment, useState } from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { useSeller } from '@riosst100/pwa-marketplace/src/talons/Seller/useSeller';
4
+ import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
5
+ import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
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';
9
+ import defaultClasses from './alphaFilter.module.css';
10
+ import { useStyle } from '@magento/venia-ui/lib/classify';
11
+ import cn from 'classnames';
12
+ import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
13
+ import { CollectibleGameSetsShimmer } from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets';
14
+ import ProductSort from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/ProductSort';
15
+ import CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
16
+
17
+ const AlphaFilter = props => {
18
+ const {items, handleActiveLetter} = props;
19
+
20
+ const groupSinglesFirstLetter = (data) => {
21
+ return data.reduce((acc, item) => {
22
+ if (item && item.name) {
23
+ const firstLetter = item.name.charAt(0).toUpperCase();
24
+ acc[firstLetter] = acc[firstLetter] || [];
25
+ acc[firstLetter].push(item);
26
+ }
27
+
28
+ return acc;
29
+ }, {});
30
+ }
31
+
32
+ const groupedSingles = items ? groupSinglesFirstLetter(items) : null;
33
+ const availableLetter = groupedSingles ? Object.keys(groupedSingles).sort() : [];
34
+
35
+ const alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
36
+
37
+ return <>
38
+ <section className='single_list-indexing-container relative m-auto py-1'>
39
+ <ul className='flex gap-2 justify-center flex-wrap'>
40
+ {alpha.map((letter, index) => (
41
+ <li key={index}>
42
+ <button
43
+ className={cn(
44
+ 'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
45
+ 'leading-4 font-medium text-base ',
46
+ availableLetter.includes(letter) ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
47
+ )}
48
+ onClick={() => {
49
+ handleActiveLetter(letter)
50
+ }}
51
+ disabled={availableLetter.includes(letter) > 0 ? false : true}
52
+ >
53
+ {letter}
54
+ </button>
55
+ </li>
56
+ ))}
57
+ <li>
58
+ <button
59
+ className={cn(
60
+ 'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
61
+ 'leading-4 font-medium text-base hover_bg-gray-50'
62
+ )}
63
+ onClick={() => {
64
+ handleActiveLetter('all')
65
+ }}
66
+ >
67
+ All
68
+ </button>
69
+ </li>
70
+ </ul>
71
+ </section>
72
+ </>
73
+ }
74
+
75
+ export default AlphaFilter;
@@ -0,0 +1,38 @@
1
+ .tabs {
2
+ composes: flex from global;
3
+ composes: flex-wrap from global;
4
+ composes: mt-3 from global;
5
+ composes: gap-[15px] from global;
6
+ margin-bottom: 30px;
7
+ }
8
+
9
+ .tabs_item {
10
+ composes: px-4 from global;
11
+ composes: py-2 from global;
12
+ composes: transition-colors from global;
13
+ composes: duration-150 from global;
14
+ composes: border from global;
15
+ composes: border-solid from global;
16
+ composes: leading-normal from global;
17
+ composes: text-base from global;
18
+ composes: text-colorDefault from global;
19
+ composes: bg-white from global;
20
+ composes: border-gray-100 from global;
21
+ border-radius: 5px;
22
+ }
23
+
24
+ .singlesWrapper {
25
+ column-count: 1;
26
+ }
27
+
28
+ @media screen and (min-width: 768px) {
29
+ .singlesWrapper {
30
+ column-count: 2;
31
+ }
32
+ }
33
+
34
+ @media screen and (min-width: 1023px) {
35
+ .singlesWrapper {
36
+ column-count: 3;
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './alphaFilter';
2
+ // export { default as CollectibleGameSetsShimmer } from './collectibleGameSets.shimmer';
@@ -100,11 +100,18 @@ const CollectibleGameSets = props => {
100
100
  }
101
101
  ];
102
102
 
103
+ let title = "All Sets";
104
+ if (productType == "expansion-sets") {
105
+ title = "Expansion Sets";
106
+ } else if (productType == "artist") {
107
+ title = "Artist";
108
+ }
109
+
103
110
  return (
104
111
  <Fragment>
105
- <StoreTitle>{"Magic: The Gathering" + " | " + (productType == "expansion-sets" ? "Expansion Sets" : "All Sets")}</StoreTitle>
112
+ <StoreTitle>{title}</StoreTitle>
106
113
  <h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
107
- {productType == "expansion-sets" ? "Expansion Sets" : "All Sets"}
114
+ {title}
108
115
  </h1>
109
116
  <div className='border border-gray-100 px-6'>
110
117
  {productType != "expansion-sets" ? (
@@ -43,7 +43,9 @@ const CustomFilter = props => {
43
43
 
44
44
  const subCategory = [];
45
45
 
46
- if (group == "card_set") {
46
+ const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
47
+
48
+ if (customAttributeLandingPage.includes(group)) {
47
49
  normalizedData && normalizedData.map(({ label, path }, index) => {
48
50
  subCategory.push(
49
51
  <Link
@@ -1,14 +1,12 @@
1
1
  import { useSubCategory } from '@riosst100/pwa-marketplace/src/talons/SubCategory/useSubCategory';
2
- import React, { useState } from 'react';
2
+ import React from 'react';
3
3
  import { Link } from 'react-router-dom';
4
4
  import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
5
5
  import defaultClasses from './subCategory.module.css';
6
6
  import { useStyle } from '@magento/venia-ui/lib/classify';
7
- import { useFilterSidebar } from '@magento/peregrine/lib/talons/FilterSidebar';
8
- import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets/collectibleGameSets';
9
7
 
10
8
  const SubCategory = props => {
11
- const { children } = props;
9
+ const { children, parent } = props;
12
10
 
13
11
  const talonProps = useSubCategory({ children });
14
12
 
@@ -17,32 +15,35 @@ const SubCategory = props => {
17
15
  const {
18
16
  normalizedData
19
17
  } = talonProps;
18
+
19
+ const maxSubCategory = 7;
20
20
 
21
21
  const subCategory = [];
22
22
 
23
23
  normalizedData && normalizedData.map(({ text, path }, index) => {
24
+ if (index < maxSubCategory) {
25
+ subCategory.push(
26
+ <Link
27
+ key={index}
28
+ to={resourceUrl(path)}
29
+ >
30
+ <li className={classes.item}>{text}</li>
31
+ </Link>
32
+ )
33
+ }
34
+ });
35
+
36
+ if (normalizedData.length > maxSubCategory) {
24
37
  subCategory.push(
25
38
  <Link
26
- key={index}
27
- to={resourceUrl(path)}
39
+ to={resourceUrl('/')}
28
40
  >
29
- <li className={classes.item}>{text}</li>
41
+ <li className={classes.item}>{"More " + parent[0].name}</li>
30
42
  </Link>
31
43
  )
32
- });
44
+ }
33
45
 
34
46
  return subCategory.length ? <ul className={classes.root}>{subCategory}</ul> : '';
35
-
36
- // const [activeTab, setActiveTab] = useState('singles')
37
-
38
- return (
39
- <>
40
- <ul className={classes.root}>
41
- <li className={classes.item}>All Sets</li>
42
- <li className={classes.item}>Expansion Sets</li>
43
- </ul>
44
- </>
45
- )
46
47
  };
47
48
 
48
49
  export default SubCategory;
@@ -78,8 +78,20 @@ export const GET_CATEGORY_AVAILABLE_SORT_METHODS = gql`
78
78
  }
79
79
  `;
80
80
 
81
+ export const GET_STORE_CONFIG_DATA = gql`
82
+ query GetStoreConfigForBreadcrumbs {
83
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
84
+ storeConfig {
85
+ store_code
86
+ custommarketplace_plp_filters_virtualcategory
87
+ }
88
+ }
89
+ `;
90
+
91
+
81
92
  export default {
82
93
  getCategoryContentQuery: GET_CATEGORY_CONTENT,
83
94
  getProductFiltersByCategoryQuery: GET_PRODUCT_FILTERS_BY_CATEGORY,
84
- getCategoryAvailableSortMethodsQuery: GET_CATEGORY_AVAILABLE_SORT_METHODS
95
+ getCategoryAvailableSortMethodsQuery: GET_CATEGORY_AVAILABLE_SORT_METHODS,
96
+ getStoreConfigQuery: GET_STORE_CONFIG_DATA
85
97
  };
@@ -1,4 +1,4 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useMemo } from 'react';
2
2
  import { useLazyQuery, useQuery } from '@apollo/client';
3
3
 
4
4
  import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
@@ -26,10 +26,22 @@ export const useCategoryContent = props => {
26
26
  const {
27
27
  getCategoryContentQuery,
28
28
  getProductFiltersByCategoryQuery,
29
- getCategoryAvailableSortMethodsQuery
29
+ getCategoryAvailableSortMethodsQuery,
30
+ getStoreConfigQuery
30
31
  } = operations;
31
32
 
32
33
  const placeholderItems = Array.from({ length: pageSize }).fill(null);
34
+
35
+ const { data: storeConfigData } = useQuery(getStoreConfigQuery, {
36
+ fetchPolicy: 'cache-and-network'
37
+ });
38
+
39
+ const virtualCategoryFilters = useMemo(() => {
40
+ if (storeConfigData) {
41
+ const data = storeConfigData.storeConfig.custommarketplace_plp_filters_virtualcategory;
42
+ return data ? data.split(',') : [];
43
+ }
44
+ }, [storeConfigData]);
33
45
 
34
46
  const [getFilters, { data: filterData }] = useLazyQuery(
35
47
  getProductFiltersByCategoryQuery,
@@ -174,6 +186,7 @@ export const useCategoryContent = props => {
174
186
  children,
175
187
  parent,
176
188
  attributesBlock,
177
- category
189
+ category,
190
+ virtualCategoryFilters
178
191
  };
179
192
  };
@@ -1,4 +1,4 @@
1
- import React, { Fragment, Suspense, useMemo, useRef } from 'react';
1
+ import React, { Fragment, Suspense, useMemo, useRef, useState } from 'react';
2
2
  import { FormattedMessage } from 'react-intl';
3
3
  import { array, number, shape, string } from 'prop-types';
4
4
 
@@ -32,6 +32,7 @@ import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/Colle
32
32
  import { useLocation } from 'react-router-dom';
33
33
  import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
34
34
  import CustomSubCategory from '@riosst100/pwa-marketplace/src/components/SubCategory/customSubCategory';
35
+ import AlphaFilter from '@riosst100/pwa-marketplace/src/components/AlphaFilter';
35
36
 
36
37
  const FilterModal = React.lazy(() => import('@magento/venia-ui/lib/components/FilterModal'));
37
38
  const FilterSidebar = React.lazy(() =>
@@ -65,12 +66,34 @@ const CategoryContent = props => {
65
66
  filters,
66
67
  items,
67
68
  children,
69
+ parent,
68
70
  totalCount,
69
71
  totalPagesFromData,
70
72
  attributesBlock,
71
- category
73
+ category,
74
+ virtualCategoryFilters
72
75
  } = talonProps;
73
76
 
77
+ const [activeLetter, setActiveLetter] = useState('all')
78
+
79
+ const handleActiveLetter = (val) => {
80
+ setActiveLetter(val);
81
+ }
82
+
83
+ const galleryItems = [];
84
+
85
+ useMemo(() => {
86
+ items && items.map((item, index) => {
87
+ if (item) {
88
+ const firstLetter = item.name.charAt(0).toUpperCase();
89
+ if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
90
+ return galleryItems.push(item);
91
+ }
92
+ }
93
+ }),
94
+ [items, activeLetter]
95
+ });
96
+
74
97
  const sidebarRef = useRef(null);
75
98
  const classes = useStyle(defaultClasses, props.classes);
76
99
  const shouldRenderSidebarContent = useIsInViewport({
@@ -125,11 +148,11 @@ const CategoryContent = props => {
125
148
  ) : null;
126
149
 
127
150
  const categoryResultsHeading =
128
- totalCount > 0 ? (
151
+ galleryItems.length > 0 ? (
129
152
  <FormattedMessage
130
153
  id={'categoryContent.resultCount'}
131
154
  values={{
132
- count: totalCount
155
+ count: galleryItems.length
133
156
  }}
134
157
  defaultMessage={'{count} Results'}
135
158
  />
@@ -147,9 +170,9 @@ const CategoryContent = props => {
147
170
  }
148
171
 
149
172
  const gallery = totalPagesFromData ? (
150
- <Gallery items={items} />
173
+ <Gallery items={galleryItems} activeLetter={activeLetter} />
151
174
  ) : (
152
- <GalleryShimmer items={items} />
175
+ <GalleryShimmer items={galleryItems} />
153
176
  );
154
177
 
155
178
  const pagination = totalPagesFromData ? (
@@ -169,7 +192,8 @@ const CategoryContent = props => {
169
192
  isLoading,
170
193
  items,
171
194
  pageControl,
172
- totalPagesFromData
195
+ totalPagesFromData,
196
+ activeLetter
173
197
  ]);
174
198
 
175
199
  const categoryTitle = categoryName ? categoryName : <Shimmer width={5} />;
@@ -186,7 +210,7 @@ const CategoryContent = props => {
186
210
 
187
211
  const label = filterArr[0];
188
212
  const optionId = filterArr[1];
189
- if (key == "card_set") {
213
+ if (virtualCategoryFilters && virtualCategoryFilters.includes(key)) {
190
214
  activeFilters.push(
191
215
  {
192
216
  'label': label
@@ -217,7 +241,8 @@ const CategoryContent = props => {
217
241
  </div>
218
242
  {/* {activeFilters.size <= 0 && category && category.custom_landing_page ? ( */}
219
243
  <>
220
- <SubCategory children={children} />
244
+ {currentFilter && <AlphaFilter items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
245
+ <SubCategory parent={parent} children={children} />
221
246
  {!currentFilter && <CustomSubCategory customSubCategory={category ? category.custom_subcategory : null} />}
222
247
  </>
223
248
  {/* ) : ( */}
@@ -20,7 +20,9 @@ const CurrentFilters = props => {
20
20
  const { title, value } = item || {};
21
21
  const key = `${group}::${title}_${value}`;
22
22
 
23
- if (group != "card_set") {
23
+ const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
24
+
25
+ if (!customAttributeLandingPage.includes(group)) {
24
26
  elements.push(
25
27
  <li key={key} className={classes.item}>
26
28
  <CurrentFilter
@@ -14,7 +14,7 @@ import { useGallery } from '@magento/peregrine/lib/talons/Gallery/useGallery';
14
14
  * @params {Array} props.items an array of items to render
15
15
  */
16
16
  const Gallery = props => {
17
- const { items } = props;
17
+ const { items, activeLetter } = props;
18
18
  const classes = useStyle(defaultClasses, props.classes);
19
19
  const talonProps = useGallery();
20
20
  const { storeConfig } = talonProps;
@@ -25,6 +25,10 @@ const Gallery = props => {
25
25
  if (item === null) {
26
26
  return <GalleryItemShimmer key={index} />;
27
27
  }
28
+
29
+ const firstLetter = item.name.charAt(0).toUpperCase();
30
+
31
+ if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
28
32
  return (
29
33
  <GalleryItem
30
34
  key={item.id}
@@ -32,8 +36,9 @@ const Gallery = props => {
32
36
  storeConfig={storeConfig}
33
37
  />
34
38
  );
39
+ }
35
40
  }),
36
- [items, storeConfig]
41
+ [items, storeConfig, activeLetter]
37
42
  );
38
43
 
39
44
  return (