@riosst100/pwa-marketplace 3.1.2 → 3.1.4

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.
Files changed (76) hide show
  1. package/package.json +1 -1
  2. package/src/components/BrandLandingPage/brandLanding.js +0 -5
  3. package/src/components/CheckoutHeader/accountTrigger.js +104 -0
  4. package/src/components/CheckoutHeader/cartTrigger.js +110 -0
  5. package/src/components/CheckoutHeader/cartTrigger.module.css +47 -0
  6. package/src/components/CheckoutHeader/storeSwitcher.js +119 -0
  7. package/src/components/CheckoutHeader/storeSwitcher.module.css +107 -0
  8. package/src/components/CheckoutHeader/switcherItem.js +47 -0
  9. package/src/components/CheckoutHeader/wishlistTrigger.js +23 -0
  10. package/src/components/FilterListContent/filterListPage.js +0 -25
  11. package/src/components/FilterTop/filterTop.js +1 -1
  12. package/src/components/HelpCenter/helpCenter.js +151 -0
  13. package/src/components/HelpCenter/helpcenter.module.css +225 -0
  14. package/src/components/HelpCenter/index.js +1 -0
  15. package/src/components/HelpCenter/questionDetail.js +89 -0
  16. package/src/components/ProductContent/productContent.js +1 -1
  17. package/src/components/RMAPage/components/productItem.css +15 -0
  18. package/src/components/RMAPage/components/productItem.module.css +15 -0
  19. package/src/components/RelatedProducts/index.js +1 -0
  20. package/src/components/RelatedProducts/relatedProducts.js +44 -0
  21. package/src/components/SellerMegaMenu/__tests__/MegaMenu.spec.js +91 -0
  22. package/src/components/SellerMegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
  23. package/src/components/SellerMegaMenu/__tests__/Submenu.spec.js +61 -0
  24. package/src/components/SellerMegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
  25. package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
  26. package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
  27. package/src/components/SellerMegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
  28. package/src/components/SellerMegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
  29. package/src/components/SellerMegaMenu/customSubmenuColumn.js +75 -0
  30. package/src/components/SellerMegaMenu/customSubmenuColumn.module.css +29 -0
  31. package/src/components/SellerMegaMenu/shopByColumn.js +121 -0
  32. package/src/components/SellerProducts/productContent.js +2 -4
  33. package/src/components/SetsData/setsData.js +0 -25
  34. package/src/components/ShopBy/shopBy.js +3 -78
  35. package/src/components/ShopBySets/shopBySets.js +2 -2
  36. package/src/components/ShowMore/showMore.js +3 -49
  37. package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -15
  38. package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderRow.gql.js +0 -11
  39. package/src/overwrites/peregrine/lib/talons/RelatedProducts/productReview.gql.js +89 -0
  40. package/src/overwrites/peregrine/lib/talons/RelatedProducts/useRelatedProducts.js +833 -0
  41. package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +0 -16
  42. package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +1 -5
  43. package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +118 -62
  44. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +3 -50
  45. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +1 -7
  46. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/editModal.js +41 -0
  47. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/index.js +1 -0
  48. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.js +80 -0
  49. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.module.css +33 -0
  50. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.js +153 -0
  51. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.module.css +52 -0
  52. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.js +31 -0
  53. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.module.css +13 -0
  54. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/quantity.js +40 -0
  55. package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +21 -92
  56. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +6 -2
  57. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +0 -21
  58. package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/Reviews/reviewModal.js +8 -0
  59. package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderHistoryPage.js +3 -3
  60. package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +4 -85
  61. package/src/talons/HelpCenter/helpCenter.gql.js +93 -0
  62. package/src/talons/HelpCenter/useHelpCenter.js +59 -0
  63. package/src/talons/ProductContent/productContent.gql.js +0 -16
  64. package/src/talons/ProductContent/useProductContent.js +0 -4
  65. package/src/talons/RelatedProducts/relatedProducts.gql.js +209 -0
  66. package/src/talons/RelatedProducts/useRelatedProducts.js +112 -0
  67. package/src/talons/SellerProducts/productContent.gql.js +1 -17
  68. package/src/talons/SellerProducts/useProductContent.js +1 -36
  69. package/src/components/AttributesBlock/attributesBlock.js +0 -54
  70. package/src/components/AttributesBlock/attributesBlock.module.css +0 -28
  71. package/src/components/ShopBy/shopBy copy.js +0 -172
  72. package/src/components/SubCategory/customSubCategory.js +0 -45
  73. package/src/components/SubCategory/customSubCategory.module.css +0 -22
  74. package/src/talons/AttributesBlock/attributesBlock.gql.js +0 -15
  75. package/src/talons/AttributesBlock/useAttributesBlock.js +0 -38
  76. package/src/talons/SubCategory/useCustomSubCategory.js +0 -50
