@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.
- package/package.json +1 -1
- package/src/components/BrandLandingPage/brandLanding.js +0 -5
- package/src/components/CheckoutHeader/accountTrigger.js +104 -0
- package/src/components/CheckoutHeader/cartTrigger.js +110 -0
- package/src/components/CheckoutHeader/cartTrigger.module.css +47 -0
- package/src/components/CheckoutHeader/storeSwitcher.js +119 -0
- package/src/components/CheckoutHeader/storeSwitcher.module.css +107 -0
- package/src/components/CheckoutHeader/switcherItem.js +47 -0
- package/src/components/CheckoutHeader/wishlistTrigger.js +23 -0
- package/src/components/FilterListContent/filterListPage.js +0 -25
- package/src/components/FilterTop/filterTop.js +1 -1
- package/src/components/HelpCenter/helpCenter.js +151 -0
- package/src/components/HelpCenter/helpcenter.module.css +225 -0
- package/src/components/HelpCenter/index.js +1 -0
- package/src/components/HelpCenter/questionDetail.js +89 -0
- package/src/components/ProductContent/productContent.js +1 -1
- package/src/components/RMAPage/components/productItem.css +15 -0
- package/src/components/RMAPage/components/productItem.module.css +15 -0
- package/src/components/RelatedProducts/index.js +1 -0
- package/src/components/RelatedProducts/relatedProducts.js +44 -0
- package/src/components/SellerMegaMenu/__tests__/MegaMenu.spec.js +91 -0
- package/src/components/SellerMegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
- package/src/components/SellerMegaMenu/__tests__/Submenu.spec.js +61 -0
- package/src/components/SellerMegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
- package/src/components/SellerMegaMenu/customSubmenuColumn.js +75 -0
- package/src/components/SellerMegaMenu/customSubmenuColumn.module.css +29 -0
- package/src/components/SellerMegaMenu/shopByColumn.js +121 -0
- package/src/components/SellerProducts/productContent.js +2 -4
- package/src/components/SetsData/setsData.js +0 -25
- package/src/components/ShopBy/shopBy.js +3 -78
- package/src/components/ShopBySets/shopBySets.js +2 -2
- package/src/components/ShowMore/showMore.js +3 -49
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -15
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderRow.gql.js +0 -11
- package/src/overwrites/peregrine/lib/talons/RelatedProducts/productReview.gql.js +89 -0
- package/src/overwrites/peregrine/lib/talons/RelatedProducts/useRelatedProducts.js +833 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +0 -16
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +1 -5
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +118 -62
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +3 -50
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +1 -7
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/editModal.js +41 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.js +80 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.module.css +33 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.js +153 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.module.css +52 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.js +31 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/quantity.js +40 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +21 -92
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +6 -2
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +0 -21
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/Reviews/reviewModal.js +8 -0
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderHistoryPage.js +3 -3
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +4 -85
- package/src/talons/HelpCenter/helpCenter.gql.js +93 -0
- package/src/talons/HelpCenter/useHelpCenter.js +59 -0
- package/src/talons/ProductContent/productContent.gql.js +0 -16
- package/src/talons/ProductContent/useProductContent.js +0 -4
- package/src/talons/RelatedProducts/relatedProducts.gql.js +209 -0
- package/src/talons/RelatedProducts/useRelatedProducts.js +112 -0
- package/src/talons/SellerProducts/productContent.gql.js +1 -17
- package/src/talons/SellerProducts/useProductContent.js +1 -36
- package/src/components/AttributesBlock/attributesBlock.js +0 -54
- package/src/components/AttributesBlock/attributesBlock.module.css +0 -28
- package/src/components/ShopBy/shopBy copy.js +0 -172
- package/src/components/SubCategory/customSubCategory.js +0 -45
- package/src/components/SubCategory/customSubCategory.module.css +0 -22
- package/src/talons/AttributesBlock/attributesBlock.gql.js +0 -15
- package/src/talons/AttributesBlock/useAttributesBlock.js +0 -38
- package/src/talons/SubCategory/useCustomSubCategory.js +0 -50
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
2
|
-
import { useMutation } from '@apollo/client';
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
3
2
|
import { arrayOf, number, shape, string } from 'prop-types';
|
|
4
3
|
import { ChevronDown, ChevronUp } from 'react-feather';
|
|
5
4
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
6
5
|
import Price from '@magento/venia-ui/lib/components/Price';
|
|
7
6
|
import { useOrderRow } from '@magento/peregrine/lib/talons/OrderHistoryPage/useOrderRow';
|
|
8
|
-
import { COMPLETE_PREORDER } from '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderRow.gql';
|
|
9
|
-
import { useCartContext } from '@magento/peregrine/lib/context/cart';
|
|
10
|
-
import { useToasts } from '@magento/peregrine/lib/Toasts';
|
|
11
7
|
|
|
12
8
|
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
13
9
|
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
@@ -23,8 +19,6 @@ import { Link, useHistory } from 'react-router-dom';
|
|
|
23
19
|
const OrderRow = props => {
|
|
24
20
|
const { order, setReviewOrder } = props;
|
|
25
21
|
const { formatMessage } = useIntl();
|
|
26
|
-
const [{ cartId }] = useCartContext();
|
|
27
|
-
const [, { addToast }] = useToasts();
|
|
28
22
|
const history = useHistory();
|
|
29
23
|
const {
|
|
30
24
|
invoices,
|
|
@@ -35,7 +29,7 @@ const OrderRow = props => {
|
|
|
35
29
|
status,
|
|
36
30
|
total
|
|
37
31
|
} = order;
|
|
38
|
-
|
|
32
|
+
|
|
39
33
|
const { grand_total: grandTotal } = total;
|
|
40
34
|
const { currency, value: orderTotal } = grandTotal;
|
|
41
35
|
|
|
@@ -53,12 +47,7 @@ const OrderRow = props => {
|
|
|
53
47
|
const hasInvoice = !!invoices.length;
|
|
54
48
|
const hasShipment = !!shipments.length;
|
|
55
49
|
let derivedStatus;
|
|
56
|
-
if (status === '
|
|
57
|
-
derivedStatus = formatMessage({
|
|
58
|
-
id: 'orderRow.canceledText',
|
|
59
|
-
defaultMessage: 'Canceled'
|
|
60
|
-
});
|
|
61
|
-
} else if (status === 'Complete') {
|
|
50
|
+
if (status === 'Complete') {
|
|
62
51
|
derivedStatus = formatMessage({
|
|
63
52
|
id: 'orderRow.deliveredText',
|
|
64
53
|
defaultMessage: 'Delivered'
|
|
@@ -112,9 +101,6 @@ const OrderRow = props => {
|
|
|
112
101
|
);
|
|
113
102
|
|
|
114
103
|
const badgeStatusStyle = () => {
|
|
115
|
-
if (status === 'Canceled') {
|
|
116
|
-
return 'text-red-600 text-[14px] font-medium py-[5px] border-none';
|
|
117
|
-
}
|
|
118
104
|
return 'text-blue-700 text-[14px] font-medium py-[5px] border-none';
|
|
119
105
|
}
|
|
120
106
|
|
|
@@ -152,58 +138,6 @@ const OrderRow = props => {
|
|
|
152
138
|
|
|
153
139
|
const showNewReturnButton = status === 'Complete' || derivedStatus === formatMessage({ id: 'orderRow.deliveredText', defaultMessage: 'Delivered' });
|
|
154
140
|
|
|
155
|
-
// Find a preorder item eligible for completion (deposit type)
|
|
156
|
-
const preorderItem = useMemo(() => {
|
|
157
|
-
if (!Array.isArray(items)) return null;
|
|
158
|
-
return items.find(it => it && it.is_preorder && String(it.pre_order_payment_type).toLowerCase() === 'deposit');
|
|
159
|
-
}, [items]);
|
|
160
|
-
|
|
161
|
-
const [completePreorder, { loading: completingPreorder }] = useMutation(COMPLETE_PREORDER);
|
|
162
|
-
|
|
163
|
-
const handleCompletePreorder = async () => {
|
|
164
|
-
try {
|
|
165
|
-
const targetItem = preorderItem || (Array.isArray(items) && items.length ? items[0] : null);
|
|
166
|
-
if (!targetItem) {
|
|
167
|
-
console.warn('No eligible preorder item found to complete preorder');
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const input = {
|
|
172
|
-
cartId: cartId || '',
|
|
173
|
-
item_id: String(targetItem.id || ''),
|
|
174
|
-
order_reference: String(orderNumber || ''),
|
|
175
|
-
product_name: String(targetItem.product_name || ''),
|
|
176
|
-
qty: Number(targetItem.quantity_ordered || 1)
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const { data: result } = await completePreorder({ variables: { input } });
|
|
180
|
-
const payload = result?.completePreorder;
|
|
181
|
-
if (payload?.success) {
|
|
182
|
-
addToast({
|
|
183
|
-
type: 'success',
|
|
184
|
-
message: payload.message || formatMessage({ id: 'orderRow.completePreorder.success', defaultMessage: 'Preorder completed successfully.' }),
|
|
185
|
-
dismissable: true,
|
|
186
|
-
timeout: 5000
|
|
187
|
-
});
|
|
188
|
-
history.push('/cart');
|
|
189
|
-
} else {
|
|
190
|
-
addToast({
|
|
191
|
-
type: 'error',
|
|
192
|
-
message: payload?.message || formatMessage({ id: 'orderRow.completePreorder.failed', defaultMessage: 'Failed to complete preorder.' }),
|
|
193
|
-
dismissable: true,
|
|
194
|
-
timeout: 7000
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
} catch (e) {
|
|
198
|
-
addToast({
|
|
199
|
-
type: 'error',
|
|
200
|
-
message: e?.message || formatMessage({ id: 'orderRow.completePreorder.error', defaultMessage: 'Something went wrong completing preorder.' }),
|
|
201
|
-
dismissable: true,
|
|
202
|
-
timeout: 7000
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
141
|
const handleNewReturn = () => {
|
|
208
142
|
// Inject product_image per item with safe fallbacks (prefer product_image_url from query)
|
|
209
143
|
let orderWithImages = { ...order };
|
|
@@ -246,6 +180,7 @@ const OrderRow = props => {
|
|
|
246
180
|
};
|
|
247
181
|
|
|
248
182
|
const handleWriteReview = useCallback(( order ) => {
|
|
183
|
+
console.log('order',order)
|
|
249
184
|
if (order) {
|
|
250
185
|
setReviewOrder(order);
|
|
251
186
|
}
|
|
@@ -342,22 +277,6 @@ const OrderRow = props => {
|
|
|
342
277
|
</span>
|
|
343
278
|
</>
|
|
344
279
|
)}
|
|
345
|
-
{preorderItem && (
|
|
346
|
-
<button
|
|
347
|
-
type="button"
|
|
348
|
-
onClick={handleCompletePreorder}
|
|
349
|
-
disabled={completingPreorder}
|
|
350
|
-
aria-busy={completingPreorder}
|
|
351
|
-
aria-disabled={completingPreorder}
|
|
352
|
-
className={`bg-blue-700 rounded-full px-[30px] py-[8px] text-[13px] font-medium text-white transition-all duration-300 ease-in-out ${completingPreorder ? 'opacity-60 cursor-not-allowed pointer-events-none bg-gray-200 text-white' : ''}`}
|
|
353
|
-
>
|
|
354
|
-
{completingPreorder ? (
|
|
355
|
-
<FormattedMessage id={'orderRow.completingPreorder'} defaultMessage={'Complete Loading...'} />
|
|
356
|
-
) : (
|
|
357
|
-
<FormattedMessage id={'orderRow.completePreorder'} defaultMessage={'Complete Preorder'} />
|
|
358
|
-
)}
|
|
359
|
-
</button>
|
|
360
|
-
)}
|
|
361
280
|
<Link
|
|
362
281
|
to={{
|
|
363
282
|
pathname: `/order-history/view/${orderNumber}`,
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const FAQ_CATEGORIES = gql`
|
|
4
|
+
query faqCategories {
|
|
5
|
+
faqCategories {
|
|
6
|
+
body_background
|
|
7
|
+
border_color
|
|
8
|
+
border_radius
|
|
9
|
+
border_width
|
|
10
|
+
category_id
|
|
11
|
+
creation_time
|
|
12
|
+
description
|
|
13
|
+
icon
|
|
14
|
+
is_active
|
|
15
|
+
margin_bottom
|
|
16
|
+
margin_left
|
|
17
|
+
meta_description
|
|
18
|
+
meta_keywords
|
|
19
|
+
page_title
|
|
20
|
+
parent_id
|
|
21
|
+
position
|
|
22
|
+
seller_id
|
|
23
|
+
status
|
|
24
|
+
store_id
|
|
25
|
+
title
|
|
26
|
+
title_background
|
|
27
|
+
title_color
|
|
28
|
+
title_size
|
|
29
|
+
update_time
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const FAQ_QUESTIONS = gql`
|
|
35
|
+
query faqQuestions {
|
|
36
|
+
faqQuestions {
|
|
37
|
+
_first_store_id
|
|
38
|
+
animation_class
|
|
39
|
+
animation_speed
|
|
40
|
+
answer
|
|
41
|
+
author_email
|
|
42
|
+
author_name
|
|
43
|
+
body_bg
|
|
44
|
+
body_color
|
|
45
|
+
body_size
|
|
46
|
+
border_width
|
|
47
|
+
creation_time
|
|
48
|
+
disklike
|
|
49
|
+
is_active
|
|
50
|
+
is_featured
|
|
51
|
+
like
|
|
52
|
+
meta_description
|
|
53
|
+
meta_keywords
|
|
54
|
+
page_title
|
|
55
|
+
question_active_icon
|
|
56
|
+
question_icon
|
|
57
|
+
question_id
|
|
58
|
+
question_margin
|
|
59
|
+
question_position
|
|
60
|
+
question_type
|
|
61
|
+
question_url
|
|
62
|
+
store_code
|
|
63
|
+
store_id
|
|
64
|
+
tags
|
|
65
|
+
title
|
|
66
|
+
title_bg
|
|
67
|
+
title_bg_active
|
|
68
|
+
title_border_color
|
|
69
|
+
title_border_radius
|
|
70
|
+
title_color
|
|
71
|
+
title_color_active
|
|
72
|
+
title_size
|
|
73
|
+
update_time
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
export const FAQ_TAGS = gql`
|
|
79
|
+
query faqTags {
|
|
80
|
+
faqTags {
|
|
81
|
+
alias
|
|
82
|
+
name
|
|
83
|
+
question_id
|
|
84
|
+
tag_id
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export default {
|
|
90
|
+
faqCategoriesQuery: FAQ_CATEGORIES,
|
|
91
|
+
faqQuestionsQuery: FAQ_QUESTIONS,
|
|
92
|
+
faqTagsQuery: FAQ_TAGS
|
|
93
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useQuery } from '@apollo/client';
|
|
4
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
5
|
+
import DEFAULT_OPERATIONS from './helpCenter.gql';
|
|
6
|
+
|
|
7
|
+
export const useHelpCenter = (props = {}) => {
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
|
|
10
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
faqCategoriesQuery,
|
|
14
|
+
faqQuestionsQuery,
|
|
15
|
+
faqTagsQuery
|
|
16
|
+
} = operations;
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
data: categoriesData,
|
|
20
|
+
loading: categoriesLoading,
|
|
21
|
+
error: categoriesError
|
|
22
|
+
} = useQuery(faqCategoriesQuery, {
|
|
23
|
+
fetchPolicy: 'cache-and-network'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
data: questionsData,
|
|
28
|
+
loading: questionsLoading,
|
|
29
|
+
error: questionsError
|
|
30
|
+
} = useQuery(faqQuestionsQuery, {
|
|
31
|
+
fetchPolicy: 'cache-and-network'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
data: tagsData,
|
|
36
|
+
loading: tagsLoading,
|
|
37
|
+
error: tagsError
|
|
38
|
+
} = useQuery(faqTagsQuery, {
|
|
39
|
+
fetchPolicy: 'cache-and-network'
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const loading = categoriesLoading || questionsLoading || tagsLoading;
|
|
43
|
+
const error = categoriesError || questionsError || tagsError || null;
|
|
44
|
+
|
|
45
|
+
const data = useMemo(() => ({
|
|
46
|
+
categories: categoriesData?.faqCategories || [],
|
|
47
|
+
questions: questionsData?.faqQuestions || [],
|
|
48
|
+
tags: tagsData?.faqTags || []
|
|
49
|
+
}), [categoriesData, questionsData, tagsData]);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
loading,
|
|
53
|
+
error,
|
|
54
|
+
data,
|
|
55
|
+
formatMessage
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default useHelpCenter;
|
|
@@ -33,23 +33,7 @@ export const GET_CATEGORY_CONTENT = gql`
|
|
|
33
33
|
description
|
|
34
34
|
url_key
|
|
35
35
|
url_path
|
|
36
|
-
hide_filters
|
|
37
|
-
allowed_filters {
|
|
38
|
-
code
|
|
39
|
-
}
|
|
40
36
|
prefixes
|
|
41
|
-
custom_subcategory {
|
|
42
|
-
name
|
|
43
|
-
path
|
|
44
|
-
}
|
|
45
|
-
attributes_block {
|
|
46
|
-
label
|
|
47
|
-
code
|
|
48
|
-
items {
|
|
49
|
-
label
|
|
50
|
-
value
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
37
|
parent {
|
|
54
38
|
uid
|
|
55
39
|
name
|
|
@@ -146,9 +146,6 @@ export const useProductContent = props => {
|
|
|
146
146
|
filters.push(newFilter);
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
const attributesBlock = categoryData && categoryData.categories.items.length
|
|
150
|
-
? categoryData.categories.items[0].attributes_block
|
|
151
|
-
: null;
|
|
152
149
|
const parent =
|
|
153
150
|
categoryData && categoryData.categories.items.length
|
|
154
151
|
? categoryData.categories.items[0].parent
|
|
@@ -196,7 +193,6 @@ export const useProductContent = props => {
|
|
|
196
193
|
totalPagesFromData,
|
|
197
194
|
children,
|
|
198
195
|
parent,
|
|
199
|
-
attributesBlock,
|
|
200
196
|
category,
|
|
201
197
|
virtualCategoryFilters,
|
|
202
198
|
paymentTypeOptions,
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const GET_STORE_CONFIG_DATA = gql`
|
|
4
|
+
query getStoreConfigData {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
|
+
storeConfig {
|
|
7
|
+
store_code
|
|
8
|
+
product_url_suffix
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const GET_SELLER_DETAIL_QUERY = gql`
|
|
14
|
+
query getSellerDetailForSellerPage($urlKey: String!, $getOtherInfo: Boolean, $getProducts: Boolean) {
|
|
15
|
+
sellerByUrl(seller_url: $urlKey, get_other_info: $getOtherInfo, get_products: $getProducts) {
|
|
16
|
+
seller_id
|
|
17
|
+
contact_number
|
|
18
|
+
shop_title
|
|
19
|
+
company
|
|
20
|
+
term_and_conditions
|
|
21
|
+
website_url
|
|
22
|
+
ship_to
|
|
23
|
+
ship_to_country
|
|
24
|
+
seller_rates {
|
|
25
|
+
total_count
|
|
26
|
+
page_info {
|
|
27
|
+
current_page
|
|
28
|
+
page_size
|
|
29
|
+
total_pages
|
|
30
|
+
}
|
|
31
|
+
items {
|
|
32
|
+
rating_id
|
|
33
|
+
seller_id
|
|
34
|
+
customer_id
|
|
35
|
+
rate1
|
|
36
|
+
rate2
|
|
37
|
+
rate3
|
|
38
|
+
rate4
|
|
39
|
+
rate5
|
|
40
|
+
rating
|
|
41
|
+
email
|
|
42
|
+
title
|
|
43
|
+
status
|
|
44
|
+
detail
|
|
45
|
+
nickname
|
|
46
|
+
created_at
|
|
47
|
+
verified_buyer
|
|
48
|
+
is_recommended
|
|
49
|
+
is_hidden
|
|
50
|
+
answer
|
|
51
|
+
admin_note
|
|
52
|
+
like_about
|
|
53
|
+
not_like_about
|
|
54
|
+
guest_email
|
|
55
|
+
plus_review
|
|
56
|
+
minus_review
|
|
57
|
+
report_abuse
|
|
58
|
+
country
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
products {
|
|
62
|
+
total_count
|
|
63
|
+
page_info {
|
|
64
|
+
current_page
|
|
65
|
+
page_size
|
|
66
|
+
total_pages
|
|
67
|
+
}
|
|
68
|
+
items {
|
|
69
|
+
name
|
|
70
|
+
sku
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
operating_hours {
|
|
74
|
+
day
|
|
75
|
+
status
|
|
76
|
+
time {
|
|
77
|
+
opening_time
|
|
78
|
+
closing_time
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
store_locators {
|
|
82
|
+
name
|
|
83
|
+
country
|
|
84
|
+
region
|
|
85
|
+
address_line_1
|
|
86
|
+
address_line_2
|
|
87
|
+
city
|
|
88
|
+
postcode
|
|
89
|
+
operating_hours {
|
|
90
|
+
day
|
|
91
|
+
status
|
|
92
|
+
time {
|
|
93
|
+
opening_time
|
|
94
|
+
closing_time
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
description
|
|
99
|
+
country
|
|
100
|
+
image
|
|
101
|
+
thumbnail
|
|
102
|
+
city
|
|
103
|
+
region
|
|
104
|
+
group
|
|
105
|
+
group_id
|
|
106
|
+
url
|
|
107
|
+
email
|
|
108
|
+
name
|
|
109
|
+
sale
|
|
110
|
+
creation_time
|
|
111
|
+
page_layout
|
|
112
|
+
status
|
|
113
|
+
position
|
|
114
|
+
twitter_id
|
|
115
|
+
facebook_id
|
|
116
|
+
gplus_id
|
|
117
|
+
youtube_id
|
|
118
|
+
vimeo_id
|
|
119
|
+
instagram_id
|
|
120
|
+
pinterest_id
|
|
121
|
+
linkedin_id
|
|
122
|
+
tw_active
|
|
123
|
+
fb_active
|
|
124
|
+
gplus_active
|
|
125
|
+
vimeo_active
|
|
126
|
+
instagram_active
|
|
127
|
+
pinterest_active
|
|
128
|
+
linkedin_active
|
|
129
|
+
banner_pic
|
|
130
|
+
shop_url
|
|
131
|
+
url_key
|
|
132
|
+
logo_pic
|
|
133
|
+
verify_status
|
|
134
|
+
product_count
|
|
135
|
+
telephone
|
|
136
|
+
creation_time
|
|
137
|
+
update_time
|
|
138
|
+
country_id
|
|
139
|
+
total_sold
|
|
140
|
+
operating_time
|
|
141
|
+
order_processing_time
|
|
142
|
+
shipping_partners
|
|
143
|
+
offers
|
|
144
|
+
benefits
|
|
145
|
+
product_shipping_info
|
|
146
|
+
prepare_time
|
|
147
|
+
response_ratio
|
|
148
|
+
response_time
|
|
149
|
+
store_id
|
|
150
|
+
products {
|
|
151
|
+
total_count
|
|
152
|
+
page_info {
|
|
153
|
+
page_size
|
|
154
|
+
current_page
|
|
155
|
+
}
|
|
156
|
+
items {
|
|
157
|
+
id
|
|
158
|
+
name
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
164
|
+
|
|
165
|
+
export const GET_COUPON_CODE_QUERY = gql`
|
|
166
|
+
query getSellerCoupons(
|
|
167
|
+
$sellerUrl: String!
|
|
168
|
+
$pageSize: Int
|
|
169
|
+
$currentPage: Int
|
|
170
|
+
$filters: CouponCodeFilterInput
|
|
171
|
+
) {
|
|
172
|
+
sellerCoupons(
|
|
173
|
+
sellerUrl: $sellerUrl
|
|
174
|
+
pageSize: $pageSize
|
|
175
|
+
currentPage: $currentPage
|
|
176
|
+
filters: $filters
|
|
177
|
+
) {
|
|
178
|
+
items {
|
|
179
|
+
code
|
|
180
|
+
coupon_id
|
|
181
|
+
couponcode_id
|
|
182
|
+
created_at
|
|
183
|
+
description
|
|
184
|
+
discount_amount
|
|
185
|
+
expiration_date
|
|
186
|
+
from_date
|
|
187
|
+
is_active
|
|
188
|
+
name
|
|
189
|
+
seller_id
|
|
190
|
+
times_used
|
|
191
|
+
to_date
|
|
192
|
+
type
|
|
193
|
+
uses_per_customer
|
|
194
|
+
}
|
|
195
|
+
page_info {
|
|
196
|
+
current_page
|
|
197
|
+
page_size
|
|
198
|
+
total_pages
|
|
199
|
+
}
|
|
200
|
+
total_count
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
export default {
|
|
206
|
+
getStoreConfigData: GET_STORE_CONFIG_DATA,
|
|
207
|
+
getSellerDetailQuery: GET_SELLER_DETAIL_QUERY,
|
|
208
|
+
getCouponCodeQuery: GET_COUPON_CODE_QUERY,
|
|
209
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
};
|
|
@@ -34,23 +34,7 @@ export const GET_CATEGORY_CONTENT = gql`
|
|
|
34
34
|
description
|
|
35
35
|
url_key
|
|
36
36
|
url_path
|
|
37
|
-
|
|
38
|
-
allowed_filters {
|
|
39
|
-
code
|
|
40
|
-
}
|
|
41
|
-
prefixes
|
|
42
|
-
custom_subcategory {
|
|
43
|
-
name
|
|
44
|
-
path
|
|
45
|
-
}
|
|
46
|
-
attributes_block {
|
|
47
|
-
label
|
|
48
|
-
code
|
|
49
|
-
items {
|
|
50
|
-
label
|
|
51
|
-
value
|
|
52
|
-
}
|
|
53
|
-
}
|
|
37
|
+
prefixes
|
|
54
38
|
parent {
|
|
55
39
|
uid
|
|
56
40
|
name
|