@riosst100/pwa-marketplace 3.1.3 → 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/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/intercept.js +0 -14
- 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/Footer/sampleData.js +1 -1
- 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/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}`,
|
|
@@ -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
|
|
@@ -9,9 +9,6 @@ import DEFAULT_OPERATIONS from './productContent.gql';
|
|
|
9
9
|
export const useProductContent = props => {
|
|
10
10
|
const { sellerId, categoryId, data, pageSize = 6 } = props;
|
|
11
11
|
|
|
12
|
-
// const categoryId = 'MTI=';
|
|
13
|
-
// alert(categoryId)
|
|
14
|
-
|
|
15
12
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
16
13
|
|
|
17
14
|
const {
|
|
@@ -22,16 +19,12 @@ export const useProductContent = props => {
|
|
|
22
19
|
} = operations;
|
|
23
20
|
|
|
24
21
|
const placeholderItems = Array.from({ length: pageSize }).fill(null);
|
|
25
|
-
|
|
26
|
-
// console.log(getStoreConfigQuery)
|
|
27
22
|
|
|
28
23
|
const { data: storeConfigData } = useQuery(getStoreConfigQuery, {
|
|
29
24
|
fetchPolicy: 'cache-and-network',
|
|
30
25
|
nextFetchPolicy: 'cache-first'
|
|
31
26
|
});
|
|
32
27
|
|
|
33
|
-
// return '';
|
|
34
|
-
|
|
35
28
|
const virtualCategoryFilters = useMemo(() => {
|
|
36
29
|
if (storeConfigData) {
|
|
37
30
|
const data = storeConfigData.storeConfig.custommarketplace_plp_filters_virtualcategory;
|
|
@@ -135,18 +128,9 @@ export const useProductContent = props => {
|
|
|
135
128
|
filters.push(newFilter);
|
|
136
129
|
});
|
|
137
130
|
|
|
138
|
-
const attributesBlock = null;
|
|
139
131
|
const parent = null;
|
|
140
|
-
// const categoryName = null;
|
|
141
132
|
const categoryDescription = null;
|
|
142
|
-
|
|
143
|
-
// const attributesBlock = categoryData && categoryData.categories.items.length
|
|
144
|
-
// ? categoryData.categories.items[0].attributes_block
|
|
145
|
-
// : null;
|
|
146
|
-
// const parent =
|
|
147
|
-
// categoryData && categoryData.categories.items.length
|
|
148
|
-
// ? categoryData.categories.items[0].parent
|
|
149
|
-
// : null;
|
|
133
|
+
|
|
150
134
|
const totalPagesFromData = data
|
|
151
135
|
? data.page_info.total_pages
|
|
152
136
|
: null;
|
|
@@ -156,28 +140,10 @@ export const useProductContent = props => {
|
|
|
156
140
|
categoryData && categoryData.categories.items.length
|
|
157
141
|
? categoryData.categories.items[0].name
|
|
158
142
|
: null;
|
|
159
|
-
// const categoryDescription =
|
|
160
|
-
// categoryData && categoryData.categories.items.length
|
|
161
|
-
// ? categoryData.categories.items[0].description
|
|
162
|
-
// : null;
|
|
163
143
|
const availableSortMethods = sortData
|
|
164
144
|
? sortData.products.sort_fields.options
|
|
165
145
|
: null;
|
|
166
146
|
|
|
167
|
-
// useEffect(() => {
|
|
168
|
-
// if (!categoryLoading && categoryData.categories.items.length > 0) {
|
|
169
|
-
// dispatch({
|
|
170
|
-
// type: 'CATEGORY_PAGE_VIEW',
|
|
171
|
-
// payload: {
|
|
172
|
-
// id: categoryData.categories.items[0].uid,
|
|
173
|
-
// name: categoryData.categories.items[0].name,
|
|
174
|
-
// url_key: categoryData.categories.items[0].url_key,
|
|
175
|
-
// url_path: categoryData.categories.items[0].url_path
|
|
176
|
-
// }
|
|
177
|
-
// });
|
|
178
|
-
// }
|
|
179
|
-
// }, [categoryData, dispatch, categoryLoading]);
|
|
180
|
-
|
|
181
147
|
return {
|
|
182
148
|
availableSortMethods,
|
|
183
149
|
categoryName,
|
|
@@ -188,7 +154,6 @@ export const useProductContent = props => {
|
|
|
188
154
|
totalPagesFromData,
|
|
189
155
|
children,
|
|
190
156
|
parent,
|
|
191
|
-
attributesBlock,
|
|
192
157
|
category,
|
|
193
158
|
virtualCategoryFilters
|
|
194
159
|
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useAttributesBlock } from '@riosst100/pwa-marketplace/src/talons/AttributesBlock/useAttributesBlock';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Link } from 'react-router-dom';
|
|
4
|
-
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
5
|
-
import defaultClasses from './attributesBlock.module.css';
|
|
6
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
-
|
|
8
|
-
const AttributesBlock = props => {
|
|
9
|
-
const { attributesBlock, category } = props;
|
|
10
|
-
|
|
11
|
-
const talonProps = useAttributesBlock({ attributesBlock });
|
|
12
|
-
|
|
13
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
categoryUrlSuffix,
|
|
17
|
-
getPath
|
|
18
|
-
} = talonProps;
|
|
19
|
-
|
|
20
|
-
const result = [];
|
|
21
|
-
|
|
22
|
-
attributesBlock && attributesBlock.map(({ label, code, items }, index) => {
|
|
23
|
-
|
|
24
|
-
const itemsResult = [];
|
|
25
|
-
|
|
26
|
-
items && items.map(({ label, value }, index) => {
|
|
27
|
-
const path = resourceUrl(
|
|
28
|
-
`/${category.url_path}${categoryUrlSuffix || ''}?${code}[filter]=${label},${value}`
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
itemsResult.push(
|
|
32
|
-
<>
|
|
33
|
-
<Link
|
|
34
|
-
key={index}
|
|
35
|
-
to={path}
|
|
36
|
-
>
|
|
37
|
-
<li className={classes.item}>{label}</li>
|
|
38
|
-
</Link>
|
|
39
|
-
</>
|
|
40
|
-
)
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
result.push(
|
|
44
|
-
<span key={index}>
|
|
45
|
-
<div className={classes.title}>{label}</div>
|
|
46
|
-
<ul className={classes.root}>{itemsResult}</ul>
|
|
47
|
-
</span>
|
|
48
|
-
)
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default AttributesBlock;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.root {
|
|
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
|
-
.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
|
-
.title {
|
|
25
|
-
composes: pb-3 from global;
|
|
26
|
-
composes: font-bold from global;
|
|
27
|
-
composes: text-[14px] from global;
|
|
28
|
-
}
|