@@ -0,0 +1,151 @@
1
+ import React, { useMemo, useCallback, useState } from 'react';
2
+ import { Link, useLocation, useHistory } from 'react-router-dom';
3
+ import useHelpCenter from '@riosst100/pwa-marketplace/src/talons/HelpCenter/useHelpCenter';
4
+ import classes from './helpcenter.module.css';
5
+
6
+ const HelpCenter = () => {
7
+ const { loading, error, data } = useHelpCenter();
8
+ const history = useHistory();
9
+ const location = useLocation();
10
+
11
+ const queryParams = new URLSearchParams(location.search);
12
+ const activeTag = queryParams.get('tag') || '';
13
+
14
+ const tagCounts = useMemo(() => {
15
+ const counts = {};
16
+ (data.questions || []).forEach(q => {
17
+ const tags = Array.isArray(q.tags) ? q.tags : (typeof q.tags === 'string' ? q.tags.split(',') : []);
18
+ tags.map(t => t && t.trim()).filter(Boolean).forEach(t => {
19
+ counts[t] = (counts[t] || 0) + 1;
20
+ });
21
+ });
22
+ return counts;
23
+ }, [data.questions]);
24
+
25
+ const [expandedId, setExpandedId] = useState(null);
26
+ const toggleExpanded = useCallback((id) => {
27
+ setExpandedId(prev => prev === id ? null : id);
28
+ }, []);
29
+
30
+ const getExcerpt = useCallback((html, limit = 420) => {
31
+ if (!html) return { text: '', truncated: false };
32
+ const text = html
33
+ .replace(/<style[\s\S]*?<\/style>/gi, ' ')
34
+ .replace(/<script[\s\S]*?<\/script>/gi, ' ')
35
+ .replace(/<[^>]+>/g, ' ')
36
+ .replace(/&nbsp;/g, ' ')
37
+ .replace(/\s+/g, ' ')
38
+ .trim();
39
+ if (text.length <= limit) return { text, truncated: false };
40
+ const cut = text.slice(0, limit);
41
+ const lastSpace = cut.lastIndexOf(' ');
42
+ const snippet = (lastSpace > 0 ? cut.slice(0, lastSpace) : cut).trim() + '...';
43
+ return { text: snippet, truncated: true };
44
+ }, []);
45
+
46
+ const visibleQuestions = useMemo(() => {
47
+ const qs = data.questions || [];
48
+ if (!activeTag) return qs;
49
+ return qs.filter(q => {
50
+ const tags = Array.isArray(q.tags) ? q.tags : (typeof q.tags === 'string' ? q.tags.split(',') : []);
51
+ return tags.map(t => t && t.trim()).includes(activeTag);
52
+ });
53
+ }, [data.questions, activeTag]);
54
+
55
+ const onSelectTag = useCallback(tag => {
56
+ const params = new URLSearchParams(location.search);
57
+ if (tag) {
58
+ params.set('tag', tag);
59
+ } else {
60
+ params.delete('tag');
61
+ }
62
+ history.push({ pathname: location.pathname, search: params.toString() });
63
+ }, [history, location]);
64
+
65
+ if (loading) {
66
+ return <div>Loading Help Center…</div>;
67
+ }
68
+
69
+ if (error) {
70
+ return <div>We\'re sorry, an error has occurred while generating this content.</div>;
71
+ }
72
+
73
+ return (
74
+ <div className={classes.container}>
75
+ <h1 className={classes.title}>User Help Center</h1>
76
+ <div className={classes.grid}>
77
+ <aside className={classes.sidebar}>
78
+ <div className={classes.sidebarHeader}>TAGS</div>
79
+ <div className={classes.tagsWrap}>
80
+ {Object.keys(tagCounts).length === 0 && (
81
+ <span className={classes.emptyState}>No tags</span>
82
+ )}
83
+ {Object.entries(tagCounts).map(([tag, count]) => (
84
+ <button
85
+ key={tag}
86
+ onClick={() => onSelectTag(tag)}
87
+ className={`${classes.tagButton} ${activeTag === tag ? classes.tagButtonActive : ''}`}
88
+ >
89
+ {tag.toUpperCase()} ({count})
90
+ </button>
91
+ ))}
92
+ </div>
93
+ </aside>
94
+ <main className={classes.main}>
95
+ {activeTag && (
96
+ <h2 className={classes.tagTitle}>Tag : {activeTag}</h2>
97
+ )}
98
+ {visibleQuestions.map(q => {
99
+ const isOpen = expandedId === q.question_id;
100
+ return (
101
+ <article key={q.question_id} className={classes.questionCard}>
102
+ <header
103
+ onClick={() => toggleExpanded(q.question_id)}
104
+ className={`${classes.questionHeader} ${isOpen ? classes.questionHeaderOpen : ''}`}
105
+ >
106
+ <span className={classes.plusIcon}>{isOpen ? '−' : '+'}</span>
107
+ {q.title}
108
+ </header>
109
+ {isOpen && (
110
+ <section className={classes.questionBody}>
111
+ {q.answer ? (
112
+ (() => {
113
+ const { text, truncated } = getExcerpt(q.answer);
114
+ return (
115
+ <>
116
+ <p className={classes.excerpt}>{text} {truncated && (
117
+ <Link to={`/help-center/question/${q.question_id}`} className={classes.tagLink}>Read more</Link>
118
+ )}</p>
119
+ </>
120
+ );
121
+ })()
122
+ ) : (
123
+ <div>We\'re sorry, an error has occurred while generating this content.</div>
124
+ )}
125
+ <div className={classes.published}>
126
+ <small>
127
+ {q.update_time ? `on ${new Date(q.update_time).toLocaleDateString()} ` : ''}
128
+ Published in: {Array.isArray(q.tags) ? (
129
+ q.tags.map((t, idx) => (
130
+ <Link key={idx} to={`/help-center?tag=${encodeURIComponent(t)}`} className={classes.tagLink}>{t}{idx < q.tags.length - 1 ? ', ' : ''}</Link>
131
+ ))
132
+ ) : (
133
+ <Link to={`/help-center?tag=${encodeURIComponent(q.tags)}`} className={classes.tagLink}>{q.tags}</Link>
134
+ )}
135
+ </small>
136
+ </div>
137
+ </section>
138
+ )}
139
+ </article>
140
+ );
141
+ })}
142
+ {visibleQuestions.length === 0 && (
143
+ <div className={classes.emptyState}>No questions found.</div>
144
+ )}
145
+ </main>
146
+ </div>
147
+ </div>
148
+ );
149
+ };
150
+
151
+ export default HelpCenter;
@@ -0,0 +1,225 @@
1
+ .container {}
2
+
3
+ .grid {
4
+ display: grid;
5
+ grid-template-columns: 280px 1fr;
6
+ gap: 24px;
7
+ }
8
+
9
+ .title {
10
+ margin-top: 16px;
11
+ font-size: 17px;
12
+ font-weight: 700;
13
+ margin-bottom: 16px;
14
+ }
15
+
16
+ .detailTitle {
17
+ margin-top: 8px;
18
+ margin-bottom: 16px;
19
+ font-size: 32px;
20
+ line-height: 1.25;
21
+ font-weight: 700;
22
+ }
23
+
24
+ .sidebar {
25
+ border: 1px solid #E6E9EA;
26
+ border-radius: 6px;
27
+ max-height: max-content;
28
+ }
29
+
30
+ .sidebarHeader {
31
+ padding: 12px;
32
+ border-bottom: 1px solid #E6E9EA;
33
+ font-weight: 600;
34
+ background-color: #F2F2F2;
35
+ }
36
+
37
+ .tagsWrap {
38
+ padding: 12px;
39
+ display: flex;
40
+ flex-wrap: wrap;
41
+ gap: 8px;
42
+ }
43
+
44
+ .tagButton {
45
+ border: 1px solid #E6E9EA;
46
+ padding: 8px 10px;
47
+ background: #F8F8F8;
48
+ color: #f76b1c;
49
+ cursor: pointer;
50
+ }
51
+
52
+ .tagButtonActive {
53
+ background: #fff3e6;
54
+ }
55
+
56
+ .main {}
57
+
58
+ .tagTitle {
59
+ margin: 0;
60
+ margin-bottom: 16px;
61
+ }
62
+
63
+ .questionCard {
64
+ border: 1px solid #E6E9EA;
65
+ border-radius: 6px;
66
+ margin-bottom: 16px;
67
+ }
68
+
69
+ .questionCardDetail {
70
+ border-radius: 6px;
71
+ margin-bottom: 16px;
72
+ }
73
+
74
+ .questionHeader {
75
+ padding: 12px;
76
+ background: #F2F2F2;
77
+ color: #f76b1c;
78
+ font-weight: 700;
79
+ display: flex;
80
+ align-items: center;
81
+ gap: 8px;
82
+ cursor: pointer;
83
+ }
84
+
85
+ .questionHeaderOpen {
86
+ background: #fff3e6;
87
+ }
88
+
89
+ .plusIcon {
90
+ display: inline-flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ width: 18px;
94
+ height: 18px;
95
+ border-radius: 3px;
96
+ background: #f76b1c;
97
+ color: #fff;
98
+ font-size: 14px;
99
+ line-height: 18px;
100
+ }
101
+
102
+ .questionBody {
103
+ padding: 16px 12px;
104
+ color: #292D32;
105
+ font-size: 16px;
106
+ line-height: 1.7;
107
+ }
108
+ .container{
109
+ margin: 3rem 0px;
110
+ }
111
+ .excerpt {
112
+ color: #292D32;
113
+ }
114
+
115
+ .published {
116
+ margin-top: 8px;
117
+ color: #999999;
118
+ }
119
+
120
+ .tagLink {
121
+ color: #f76b1c;
122
+ }
123
+ .emptyState {
124
+ color: #999999;
125
+ }
126
+
127
+ .tagsLine {
128
+ margin-top: 16px;
129
+ display: flex;
130
+ align-items: center;
131
+ gap: 20px;
132
+ flex-wrap: wrap;
133
+ }
134
+
135
+ .tagPill {
136
+ display: inline-flex;
137
+ align-items: center;
138
+ gap: 8px;
139
+ padding: 4px 10px;
140
+ border-radius: 0px 4px 4px 0px;
141
+ background: #292D32;
142
+ color: #fff;
143
+ font-size: 12px;
144
+ position: relative;
145
+ text-transform: uppercase;
146
+ }
147
+
148
+ .tagPill::before {
149
+ content: '';
150
+ position: absolute;
151
+ left: -13px;
152
+ top: 50%;
153
+ transform: translateY(-53%);
154
+ width: 0;
155
+ height: 0;
156
+ border-top: 13px solid transparent;
157
+ border-bottom: 13px solid transparent;
158
+ border-right: 14px solid #292D32;
159
+ }
160
+
161
+ .tagPill::after {
162
+ content: '';
163
+ position: absolute;
164
+ left: -7px;
165
+ top: 50%;
166
+ transform: translateY(-50%);
167
+ width: 5px;
168
+ height: 5px;
169
+ background: #fff;
170
+ border-radius: 50%;
171
+ }
172
+
173
+ /* Mobile adjustments */
174
+ @media (max-width: 768px) {
175
+ .container {
176
+ margin: 1.5rem 0;
177
+ }
178
+ .grid {
179
+ grid-template-columns: 1fr;
180
+ gap: 16px;
181
+ }
182
+ .sidebar {
183
+ border-radius: 8px;
184
+ }
185
+ .tagsWrap {
186
+ gap: 6px;
187
+ }
188
+ .tagButton {
189
+ padding: 8px 12px;
190
+ border-radius: 6px;
191
+ }
192
+ .title {
193
+ font-size: 18px;
194
+ margin-bottom: 12px;
195
+ }
196
+ .tagTitle {
197
+ font-size: 16px;
198
+ margin-bottom: 12px;
199
+ }
200
+ .questionCard {
201
+ margin-bottom: 12px;
202
+ }
203
+ .questionHeader {
204
+ padding: 12px;
205
+ font-size: 14px;
206
+ }
207
+ .plusIcon {
208
+ width: 16px;
209
+ height: 16px;
210
+ font-size: 12px;
211
+ line-height: 16px;
212
+ }
213
+ .questionBody {
214
+ padding: 12px;
215
+ font-size: 15px;
216
+ line-height: 1.6;
217
+ }
218
+ .tagsLine {
219
+ gap: 18px;
220
+ }
221
+ .tagPill {
222
+ font-size: 11px;
223
+ padding: 4px 8px;
224
+ }
225
+ }
@@ -0,0 +1 @@
1
+ export { default } from './helpCenter';
@@ -0,0 +1,89 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Link, useParams } from 'react-router-dom';
3
+ import useHelpCenter from '@riosst100/pwa-marketplace/src/talons/HelpCenter/useHelpCenter';
4
+ import classes from './helpcenter.module.css';
5
+
6
+ const QuestionDetail = () => {
7
+ const { questionId } = useParams();
8
+ const { loading, error, data } = useHelpCenter();
9
+
10
+ const tagCounts = useMemo(() => {
11
+ const counts = {};
12
+ (data.questions || []).forEach(q => {
13
+ const tags = Array.isArray(q.tags) ? q.tags : (typeof q.tags === 'string' ? q.tags.split(',') : []);
14
+ tags.map(t => t && t.trim()).filter(Boolean).forEach(t => {
15
+ counts[t] = (counts[t] || 0) + 1;
16
+ });
17
+ });
18
+ return counts;
19
+ }, [data.questions]);
20
+
21
+ const question = useMemo(() => {
22
+ const id = Number(questionId);
23
+ return (data.questions || []).find(q => Number(q.question_id) === id) || null;
24
+ }, [data.questions, questionId]);
25
+
26
+ if (loading) return <div>Loading…</div>;
27
+ if (error) return <div>We\'re sorry, an error has occurred while generating this content.</div>;
28
+ if (!question) return <div className={classes.emptyState}>Question not found.</div>;
29
+
30
+ return (
31
+ <div className={classes.container}>
32
+ <div className={classes.grid}>
33
+ <aside className={classes.sidebar}>
34
+ <div className={classes.sidebarHeader}>TAGS</div>
35
+ <div className={classes.tagsWrap}>
36
+ {Object.keys(tagCounts).length === 0 && (
37
+ <span className={classes.emptyState}>No tags</span>
38
+ )}
39
+ {Object.entries(tagCounts).map(([tag, count]) => (
40
+ <Link key={tag} to={`/help-center?tag=${encodeURIComponent(tag)}`} className={`${classes.tagButton}`}>
41
+ {tag.toUpperCase()} ({count})
42
+ </Link>
43
+ ))}
44
+ </div>
45
+ </aside>
46
+ <main>
47
+ <h1 className={classes.detailTitle}>{question.title}</h1>
48
+ <article className={classes.questionCardDetail}>
49
+ <section className={classes.questionBody}>
50
+ {question.answer ? (
51
+ <div dangerouslySetInnerHTML={{ __html: question.answer }} />
52
+ ) : (
53
+ <div>We\'re sorry, an error has occurred while generating this content.</div>
54
+ )}
55
+ <div className={classes.published}>
56
+ <p>
57
+ {question.update_time ? `on ${new Date(question.update_time).toLocaleDateString()} ` : ''}
58
+ Published in: {Array.isArray(question.tags) ? (
59
+ question.tags.map((t, idx) => (
60
+ <Link key={idx} to={`/help-center?tag=${encodeURIComponent(t)}`} className={classes.tagLink}>{t}{idx < question.tags.length - 1 ? ', ' : ''}</Link>
61
+ ))
62
+ ) : (
63
+ <Link to={`/help-center?tag=${encodeURIComponent(question.tags)}`} className={classes.tagLink}>{question.tags}</Link>
64
+ )}
65
+ </p>
66
+ </div>
67
+ <div className={classes.tagsLine}>
68
+ <strong>TAGS:</strong>
69
+ {Array.isArray(question.tags) ? (
70
+ question.tags.map((t, idx) => (
71
+ <span key={idx} className={classes.tagPill}>
72
+ {String(t).toUpperCase()}
73
+ </span>
74
+ ))
75
+ ) : (
76
+ <span className={classes.tagPill}>
77
+ {String(question.tags).toUpperCase()}
78
+ </span>
79
+ )}
80
+ </div>
81
+ </section>
82
+ </article>
83
+ </main>
84
+ </div>
85
+ </div>
86
+ );
87
+ };
88
+
89
+ export default QuestionDetail;
@@ -74,7 +74,7 @@ const ProductContent = props => {
74
74
  // console.log(filters)
75
75
 
76
76
  const sidebar = shouldShowFilterButtons ? (
77
- <FilterSidebar hideFilters={false} children={[]} filters={filters} allowedFilters={[]} />
77
+ <FilterSidebar children={[]} filters={filters} />
78
78
  ) : shouldShowFilterShimmer ? (
79
79
  <FilterSidebarShimmer />
80
80
  ) : null;
@@ -0,0 +1,15 @@
1
+ .quantityLabel {
2
+ composes: font-medium from global;
3
+ composes: leading-normal from global;
4
+ composes: mb-sm from global;
5
+ composes: pt-xs from global;
6
+ composes: text-colorDefault from global;
7
+ }
8
+
9
+ .quantityRoot {
10
+ composes: root from '@magento/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css';
11
+ grid-template-columns: auto 4rem auto;
12
+ composes: justify-start from global;
13
+ composes: px-xs from global;
14
+ composes: py-0 from global;
15
+ }
@@ -0,0 +1,15 @@
1
+ .quantityLabel {
2
+ composes: font-medium from global;
3
+ composes: leading-normal from global;
4
+ composes: mb-sm from global;
5
+ composes: pt-xs from global;
6
+ composes: text-colorDefault from global;
7
+ }
8
+
9
+ .quantityRoot {
10
+ composes: root from '@magento/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css';
11
+ grid-template-columns: auto 4rem auto;
12
+ composes: justify-start from global;
13
+ composes: px-xs from global;
14
+ composes: py-0 from global;
15
+ }
@@ -0,0 +1 @@
1
+ export { default } from './relatedProducts';
@@ -0,0 +1,44 @@
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;
@@ -0,0 +1,91 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+
4
+ import { createTestInstance } from '@magento/peregrine';
5
+ import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
6
+
7
+ import MegaMenu from '../megaMenu';
8
+
9
+ jest.mock('@magento/venia-ui/lib/classify');
10
+ jest.mock('@magento/peregrine/lib/hooks/useIsInViewport');
11
+ jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenu', () => ({
12
+ useMegaMenu: jest.fn().mockReturnValue({
13
+ megaMenuData: {
14
+ id: 1,
15
+ name: 'Clothing',
16
+ children: [
17
+ {
18
+ id: 2,
19
+ name: 'Women',
20
+ url_path: 'women',
21
+ children: [
22
+ {
23
+ id: 5,
24
+ name: 'Bottoms',
25
+ url_path: 'bottoms',
26
+ isActive: true,
27
+ children: []
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ id: 3,
33
+ name: 'Men',
34
+ url_path: 'men',
35
+ children: []
36
+ },
37
+ {
38
+ id: 4,
39
+ name: 'Gear',
40
+ url_path: 'gear',
41
+ children: []
42
+ }
43
+ ]
44
+ },
45
+ activeCategoryId: 5,
46
+ categoryUrlSuffix: '.html',
47
+ useOutsideAlerter: () => {}
48
+ })
49
+ }));
50
+
51
+ describe('#MegaMenu', () => {
52
+ test('useEffect', () => {
53
+ const useEffect = jest.spyOn(React, 'useEffect');
54
+
55
+ const mockUseEffect = () => {
56
+ useEffect.mockImplementationOnce(mockFunction => mockFunction());
57
+ };
58
+
59
+ mockUseEffect();
60
+ });
61
+
62
+ test('not resetting the menu', () => {
63
+ const handleClickOutside = jest.fn();
64
+
65
+ expect(handleClickOutside).toHaveBeenCalledTimes(0);
66
+ });
67
+
68
+ it('renders empty div if not in viewport', () => {
69
+ useIsInViewport.mockReturnValue(false);
70
+
71
+ const instance = createTestInstance(
72
+ <MemoryRouter>
73
+ <MegaMenu />
74
+ </MemoryRouter>
75
+ );
76
+
77
+ expect(instance.toJSON()).toMatchSnapshot();
78
+ });
79
+
80
+ it('renders menu if in viewport', () => {
81
+ useIsInViewport.mockReturnValue(true);
82
+
83
+ const instance = createTestInstance(
84
+ <MemoryRouter>
85
+ <MegaMenu />
86
+ </MemoryRouter>
87
+ );
88
+
89
+ expect(instance.toJSON()).toMatchSnapshot();
90
+ });
91
+ });