@riosst100/pwa-marketplace 3.1.9 → 3.2.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/i18n/en_US.json +30 -1
- package/i18n/id_ID.json +30 -1
- package/package.json +1 -1
- package/src/components/AboutUs/aboutUs.js +9 -0
- package/src/components/AboutUs/index.js +1 -0
- package/src/components/AgeVerification/ageVerificationModal.js +163 -0
- package/src/components/AgeVerification/ageVerificationModal.module.css +85 -0
- package/src/components/AgeVerification/ageVerificationModal.shimmer.js +21 -0
- package/src/components/AgeVerification/index.js +2 -0
- package/src/components/AgeVerification/sellerCoupon.js +119 -0
- package/src/components/AgeVerification/sellerCouponCheckout.js +164 -0
- package/src/components/HelpCenter/helpCenter.js +95 -23
- package/src/components/HelpCenter/helpcenter.module.css +15 -2
- package/src/components/HelpCenter/questionDetail.js +1 -1
- package/src/components/LiveChat/MessagesModal.js +345 -0
- package/src/components/LiveChat/chatContent.js +3 -2
- package/src/components/MaintenancePage/maintenancePage.js +2 -2
- package/src/components/SellerCoupon/sellerCouponCheckout.js +2 -2
- package/src/components/SellerDetail/sellerDetail.js +37 -35
- package/src/components/WebsiteSwitcher/websiteSwitcherItem.js +17 -7
- package/src/intercept.js +7 -0
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +21 -1
- package/src/overwrites/venia-ui/lib/components/Footer/footer.js +21 -22
- package/src/overwrites/venia-ui/lib/components/Footer/sampleData.js +35 -31
- package/src/overwrites/venia-ui/lib/components/Header/header.js +2 -2
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +105 -3
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +55 -53
- package/src/talons/HelpCenter/helpCenter.gql.js +50 -39
- package/src/talons/HelpCenter/useHelpCenter.js +67 -7
- package/src/talons/Seller/seller.gql.js +90 -0
- package/src/talons/Seller/useSeller.js +102 -4
- package/src/talons/SellerProducts/useProductContent.js +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useHistory } from 'react-router-dom';
|
|
3
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
4
|
+
import { useCartContext } from '@magento/peregrine/lib/context/cart';
|
|
5
|
+
import { useApolloClient, useQuery } from '@apollo/client';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const storage = new BrowserPersistence();
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* This component checks for use of a store code in the url that is not the
|
|
@@ -12,42 +12,42 @@
|
|
|
12
12
|
* and reloads the page so that they are used in the graphQL headers.
|
|
13
13
|
*/
|
|
14
14
|
const StoreCodeRoute = () => {
|
|
15
|
-
|
|
15
|
+
const history = useHistory();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const websiteCodes = [];
|
|
18
|
+
const websiteStores = useMemo(() => ({}), []);
|
|
19
|
+
const storeCurrencies = useMemo(() => ({}), []);
|
|
20
|
+
const storeSecureBaseMediaUrl = useMemo(() => ({}), []);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
AVAILABLE_WEBSITES.forEach(store => {
|
|
23
|
+
websiteCodes.push(store.website_code);
|
|
24
|
+
websiteStores[store.website_code] = store.store_code;
|
|
25
|
+
storeCurrencies[store.store_code] = store.default_display_currency_code;
|
|
26
|
+
storeSecureBaseMediaUrl[store.store_code] = store.secure_base_media_url;
|
|
27
|
+
});
|
|
28
28
|
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
29
|
+
// Sort by length (longest first) to avoid false hits ie "en" matching just
|
|
30
|
+
// the "/en" in "/en-us/home.html" when "en-us" is also in storeCodes.
|
|
31
|
+
websiteCodes.sort((a, b) => b.length - a.length);
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// Find the store code in the url. This will always be the first path.
|
|
34
|
+
// ie `https://example.com/fr/foo/baz.html` => `fr`.
|
|
35
|
+
const { location } = globalThis;
|
|
36
|
+
const match = location && location.pathname.split("/")[1];
|
|
37
|
+
let websiteCodeInUrl = websiteCodes.find((str) => str === match);
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
|
|
39
|
+
// Determine what the current store code is using the configured basename.
|
|
40
|
+
const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
// If we find a store code in the url that is not the current one, update
|
|
45
45
|
// the storage value and refresh so that we start using the new code.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!websiteCodeInUrl) {
|
|
48
|
+
history.replace(location.pathname + location.search)
|
|
49
|
+
} else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
|
|
50
|
+
const storeCodeInUrl = websiteStores[websiteCodeInUrl];
|
|
51
51
|
|
|
52
52
|
// alert(storeCodeInUrl)
|
|
53
53
|
|
|
@@ -63,31 +63,33 @@ const StoreCodeRoute = () => {
|
|
|
63
63
|
|
|
64
64
|
// await apolloClient.clearCacheData(apolloClient, 'cart');
|
|
65
65
|
// await removeCart();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
alert('22ok')
|
|
67
|
+
storage.removeItem('cartId');
|
|
68
|
+
|
|
69
|
+
storage.setItem('store_view_code', storeCodeInUrl);
|
|
70
|
+
storage.setItem('website_code', websiteCodeInUrl);
|
|
71
|
+
storage.setItem(
|
|
72
|
+
'store_view_currency',
|
|
73
|
+
storeCurrencies[storeCodeInUrl]
|
|
74
|
+
);
|
|
75
|
+
storage.setItem(
|
|
76
|
+
'store_view_secure_base_media_url',
|
|
77
|
+
storeSecureBaseMediaUrl[storeCodeInUrl]
|
|
78
|
+
);
|
|
77
79
|
|
|
78
80
|
// We're required to reload the page as the basename doesn't
|
|
79
81
|
// change entirely without a full page reload.
|
|
80
82
|
// history.go(0);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
}
|
|
84
|
+
}, [
|
|
85
|
+
websiteCodeInUrl,
|
|
86
|
+
// currentWebsiteCode,
|
|
87
|
+
history
|
|
88
|
+
// , apolloClient, removeCart
|
|
89
|
+
// storeCodeInUrl,
|
|
90
|
+
// storeCurrencies,
|
|
91
|
+
// storeSecureBaseMediaUrl
|
|
92
|
+
]);
|
|
91
93
|
|
|
92
94
|
return null;
|
|
93
95
|
};
|
|
@@ -32,45 +32,56 @@ export const FAQ_CATEGORIES = gql`
|
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
34
|
export const FAQ_QUESTIONS = gql`
|
|
35
|
-
query faqQuestions
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
35
|
+
query faqQuestions(
|
|
36
|
+
$search: String
|
|
37
|
+
$pageSize: Int
|
|
38
|
+
$currentPage: Int
|
|
39
|
+
) {
|
|
40
|
+
faqQuestions(search: $search, pageSize: $pageSize, currentPage: $currentPage) {
|
|
41
|
+
items {
|
|
42
|
+
_first_store_id
|
|
43
|
+
animation_class
|
|
44
|
+
animation_speed
|
|
45
|
+
answer
|
|
46
|
+
author_email
|
|
47
|
+
author_name
|
|
48
|
+
body_bg
|
|
49
|
+
body_color
|
|
50
|
+
body_size
|
|
51
|
+
border_width
|
|
52
|
+
creation_time
|
|
53
|
+
disklike
|
|
54
|
+
is_active
|
|
55
|
+
is_featured
|
|
56
|
+
like
|
|
57
|
+
meta_description
|
|
58
|
+
meta_keywords
|
|
59
|
+
page_title
|
|
60
|
+
question_active_icon
|
|
61
|
+
question_icon
|
|
62
|
+
question_id
|
|
63
|
+
question_margin
|
|
64
|
+
question_position
|
|
65
|
+
question_type
|
|
66
|
+
question_url
|
|
67
|
+
store_code
|
|
68
|
+
store_id
|
|
69
|
+
tags
|
|
70
|
+
title
|
|
71
|
+
title_bg
|
|
72
|
+
title_bg_active
|
|
73
|
+
title_border_color
|
|
74
|
+
title_border_radius
|
|
75
|
+
title_color
|
|
76
|
+
title_color_active
|
|
77
|
+
title_size
|
|
78
|
+
update_time
|
|
79
|
+
}
|
|
80
|
+
page_info {
|
|
81
|
+
current_page
|
|
82
|
+
total_pages
|
|
83
|
+
}
|
|
84
|
+
total_count
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
87
|
`;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import { useQuery } from '@apollo/client';
|
|
3
|
+
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
4
4
|
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
5
5
|
import DEFAULT_OPERATIONS from './helpCenter.gql';
|
|
6
|
+
import { usePagination } from '@magento/peregrine/lib/hooks/usePagination';
|
|
6
7
|
|
|
7
|
-
export const useHelpCenter = (props
|
|
8
|
+
export const useHelpCenter = (props) => {
|
|
8
9
|
const { formatMessage } = useIntl();
|
|
9
10
|
|
|
11
|
+
const { searchQuery, pageSize = 10 } = props;
|
|
12
|
+
|
|
13
|
+
const [paginationValues, paginationApi] = usePagination();
|
|
14
|
+
const { currentPage = 1, totalPages } = paginationValues;
|
|
15
|
+
const { setCurrentPage, setTotalPages } = paginationApi;
|
|
16
|
+
|
|
10
17
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
11
18
|
|
|
12
19
|
const {
|
|
@@ -23,13 +30,45 @@ export const useHelpCenter = (props = {}) => {
|
|
|
23
30
|
fetchPolicy: 'cache-and-network'
|
|
24
31
|
});
|
|
25
32
|
|
|
26
|
-
const {
|
|
33
|
+
// const {
|
|
34
|
+
// data: questionsData,
|
|
35
|
+
// loading: questionsLoading,
|
|
36
|
+
// error: questionsError
|
|
37
|
+
// } = useQuery(faqQuestionsQuery, {
|
|
38
|
+
// fetchPolicy: 'cache-and-network',
|
|
39
|
+
// nextFetchPolicy: 'cache-first',
|
|
40
|
+
// variables: {
|
|
41
|
+
// search: searchQuery,
|
|
42
|
+
// pageSize: 20,
|
|
43
|
+
// currentPage: 1
|
|
44
|
+
// },
|
|
45
|
+
// });
|
|
46
|
+
|
|
47
|
+
console.log('searchQuery',searchQuery)
|
|
48
|
+
|
|
49
|
+
const [runQuery, {
|
|
27
50
|
data: questionsData,
|
|
28
51
|
loading: questionsLoading,
|
|
29
52
|
error: questionsError
|
|
30
|
-
} =
|
|
31
|
-
fetchPolicy: 'cache-and-network'
|
|
53
|
+
}] = useLazyQuery(faqQuestionsQuery, {
|
|
54
|
+
fetchPolicy: 'cache-and-network',
|
|
55
|
+
nextFetchPolicy: 'cache-first'
|
|
32
56
|
});
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
runQuery({
|
|
60
|
+
variables: {
|
|
61
|
+
pageSize: pageSize,
|
|
62
|
+
currentPage: currentPage,
|
|
63
|
+
search: searchQuery
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, [
|
|
67
|
+
runQuery,
|
|
68
|
+
pageSize,
|
|
69
|
+
currentPage,
|
|
70
|
+
searchQuery
|
|
71
|
+
]);
|
|
33
72
|
|
|
34
73
|
const {
|
|
35
74
|
data: tagsData,
|
|
@@ -44,14 +83,35 @@ export const useHelpCenter = (props = {}) => {
|
|
|
44
83
|
|
|
45
84
|
const data = useMemo(() => ({
|
|
46
85
|
categories: categoriesData?.faqCategories || [],
|
|
47
|
-
questions: questionsData?.faqQuestions || [],
|
|
86
|
+
questions: questionsData?.faqQuestions.items || [],
|
|
48
87
|
tags: tagsData?.faqTags || []
|
|
49
88
|
}), [categoriesData, questionsData, tagsData]);
|
|
50
89
|
|
|
90
|
+
const totalPagesFromData = questionsData
|
|
91
|
+
? questionsData.faqQuestions?.page_info?.total_pages
|
|
92
|
+
: null;
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
setTotalPages(totalPagesFromData);
|
|
96
|
+
return () => {
|
|
97
|
+
setTotalPages(null);
|
|
98
|
+
};
|
|
99
|
+
}, [setTotalPages, totalPagesFromData]);
|
|
100
|
+
|
|
101
|
+
const pageControl = {
|
|
102
|
+
currentPage,
|
|
103
|
+
setPage: setCurrentPage,
|
|
104
|
+
totalPages
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
console.log('pageControl',pageControl)
|
|
108
|
+
|
|
51
109
|
return {
|
|
52
110
|
loading,
|
|
53
111
|
error,
|
|
54
112
|
data,
|
|
113
|
+
totalPagesFromData,
|
|
114
|
+
pageControl,
|
|
55
115
|
formatMessage
|
|
56
116
|
};
|
|
57
117
|
};
|
|
@@ -202,8 +202,98 @@ export const GET_COUPON_CODE_QUERY = gql`
|
|
|
202
202
|
}
|
|
203
203
|
`;
|
|
204
204
|
|
|
205
|
+
export const GET_CUSTOMER_SELLER_MESSAGES = gql`
|
|
206
|
+
query GetCustomerSellerMessages(
|
|
207
|
+
$pageSize: Int!
|
|
208
|
+
$currentPage: Int!
|
|
209
|
+
$filter: SellerMessageFilterInput
|
|
210
|
+
$sort: SellerMessageSortInput
|
|
211
|
+
) {
|
|
212
|
+
customer {
|
|
213
|
+
sellerMessages(
|
|
214
|
+
pageSize: $pageSize
|
|
215
|
+
currentPage: $currentPage
|
|
216
|
+
filter: $filter
|
|
217
|
+
sort: $sort
|
|
218
|
+
) {
|
|
219
|
+
total_count
|
|
220
|
+
page_info {
|
|
221
|
+
current_page
|
|
222
|
+
page_size
|
|
223
|
+
total_pages
|
|
224
|
+
}
|
|
225
|
+
items {
|
|
226
|
+
message_id
|
|
227
|
+
subject
|
|
228
|
+
description
|
|
229
|
+
sender_email
|
|
230
|
+
sender_name
|
|
231
|
+
created_at
|
|
232
|
+
status
|
|
233
|
+
is_read
|
|
234
|
+
sender_id
|
|
235
|
+
owner_id
|
|
236
|
+
receiver_id
|
|
237
|
+
seller_send
|
|
238
|
+
details(pageSize: 500, currentPage: 1) {
|
|
239
|
+
total_count
|
|
240
|
+
items {
|
|
241
|
+
content
|
|
242
|
+
sender_name
|
|
243
|
+
sender_email
|
|
244
|
+
receiver_name
|
|
245
|
+
is_read
|
|
246
|
+
created_at
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
export const CUSTOMER_SEND_MESSAGE_MUTATION = gql`
|
|
256
|
+
mutation CustomerSendMessage($input: CustomerMessageInput!) {
|
|
257
|
+
customerSendMessage(input: $input) {
|
|
258
|
+
message_id
|
|
259
|
+
subject
|
|
260
|
+
description
|
|
261
|
+
sender_name
|
|
262
|
+
sender_email
|
|
263
|
+
created_at
|
|
264
|
+
status
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
export const CUSTOMER_REPLY_MESSAGE_MUTATION = gql`
|
|
270
|
+
mutation CUSTOMER_REPLY_MESSAGE_MUTATION($input: ReplyMessageInput!) {
|
|
271
|
+
customerReplyMessage(input: $input) {
|
|
272
|
+
content
|
|
273
|
+
sender_name
|
|
274
|
+
sender_email
|
|
275
|
+
receiver_name
|
|
276
|
+
is_read
|
|
277
|
+
created_at
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
`;
|
|
281
|
+
|
|
282
|
+
export const CUSTOMER_DELETE_MESSAGE_MUTATION = gql`
|
|
283
|
+
mutation CustomerDeleteMessage($id: Int!) {
|
|
284
|
+
customerDeleteMessage(message_id: $id) {
|
|
285
|
+
message
|
|
286
|
+
code
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
`;
|
|
290
|
+
|
|
205
291
|
export default {
|
|
206
292
|
getStoreConfigData: GET_STORE_CONFIG_DATA,
|
|
207
293
|
getSellerDetailQuery: GET_SELLER_DETAIL_QUERY,
|
|
208
294
|
getCouponCodeQuery: GET_COUPON_CODE_QUERY,
|
|
295
|
+
getCustomerSellerMessages: GET_CUSTOMER_SELLER_MESSAGES,
|
|
296
|
+
customerSendMessageMutation: CUSTOMER_SEND_MESSAGE_MUTATION,
|
|
297
|
+
customerReplyMessageMutation: CUSTOMER_REPLY_MESSAGE_MUTATION,
|
|
298
|
+
customerDeleteMessageMutation: CUSTOMER_DELETE_MESSAGE_MUTATION,
|
|
209
299
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client';
|
|
2
|
-
import { useEffect, useMemo } from 'react';
|
|
1
|
+
import { useQuery, useMutation } from '@apollo/client';
|
|
2
|
+
import { useEffect, useMemo, useCallback, useState } from 'react';
|
|
3
|
+
import { useToasts } from '@magento/peregrine/lib/Toasts/useToasts';
|
|
3
4
|
import { useLocation } from 'react-router-dom';
|
|
4
5
|
import { useAppContext } from '@magento/peregrine/lib/context/app';
|
|
5
6
|
import { useIntl } from 'react-intl';
|
|
@@ -13,7 +14,15 @@ export const useSeller = props => {
|
|
|
13
14
|
const { formatMessage } = useIntl();
|
|
14
15
|
|
|
15
16
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
16
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
getStoreConfigData,
|
|
19
|
+
getSellerDetailQuery,
|
|
20
|
+
getCouponCodeQuery,
|
|
21
|
+
getCustomerSellerMessages,
|
|
22
|
+
customerSendMessageMutation,
|
|
23
|
+
customerReplyMessageMutation,
|
|
24
|
+
customerDeleteMessageMutation
|
|
25
|
+
} = operations;
|
|
17
26
|
const { pathname } = useLocation();
|
|
18
27
|
const [
|
|
19
28
|
,
|
|
@@ -27,6 +36,8 @@ export const useSeller = props => {
|
|
|
27
36
|
nextFetchPolicy: 'cache-first'
|
|
28
37
|
});
|
|
29
38
|
|
|
39
|
+
const [, { addToast }] = useToasts();
|
|
40
|
+
|
|
30
41
|
const slug = pathname.split('/')[2];
|
|
31
42
|
const productUrlSuffix = storeConfigData?.storeConfig?.product_url_suffix;
|
|
32
43
|
const urlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
|
|
@@ -100,6 +111,82 @@ export const useSeller = props => {
|
|
|
100
111
|
storeConfig: storeConfigData ? storeConfigData.storeConfig : {}
|
|
101
112
|
};
|
|
102
113
|
|
|
114
|
+
// Messages state
|
|
115
|
+
const [messageListVars, setMessageListVars] = useState({
|
|
116
|
+
pageSize: 500,
|
|
117
|
+
currentPage: 1,
|
|
118
|
+
filter: undefined,
|
|
119
|
+
sort: undefined
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const {
|
|
123
|
+
data: messagesData,
|
|
124
|
+
loading: messagesLoading,
|
|
125
|
+
error: messagesError,
|
|
126
|
+
refetch: refetchMessages
|
|
127
|
+
} = useQuery(getCustomerSellerMessages, {
|
|
128
|
+
fetchPolicy: 'network-only',
|
|
129
|
+
nextFetchPolicy: 'network-only',
|
|
130
|
+
skip: !storeConfigData,
|
|
131
|
+
variables: messageListVars,
|
|
132
|
+
pollInterval: 10000,
|
|
133
|
+
notifyOnNetworkStatusChange: true
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const [sendMessage, { loading: sendLoading }] = useMutation(customerSendMessageMutation);
|
|
137
|
+
const [replyMessage, { loading: replyLoading }] = useMutation(customerReplyMessageMutation);
|
|
138
|
+
const [deleteMessage, { loading: deleteLoading }] = useMutation(customerDeleteMessageMutation);
|
|
139
|
+
|
|
140
|
+
const handleSendMessage = useCallback(async ({ subject, content, seller_url }) => {
|
|
141
|
+
const input = {
|
|
142
|
+
subject,
|
|
143
|
+
content,
|
|
144
|
+
seller_url
|
|
145
|
+
};
|
|
146
|
+
const result = await sendMessage({ variables: { input }, refetchQueries: [{ query: getCustomerSellerMessages, variables: messageListVars }] });
|
|
147
|
+
addToast({
|
|
148
|
+
type: 'success',
|
|
149
|
+
message: formatMessage({
|
|
150
|
+
id: 'messages.messageSent',
|
|
151
|
+
defaultMessage: 'Message sent successfully.'
|
|
152
|
+
}),
|
|
153
|
+
timeout: 3000
|
|
154
|
+
});
|
|
155
|
+
await refetchMessages({ fetchPolicy: 'network-only' });
|
|
156
|
+
return result?.data?.customerSendMessage;
|
|
157
|
+
}, [sendMessage, refetchMessages, addToast, formatMessage]);
|
|
158
|
+
|
|
159
|
+
const handleReplyMessage = useCallback(async ({ message_id, content }) => {
|
|
160
|
+
const input = {
|
|
161
|
+
message_id,
|
|
162
|
+
content
|
|
163
|
+
};
|
|
164
|
+
const result = await replyMessage({ variables: { input }, refetchQueries: [{ query: getCustomerSellerMessages, variables: messageListVars }] });
|
|
165
|
+
addToast({
|
|
166
|
+
type: 'success',
|
|
167
|
+
message: formatMessage({
|
|
168
|
+
id: 'messages.replySent',
|
|
169
|
+
defaultMessage: 'Reply sent successfully.'
|
|
170
|
+
}),
|
|
171
|
+
timeout: 3000
|
|
172
|
+
});
|
|
173
|
+
await refetchMessages({ fetchPolicy: 'network-only' });
|
|
174
|
+
return result?.data?.customerReplyMessage;
|
|
175
|
+
}, [replyMessage, refetchMessages, addToast, formatMessage]);
|
|
176
|
+
|
|
177
|
+
const handleDeleteMessage = useCallback(async ({ id }) => {
|
|
178
|
+
await deleteMessage({ variables: { id }, refetchQueries: [{ query: getCustomerSellerMessages, variables: messageListVars }] });
|
|
179
|
+
addToast({
|
|
180
|
+
type: 'success',
|
|
181
|
+
message: formatMessage({
|
|
182
|
+
id: 'messages.messageDeleted',
|
|
183
|
+
defaultMessage: 'Message deleted successfully.'
|
|
184
|
+
}),
|
|
185
|
+
timeout: 3000
|
|
186
|
+
});
|
|
187
|
+
await refetchMessages({ fetchPolicy: 'network-only' });
|
|
188
|
+
}, [deleteMessage, refetchMessages, addToast, formatMessage]);
|
|
189
|
+
|
|
103
190
|
return {
|
|
104
191
|
error,
|
|
105
192
|
loading,
|
|
@@ -107,6 +194,17 @@ export const useSeller = props => {
|
|
|
107
194
|
favoriteSellerButtonProps,
|
|
108
195
|
couponData,
|
|
109
196
|
couponError,
|
|
110
|
-
couponLoading
|
|
197
|
+
couponLoading,
|
|
198
|
+
// messages
|
|
199
|
+
messages: messagesData?.customer?.sellerMessages,
|
|
200
|
+
messagesLoading,
|
|
201
|
+
messagesError,
|
|
202
|
+
setMessageListVars,
|
|
203
|
+
sendLoading,
|
|
204
|
+
replyLoading,
|
|
205
|
+
deleteLoading,
|
|
206
|
+
handleSendMessage,
|
|
207
|
+
handleReplyMessage,
|
|
208
|
+
handleDeleteMessage
|
|
111
209
|
};
|
|
112
210
|
};
|
|
@@ -62,8 +62,8 @@ export const useProductContent = props => {
|
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
console.log('categoryData',categoryData)
|
|
66
|
-
console.log('categoryId',categoryId)
|
|
65
|
+
// console.log('categoryData',categoryData)
|
|
66
|
+
// console.log('categoryId',categoryId)
|
|
67
67
|
|
|
68
68
|
const [, { dispatch }] = useEventingContext();
|
|
69
69
|
|
|
@@ -99,7 +99,7 @@ export const useProductContent = props => {
|
|
|
99
99
|
categoryData && categoryData.categories.items.length
|
|
100
100
|
? categoryData.categories.items[0]
|
|
101
101
|
: null;
|
|
102
|
-
console.log('categorycategory',category)
|
|
102
|
+
// console.log('categorycategory',category)
|
|
103
103
|
const children =
|
|
104
104
|
categoryData && categoryData.categories.items.length
|
|
105
105
|
? categoryData.categories.items[0].children
|
|
@@ -138,7 +138,7 @@ export const useProductContent = props => {
|
|
|
138
138
|
[history, location]
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
-
console.log('category category',category)
|
|
141
|
+
// console.log('category category',category)
|
|
142
142
|
|
|
143
143
|
useEffect(() => {
|
|
144
144
|
const { search } = location;
|