@riosst100/pwa-marketplace 2.9.3 → 2.9.5
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 +1 -0
- package/i18n/id_ID.json +1 -0
- package/package.json +1 -1
- package/src/componentOverrideMapping.js +2 -1
- package/src/components/ConfirmEmailPage/confirmEmail.js +76 -0
- package/src/components/ConfirmEmailPage/confirmEmail.module.css +71 -0
- package/src/components/ConfirmEmailPage/index.js +1 -0
- package/src/components/FavoriteSellerPage/favoriteSeller.js +0 -1
- package/src/components/FavoriteSellerPage/item.js +0 -2
- package/src/components/OrderDetail/components/itemsOrdered.js +94 -82
- package/src/components/OrderDetail/orderDetail.js +102 -86
- package/src/components/SubCategory/subCategory.js +1 -1
- package/src/components/VerifyEmailPage/verifyEmail.js +33 -10
- package/src/intercept.js +8 -1
- package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +2 -2
- package/src/overwrites/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js +43 -2
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +4 -1
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +116 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +7 -0
- package/src/overwrites/venia-ui/lib/components/AccountInformationPage/DeleteAccount.js +5 -37
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +3 -1
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +53 -58
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/OrderConfirmationPage/orderConfirmationPage.js +68 -39
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/checkoutPage.js +1 -1
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderHistoryPage.js +10 -2
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +91 -78
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.module.css +3 -3
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +1 -1
- package/src/talons/AccountInformationPage/deleteAccount.gql.js +23 -0
- package/src/talons/AccountInformationPage/useDeleteAccount.js +98 -0
- package/src/talons/ConfirmEmailPage/confirmEmailPage.gql.js +20 -0
- package/src/talons/ConfirmEmailPage/useConfirmEmailPage.js +78 -0
- package/src/talons/OrderHistoryPage/useOrderHistoryPage.js +115 -0
- package/src/talons/ShopBy/useShopBy.js +12 -2
- package/src/talons/VerifyEmailPage/useVerifyEmailPage.js +73 -0
- package/src/talons/VerifyEmailPage/verifyEmailPage.gql.js +36 -0
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +13 -2
|
@@ -1,79 +1,113 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
|
|
4
4
|
import Button from '@magento/venia-ui/lib/components/Button';
|
|
5
5
|
import cn from 'classnames';
|
|
6
6
|
import { Printer } from 'iconsax-react';
|
|
7
|
-
// import Tabs from '@riosst100/pwa-marketplace/src/components/commons/Tabs';
|
|
8
7
|
import ItemsOrdered from './components/itemsOrdered';
|
|
9
8
|
import RMAList from './components/rmaList';
|
|
9
|
+
import { useLocation } from 'react-router-dom';
|
|
10
10
|
|
|
11
|
-
const OrderDetail = () => {
|
|
11
|
+
const OrderDetail = (props) => {
|
|
12
|
+
const printRef = useRef(null);
|
|
12
13
|
const { formatMessage } = useIntl();
|
|
14
|
+
const location = useLocation();
|
|
13
15
|
const PAGE_TITLE = formatMessage({
|
|
14
16
|
id: 'Quotes.pageTitleTextRMADetail',
|
|
15
17
|
defaultMessage: 'Order Detail'
|
|
16
18
|
});
|
|
17
19
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
// Retrieve order data from props or location state
|
|
21
|
+
const order = props.order || location.state?.order;
|
|
22
|
+
// Extract order data
|
|
23
|
+
const invoiceNumber = order?.invoices?.[0]?.number || '-';
|
|
24
|
+
const orderDate = order?.order_date
|
|
25
|
+
? new Date(order.order_date.replace(' ', 'T')).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' })
|
|
26
|
+
: '-';
|
|
27
|
+
const status = order?.status || '-';
|
|
28
|
+
const shippingMethod = order?.shipping_method || '-';
|
|
29
|
+
const trackingNumber = order?.shipments?.[0]?.tracking?.[0]?.number || '-';
|
|
30
|
+
const shippingAddress = order?.shipping_address;
|
|
31
|
+
const billingAddress = order?.billing_address;
|
|
32
|
+
const paymentMethod = order?.payment_methods?.[0]?.type || '-';
|
|
33
|
+
|
|
34
|
+
// Format address helper
|
|
35
|
+
const formatAddress = addr => {
|
|
36
|
+
if (!addr) return '-';
|
|
37
|
+
return [
|
|
38
|
+
`${addr.firstname} ${addr.lastname}`,
|
|
39
|
+
...(addr.street || []),
|
|
40
|
+
`${addr.city}${addr.region_id ? ', ' + addr.region_id : ''}${addr.postcode ? ', ' + addr.postcode : ''}`,
|
|
41
|
+
addr.country_code,
|
|
42
|
+
addr.telephone ? `T: ${addr.telephone}` : ''
|
|
43
|
+
].filter(Boolean).join('\n');
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handlePrint = useCallback(() => {
|
|
47
|
+
const styleId = 'order-detail-print-style';
|
|
48
|
+
let style = document.getElementById(styleId);
|
|
49
|
+
if (!style) {
|
|
50
|
+
style = document.createElement('style');
|
|
51
|
+
style.id = styleId;
|
|
52
|
+
style.type = 'text/css';
|
|
53
|
+
style.media = 'print';
|
|
54
|
+
style.appendChild(document.createTextNode(`
|
|
55
|
+
@page { size: A3; margin: 0; }
|
|
56
|
+
@media print {
|
|
57
|
+
body { margin: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
58
|
+
body * { visibility: hidden !important; }
|
|
59
|
+
.print-area, .print-area * { visibility: visible !important; }
|
|
60
|
+
.print-area { position: relative; left: 0; top: -20px; width: 100%;}
|
|
61
|
+
.no-print { display: none !important; }
|
|
62
|
+
}
|
|
63
|
+
`));
|
|
64
|
+
document.head.appendChild(style);
|
|
65
|
+
}
|
|
66
|
+
window.print();
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
}, 500);
|
|
69
|
+
}, []);
|
|
36
70
|
|
|
37
71
|
return (
|
|
38
|
-
<div className='relative grid gap-y-md'>
|
|
72
|
+
<div className='print-area relative grid gap-y-md' ref={printRef}>
|
|
39
73
|
<StoreTitle>{PAGE_TITLE}</StoreTitle>
|
|
40
74
|
<div aria-live="polite" className="text-xl font-medium text-left">
|
|
41
|
-
{PAGE_TITLE} -
|
|
75
|
+
{PAGE_TITLE} - #{order?.number || '-'}
|
|
42
76
|
</div>
|
|
43
77
|
<div className='block relative'>
|
|
44
78
|
<div className='flex gap-2 mb-4 flex-col'>
|
|
45
|
-
<div
|
|
46
|
-
<p
|
|
79
|
+
<div className="box box-order-shipping-method flex gap-4">
|
|
80
|
+
<p className="box-title block min-w-[90px] font-semibold text-[14px]">
|
|
47
81
|
<span>Invoice</span>
|
|
48
82
|
</p>
|
|
49
|
-
<div
|
|
50
|
-
|
|
83
|
+
<div className="box-content text-[14px]">
|
|
84
|
+
{invoiceNumber || '-'}
|
|
51
85
|
</div>
|
|
52
86
|
</div>
|
|
53
|
-
<div
|
|
54
|
-
<p
|
|
87
|
+
<div className="box box-order-shipping-method flex gap-4 text-[14px]">
|
|
88
|
+
<p className="box-title block min-w-[90px] font-semibold">
|
|
55
89
|
<span>Order Date</span>
|
|
56
90
|
</p>
|
|
57
|
-
<div
|
|
58
|
-
|
|
91
|
+
<div className="box-content text-[14px]">
|
|
92
|
+
{orderDate}
|
|
59
93
|
</div>
|
|
60
94
|
</div>
|
|
61
|
-
<div
|
|
62
|
-
<p
|
|
95
|
+
<div className="box box-order-shipping-method flex gap-4 text-[14px]">
|
|
96
|
+
<p className="box-title block min-w-[90px] font-semibold self-center">
|
|
63
97
|
<span>Status</span>
|
|
64
98
|
</p>
|
|
65
|
-
<div
|
|
99
|
+
<div className="box-content text-[14px]">
|
|
66
100
|
<div className='p-1 bg-[#F1EFF6] rounded-md flex items-center px-5'>
|
|
67
101
|
<p className='text-[14px] text-blue-700 flex justify-between'>
|
|
68
102
|
<span className='font-medium block text-blue-700'>
|
|
69
|
-
|
|
103
|
+
{status}
|
|
70
104
|
</span>
|
|
71
105
|
</p>
|
|
72
106
|
</div>
|
|
73
107
|
</div>
|
|
74
108
|
</div>
|
|
75
109
|
</div>
|
|
76
|
-
<div className='flex flex-col md_flex-row gap-x-4 justify-end'>
|
|
110
|
+
<div className='flex flex-col md_flex-row gap-x-4 justify-end no-print'>
|
|
77
111
|
<Button
|
|
78
112
|
priority='high'
|
|
79
113
|
classes={{
|
|
@@ -83,6 +117,8 @@ const OrderDetail = () => {
|
|
|
83
117
|
"bg-white px-6 py-2 rounded-md text-gray-900 hover_!text-white border border-solid",
|
|
84
118
|
"border-gray-900 focus-visible_outline-none hover_bg-gray-900 min-h-[40px]"
|
|
85
119
|
)}
|
|
120
|
+
onClick={handlePrint}
|
|
121
|
+
aria-label={formatMessage({ id: 'order.printInvoices', defaultMessage: 'Print Invoices' })}
|
|
86
122
|
>
|
|
87
123
|
<span className='flex gap-x-3 justify-center group-hover_!text-white'>
|
|
88
124
|
<Printer
|
|
@@ -99,15 +135,7 @@ const OrderDetail = () => {
|
|
|
99
135
|
</Button>
|
|
100
136
|
</div>
|
|
101
137
|
</div>
|
|
102
|
-
|
|
103
|
-
{/* <Tabs
|
|
104
|
-
data={dataTabs}
|
|
105
|
-
tabContentWrapperClassName='!p-0'
|
|
106
|
-
hasContent
|
|
107
|
-
tabWrapperClassName='xl_gap-x-[60px]'
|
|
108
|
-
rootClassName="mb-0"
|
|
109
|
-
/> */}
|
|
110
|
-
<div class="block block-order-details-view">
|
|
138
|
+
<div className="block block-order-details-view">
|
|
111
139
|
<div aria-live="polite" className="text-lg font-medium text-left mb-4 block-title">
|
|
112
140
|
{
|
|
113
141
|
formatMessage({
|
|
@@ -116,11 +144,9 @@ const OrderDetail = () => {
|
|
|
116
144
|
})
|
|
117
145
|
}
|
|
118
146
|
</div>
|
|
119
|
-
|
|
120
|
-
<ItemsOrdered />
|
|
147
|
+
<ItemsOrdered order={order} />
|
|
121
148
|
</div>
|
|
122
|
-
|
|
123
|
-
<div class="block block-order-details-view">
|
|
149
|
+
<div className="block block-order-details-view">
|
|
124
150
|
<div aria-live="polite" className="text-lg font-medium text-left mb-4 block-title">
|
|
125
151
|
{
|
|
126
152
|
formatMessage({
|
|
@@ -129,11 +155,9 @@ const OrderDetail = () => {
|
|
|
129
155
|
})
|
|
130
156
|
}
|
|
131
157
|
</div>
|
|
132
|
-
|
|
133
158
|
<RMAList />
|
|
134
159
|
</div>
|
|
135
|
-
|
|
136
|
-
<div class="block block-order-details-view">
|
|
160
|
+
<div className="block block-order-details-view">
|
|
137
161
|
<div aria-live="polite" className="text-lg font-medium text-left mb-4 block-title">
|
|
138
162
|
{
|
|
139
163
|
formatMessage({
|
|
@@ -142,63 +166,55 @@ const OrderDetail = () => {
|
|
|
142
166
|
})
|
|
143
167
|
}
|
|
144
168
|
</div>
|
|
145
|
-
<div
|
|
146
|
-
<div
|
|
147
|
-
<strong
|
|
169
|
+
<div className="block-content flex flex-col gap-y-4 rounded-md border border-gray-100 px-4 py-6 justify-between gap-x-10">
|
|
170
|
+
<div className="box box-order-shipping-method flex gap-4">
|
|
171
|
+
<strong className="box-title block min-w-[140px]">
|
|
148
172
|
<span>Shipping Method</span>
|
|
149
173
|
</strong>
|
|
150
|
-
<div
|
|
151
|
-
|
|
174
|
+
<div className="box-content">
|
|
175
|
+
{shippingMethod}
|
|
152
176
|
</div>
|
|
153
177
|
</div>
|
|
154
|
-
<div
|
|
155
|
-
<strong
|
|
178
|
+
<div className="box box-order-shipping-method flex gap-4">
|
|
179
|
+
<strong className="box-title block min-w-[140px]">
|
|
156
180
|
<span>Tracking Number</span>
|
|
157
181
|
</strong>
|
|
158
|
-
<div
|
|
159
|
-
|
|
182
|
+
<div className="box-content">
|
|
183
|
+
{trackingNumber}
|
|
160
184
|
</div>
|
|
161
185
|
</div>
|
|
162
|
-
<div
|
|
163
|
-
<strong
|
|
164
|
-
<div
|
|
165
|
-
<div className='
|
|
166
|
-
|
|
167
|
-
6146 Honey Bluff Parkway{'\n'}
|
|
168
|
-
Calder, Michigan, 49628-7978{'\n'}
|
|
169
|
-
United States{'\n'}
|
|
170
|
-
T: <a href="tel:(555) 229-3326">(555) 229-3326</a>
|
|
186
|
+
<div className="box box-order-shipping-address flex gap-4">
|
|
187
|
+
<strong className="box-title block min-w-[140px]"><span>Shipping Address</span></strong>
|
|
188
|
+
<div className="box-content">
|
|
189
|
+
<div className='whitespace-pre-wrap'>
|
|
190
|
+
{formatAddress(shippingAddress)}
|
|
171
191
|
</div>
|
|
172
192
|
</div>
|
|
173
193
|
</div>
|
|
174
|
-
<div
|
|
175
|
-
<strong
|
|
194
|
+
<div className="box box-order-billing-method flex gap-4">
|
|
195
|
+
<strong className="box-title block min-w-[140px]">
|
|
176
196
|
<span>Payment Method</span>
|
|
177
197
|
</strong>
|
|
178
|
-
<div
|
|
179
|
-
<dl
|
|
180
|
-
<dt
|
|
198
|
+
<div className="box-content">
|
|
199
|
+
<dl className="payment-method checkmemo">
|
|
200
|
+
<dt className="title">{paymentMethod}</dt>
|
|
181
201
|
</dl>
|
|
182
202
|
</div>
|
|
183
203
|
</div>
|
|
184
|
-
<div
|
|
185
|
-
<strong
|
|
204
|
+
<div className="box box-order-billing-address flex gap-4">
|
|
205
|
+
<strong className="box-title block min-w-[140px]">
|
|
186
206
|
<span>Billing Address</span>
|
|
187
207
|
</strong>
|
|
188
|
-
<div
|
|
208
|
+
<div className="box-content">
|
|
189
209
|
<div className='whitespace-pre-wrap'>
|
|
190
|
-
|
|
191
|
-
6146 Honey Bluff Parkway{'\n'}
|
|
192
|
-
Calder, Michigan, 49628-7978{'\n'}
|
|
193
|
-
United States{'\n'}
|
|
194
|
-
T: <a href="tel:(555) 229-3326">(555) 229-3326</a>
|
|
210
|
+
{formatAddress(billingAddress)}
|
|
195
211
|
</div>
|
|
196
212
|
</div>
|
|
197
213
|
</div>
|
|
198
214
|
</div>
|
|
199
|
-
</div>
|
|
215
|
+
</div>
|
|
200
216
|
</div>
|
|
201
|
-
)
|
|
202
|
-
}
|
|
217
|
+
);
|
|
218
|
+
};
|
|
203
219
|
|
|
204
220
|
export default OrderDetail;
|
|
@@ -25,7 +25,7 @@ const SubCategory = props => {
|
|
|
25
25
|
const isActive = index == 0 ? true : false;
|
|
26
26
|
|
|
27
27
|
const item = isActive ? (
|
|
28
|
-
<span className={classes.item}><b>{text}</b></span>
|
|
28
|
+
<span key={index} className={classes.item}><b>{text}</b></span>
|
|
29
29
|
) : (
|
|
30
30
|
<Link
|
|
31
31
|
key={index}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo, useEffect } from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
3
|
import { FormattedMessage } from 'react-intl';
|
|
4
4
|
import { shape, string } from 'prop-types';
|
|
5
5
|
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
6
|
import defaultClasses from './verifyEmail.module.css';
|
|
7
|
-
import {
|
|
7
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
8
|
+
import { useHistory } from 'react-router-dom';
|
|
9
|
+
import { useVerifyEmailPage } from '@riosst100/pwa-marketplace/src/talons/VerifyEmailPage/useVerifyEmailPage';
|
|
8
10
|
|
|
11
|
+
const storage = new BrowserPersistence();
|
|
9
12
|
|
|
10
13
|
const VerifyEmailPage = props => {
|
|
11
14
|
const classes = useStyle(defaultClasses, props.classes);
|
|
12
|
-
const
|
|
13
|
-
const email = data?.customer?.email || '';
|
|
15
|
+
const email = storage.getItem('confirm_email');
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
const history = useHistory();
|
|
18
|
+
|
|
19
|
+
const { handleResendEmail, shouldShowLoadingIndicator } = useVerifyEmailPage({ email });
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!email) {
|
|
23
|
+
history.push('/');
|
|
24
|
+
}
|
|
25
|
+
}, [email, history]);
|
|
26
|
+
|
|
27
|
+
return email ? (
|
|
16
28
|
<div className={classes.root}>
|
|
17
29
|
<div className={classes.card}>
|
|
18
30
|
<h2 className={classes.title}>
|
|
@@ -21,30 +33,41 @@ const VerifyEmailPage = props => {
|
|
|
21
33
|
defaultMessage={'Please verify your email'}
|
|
22
34
|
/>
|
|
23
35
|
</h2>
|
|
36
|
+
{email ?
|
|
24
37
|
<p className={classes.subtitle}>
|
|
25
38
|
<FormattedMessage
|
|
26
39
|
id={'verifyEmail.sentTo'}
|
|
27
40
|
defaultMessage={'You\'re almost there! We sent an email to'}
|
|
28
41
|
/>
|
|
29
42
|
<br />
|
|
30
|
-
<span className={classes.email}>{
|
|
31
|
-
</p>
|
|
43
|
+
<span className={classes.email}>{email}</span>
|
|
44
|
+
</p> : ''}
|
|
32
45
|
<p className={classes.instructions}>
|
|
33
46
|
<FormattedMessage
|
|
34
47
|
id={'verifyEmail.instructions'}
|
|
35
48
|
defaultMessage={'Just click on the link in that email to complete your signup. If you don\'t see it, you may need to check your spam folder.'}
|
|
36
49
|
/>
|
|
37
50
|
</p>
|
|
51
|
+
{shouldShowLoadingIndicator ? <button
|
|
52
|
+
className={classes.resendButton}
|
|
53
|
+
type="button"
|
|
54
|
+
style={{"opacity":"0.5"}}
|
|
55
|
+
>
|
|
56
|
+
<FormattedMessage
|
|
57
|
+
id={'verifyEmail.sendingEmail'}
|
|
58
|
+
defaultMessage={'Sending Email...'}
|
|
59
|
+
/>
|
|
60
|
+
</button> :
|
|
38
61
|
<button
|
|
39
62
|
className={classes.resendButton}
|
|
40
63
|
type="button"
|
|
41
|
-
onClick={
|
|
64
|
+
onClick={handleResendEmail}
|
|
42
65
|
>
|
|
43
66
|
<FormattedMessage
|
|
44
67
|
id={'verifyEmail.resend'}
|
|
45
68
|
defaultMessage={'Resend Email'}
|
|
46
69
|
/>
|
|
47
|
-
</button>
|
|
70
|
+
</button>}
|
|
48
71
|
<div className={classes.contactHelp}>
|
|
49
72
|
<FormattedMessage
|
|
50
73
|
id={'verifyEmail.needHelp'}
|
|
@@ -59,7 +82,7 @@ const VerifyEmailPage = props => {
|
|
|
59
82
|
</div>
|
|
60
83
|
</div>
|
|
61
84
|
</div>
|
|
62
|
-
);
|
|
85
|
+
) : '';
|
|
63
86
|
};
|
|
64
87
|
|
|
65
88
|
VerifyEmailPage.propTypes = {
|
package/src/intercept.js
CHANGED
|
@@ -92,7 +92,14 @@ module.exports = targets => {
|
|
|
92
92
|
name: "VerifyEmailPage",
|
|
93
93
|
pattern: "/verify-email",
|
|
94
94
|
path: require.resolve("./components/VerifyEmailPage/index.js"),
|
|
95
|
-
authed:
|
|
95
|
+
authed: false,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
exact: true,
|
|
99
|
+
name: "ConfirmEmailPage",
|
|
100
|
+
pattern: "/confirm-email",
|
|
101
|
+
path: require.resolve("./components/ConfirmEmailPage/index.js"),
|
|
102
|
+
authed: false,
|
|
96
103
|
},
|
|
97
104
|
{
|
|
98
105
|
exact: true,
|
|
@@ -99,8 +99,8 @@ export const usePriceSummary = (props = {}) => {
|
|
|
99
99
|
|
|
100
100
|
await createSellerCart({ initCheckoutSplitCart, sellerUrl });
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
console.log('initCheckoutSplitCartData',initCheckoutSplitCartData)
|
|
103
|
+
console.log('fetchCartId',fetchCartId)
|
|
104
104
|
|
|
105
105
|
await removeCart();
|
|
106
106
|
await apolloClient.clearCacheData(apolloClient, 'cart');
|
|
@@ -295,6 +295,9 @@ export const useCheckoutPage = (props = {}) => {
|
|
|
295
295
|
// When true, we intentionally hide the OrderConfirmationPage (orderNumber)
|
|
296
296
|
// to allow external payment (Xendit) to complete first.
|
|
297
297
|
const [suppressOrderConfirmation, setSuppressOrderConfirmation] = useState(false);
|
|
298
|
+
// Support returning from external payment with orderNumber in URL
|
|
299
|
+
const [externalOrderNumber, setExternalOrderNumber] = useState(null);
|
|
300
|
+
const [externalOrderDetails, setExternalOrderDetails] = useState(null);
|
|
298
301
|
|
|
299
302
|
const handlePlaceOrder = useCallback(async () => {
|
|
300
303
|
// Fetch order details and then use an effect to actually place the
|
|
@@ -352,6 +355,17 @@ export const useCheckoutPage = (props = {}) => {
|
|
|
352
355
|
try {
|
|
353
356
|
// Prevent success page from rendering; we'll redirect to Xendit first
|
|
354
357
|
setSuppressOrderConfirmation(true);
|
|
358
|
+
// Persist a snapshot of order details for rendering confirmation after redirect
|
|
359
|
+
try {
|
|
360
|
+
if (orderDetailsData) {
|
|
361
|
+
const key = `orderConfirmationSnapshot:${orderNumber}`;
|
|
362
|
+
const payload = JSON.stringify(orderDetailsData);
|
|
363
|
+
globalThis.localStorage && globalThis.localStorage.setItem(key, payload);
|
|
364
|
+
}
|
|
365
|
+
} catch (e) {
|
|
366
|
+
// eslint-disable-next-line no-console
|
|
367
|
+
console.warn('Unable to persist order confirmation snapshot', e);
|
|
368
|
+
}
|
|
355
369
|
const res = await xenditCreateInvoice({
|
|
356
370
|
variables: { orderId: orderNumber }
|
|
357
371
|
});
|
|
@@ -418,6 +432,33 @@ export const useCheckoutPage = (props = {}) => {
|
|
|
418
432
|
isPlacingOrder
|
|
419
433
|
]);
|
|
420
434
|
|
|
435
|
+
// On first load, check for orderNumber in querystring to render confirmation
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
try {
|
|
438
|
+
const { location } = globalThis;
|
|
439
|
+
if (!location) return;
|
|
440
|
+
const params = new URLSearchParams(location.search || '');
|
|
441
|
+
const qsOrder = params.get('orderNumber');
|
|
442
|
+
if (!qsOrder) return;
|
|
443
|
+
|
|
444
|
+
setExternalOrderNumber(qsOrder);
|
|
445
|
+
// Attempt to load the previously saved snapshot
|
|
446
|
+
try {
|
|
447
|
+
const key = `orderConfirmationSnapshot:${qsOrder}`;
|
|
448
|
+
const raw = globalThis.localStorage && globalThis.localStorage.getItem(key);
|
|
449
|
+
if (raw) {
|
|
450
|
+
const parsed = JSON.parse(raw);
|
|
451
|
+
setExternalOrderDetails(parsed);
|
|
452
|
+
}
|
|
453
|
+
} catch (e) {
|
|
454
|
+
// eslint-disable-next-line no-console
|
|
455
|
+
console.warn('Failed to restore order confirmation snapshot', e);
|
|
456
|
+
}
|
|
457
|
+
} catch (_) {
|
|
458
|
+
// ignore
|
|
459
|
+
}
|
|
460
|
+
}, []);
|
|
461
|
+
|
|
421
462
|
useEffect(async () => {
|
|
422
463
|
await setCheckoutState(false);
|
|
423
464
|
}, [setCheckoutState]);
|
|
@@ -517,11 +558,11 @@ export const useCheckoutPage = (props = {}) => {
|
|
|
517
558
|
isGuestCheckout: !isSignedIn,
|
|
518
559
|
isLoading,
|
|
519
560
|
isUpdating,
|
|
520
|
-
orderDetailsData,
|
|
561
|
+
orderDetailsData: externalOrderDetails || orderDetailsData,
|
|
521
562
|
orderDetailsLoading,
|
|
522
563
|
orderNumber: suppressOrderConfirmation
|
|
523
564
|
? null
|
|
524
|
-
: (placeOrderData && placeOrderData.placeOrder.order.order_number) || null,
|
|
565
|
+
: (externalOrderNumber || (placeOrderData && placeOrderData.placeOrder.order.order_number) || null),
|
|
525
566
|
placeOrderLoading,
|
|
526
567
|
placeOrderButtonClicked,
|
|
527
568
|
setCheckoutStep,
|
|
@@ -34,7 +34,10 @@ export const useFilterSidebar = props => {
|
|
|
34
34
|
|
|
35
35
|
const allActiveFilters = getFiltersFromSearch(search);
|
|
36
36
|
|
|
37
|
-
const { data: introspectionData } = useQuery(getFilterInputsQuery
|
|
37
|
+
const { data: introspectionData } = useQuery(getFilterInputsQuery, {
|
|
38
|
+
fetchPolicy: 'cache-and-network',
|
|
39
|
+
nextFetchPolicy: 'cache-first'
|
|
40
|
+
});
|
|
38
41
|
|
|
39
42
|
// const {
|
|
40
43
|
// called: subFilterItemsCalled,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
const CustomerOrdersFragment = gql`
|
|
4
|
+
fragment CustomerOrdersFragment on CustomerOrders {
|
|
5
|
+
items {
|
|
6
|
+
billing_address {
|
|
7
|
+
city
|
|
8
|
+
country_code
|
|
9
|
+
firstname
|
|
10
|
+
lastname
|
|
11
|
+
postcode
|
|
12
|
+
region
|
|
13
|
+
street
|
|
14
|
+
telephone
|
|
15
|
+
}
|
|
16
|
+
id
|
|
17
|
+
invoices {
|
|
18
|
+
id
|
|
19
|
+
number
|
|
20
|
+
}
|
|
21
|
+
items {
|
|
22
|
+
id
|
|
23
|
+
product_name
|
|
24
|
+
product_sale_price {
|
|
25
|
+
currency
|
|
26
|
+
value
|
|
27
|
+
}
|
|
28
|
+
product_sku
|
|
29
|
+
product_url_key
|
|
30
|
+
selected_options {
|
|
31
|
+
label
|
|
32
|
+
value
|
|
33
|
+
}
|
|
34
|
+
quantity_ordered
|
|
35
|
+
seller_name
|
|
36
|
+
}
|
|
37
|
+
number
|
|
38
|
+
order_date
|
|
39
|
+
payment_methods {
|
|
40
|
+
name
|
|
41
|
+
type
|
|
42
|
+
additional_data {
|
|
43
|
+
name
|
|
44
|
+
value
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
shipments {
|
|
48
|
+
id
|
|
49
|
+
tracking {
|
|
50
|
+
number
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
shipping_address {
|
|
54
|
+
city
|
|
55
|
+
country_code
|
|
56
|
+
firstname
|
|
57
|
+
lastname
|
|
58
|
+
postcode
|
|
59
|
+
region
|
|
60
|
+
street
|
|
61
|
+
telephone
|
|
62
|
+
}
|
|
63
|
+
shipping_method
|
|
64
|
+
status
|
|
65
|
+
total {
|
|
66
|
+
discounts {
|
|
67
|
+
amount {
|
|
68
|
+
currency
|
|
69
|
+
value
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
grand_total {
|
|
73
|
+
currency
|
|
74
|
+
value
|
|
75
|
+
}
|
|
76
|
+
subtotal {
|
|
77
|
+
currency
|
|
78
|
+
value
|
|
79
|
+
}
|
|
80
|
+
total_shipping {
|
|
81
|
+
currency
|
|
82
|
+
value
|
|
83
|
+
}
|
|
84
|
+
total_tax {
|
|
85
|
+
currency
|
|
86
|
+
value
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
page_info {
|
|
91
|
+
current_page
|
|
92
|
+
total_pages
|
|
93
|
+
}
|
|
94
|
+
total_count
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
export const GET_CUSTOMER_ORDERS = gql`
|
|
99
|
+
query GetCustomerOrders(
|
|
100
|
+
$filter: CustomerOrdersFilterInput
|
|
101
|
+
$pageSize: Int!
|
|
102
|
+
$currentPage: Int
|
|
103
|
+
) {
|
|
104
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
105
|
+
customer {
|
|
106
|
+
orders(filter: $filter, pageSize: $pageSize, currentPage: $currentPage) {
|
|
107
|
+
...CustomerOrdersFragment
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
${CustomerOrdersFragment}
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
getCustomerOrdersQuery: GET_CUSTOMER_ORDERS
|
|
116
|
+
};
|
|
@@ -120,6 +120,7 @@ export const useCategoryContent = props => {
|
|
|
120
120
|
return masterAttributes;
|
|
121
121
|
}, [masterAttributesData]);
|
|
122
122
|
|
|
123
|
+
|
|
123
124
|
|
|
124
125
|
useEffect(() => {
|
|
125
126
|
if (categoryId) {
|
|
@@ -132,6 +133,10 @@ export const useCategoryContent = props => {
|
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
const filters = getFiltersFromSearch(search);
|
|
136
|
+
|
|
137
|
+
// console.log('masterAttributes',masterAttributes)
|
|
138
|
+
// console.log('filters',filters)
|
|
139
|
+
|
|
135
140
|
|
|
136
141
|
// Construct the filter arg object.
|
|
137
142
|
const newFilters = {};
|
|
@@ -141,6 +146,8 @@ export const useCategoryContent = props => {
|
|
|
141
146
|
}
|
|
142
147
|
});
|
|
143
148
|
|
|
149
|
+
// console.log('newFilters',newFilters)
|
|
150
|
+
|
|
144
151
|
getFilters({
|
|
145
152
|
variables: {
|
|
146
153
|
filters: newFilters
|