@riosst100/pwa-marketplace 2.9.4 → 2.9.6
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 +6 -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/components/rmaList.js +80 -88
- package/src/components/OrderDetail/orderDetail.js +154 -95
- package/src/components/RMAPage/RMACreate.js +225 -36
- package/src/components/RMAPage/RMADetail.js +141 -89
- package/src/components/RMAPage/RMAList.js +38 -57
- package/src/components/RMAPage/components/productItem.js +55 -30
- package/src/components/RMAPage/orderRow.js +109 -254
- 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/PaymentInformation/paymentMethods.gql.js +45 -0
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +117 -0
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderRow.gql.js +46 -0
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/useOrderRow.js +112 -0
- package/src/overwrites/peregrine/lib/talons/RMAPage/rmaPage.gql.js +170 -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/OrderHistoryPage/orderHistoryPage.js +10 -2
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +158 -79
- 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/RMAPage/useRmaPage.js +145 -0
- package/src/talons/VerifyEmailPage/useVerifyEmailPage.js +73 -0
- package/src/talons/VerifyEmailPage/verifyEmailPage.gql.js +36 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useLocation, useHistory } from 'react-router-dom';
|
|
3
|
+
import { useRmaPage } from '@riosst100/pwa-marketplace/src/talons/RMAPage/useRmaPage';
|
|
2
4
|
import { useIntl } from 'react-intl';
|
|
3
5
|
import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
|
|
4
6
|
import Button from '@magento/venia-ui/lib/components/Button';
|
|
@@ -6,15 +8,177 @@ import ChatContent from '../LiveChat/chatContent';
|
|
|
6
8
|
import cn from 'classnames';
|
|
7
9
|
import { Send } from 'iconsax-react';
|
|
8
10
|
import Item from './components/productItem';
|
|
11
|
+
import { useQuery } from '@apollo/client';
|
|
12
|
+
import { GET_LOFMP_RMA_CONFIGURATIONS } from '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/RMAPage/rmaPage.gql';
|
|
13
|
+
import { useToasts } from '@magento/peregrine/lib/Toasts';
|
|
14
|
+
import { CheckCircle as CheckCircleIcon, AlertCircle as AlertCircleIcon } from 'react-feather';
|
|
9
15
|
|
|
10
16
|
const RMACreate = () => {
|
|
17
|
+
const location = useLocation();
|
|
18
|
+
const history = useHistory();
|
|
19
|
+
let order = location.state && location.state.order;
|
|
20
|
+
if (!order) {
|
|
21
|
+
try {
|
|
22
|
+
order = JSON.parse(localStorage.getItem('rma_order'));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
order = undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
createRma,
|
|
30
|
+
createRmaLoading,
|
|
31
|
+
createRmaError,
|
|
32
|
+
createRmaData
|
|
33
|
+
} = useRmaPage();
|
|
34
|
+
|
|
35
|
+
const [submitError, setSubmitError] = useState(null);
|
|
36
|
+
const [submitSuccess, setSubmitSuccess] = useState(null);
|
|
37
|
+
const [, { addToast }] = useToasts();
|
|
38
|
+
|
|
39
|
+
// State untuk setiap item yang di-checklist
|
|
40
|
+
const [itemReturnState, setItemReturnState] = useState({});
|
|
41
|
+
|
|
42
|
+
// Ambil konfigurasi RMA (reasons, conditions, resolutions)
|
|
43
|
+
const { data: rmaConfigData } = useQuery(GET_LOFMP_RMA_CONFIGURATIONS);
|
|
44
|
+
|
|
45
|
+
// Handler untuk update state per item
|
|
46
|
+
const handleItemChange = (itemId, field, value) => {
|
|
47
|
+
setItemReturnState(prev => ({
|
|
48
|
+
...prev,
|
|
49
|
+
[itemId]: {
|
|
50
|
+
...prev[itemId],
|
|
51
|
+
[field]: value
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Handler untuk checklist item
|
|
57
|
+
const handleItemCheck = (itemId, checked) => {
|
|
58
|
+
setItemReturnState(prev => {
|
|
59
|
+
const current = prev[itemId] || {};
|
|
60
|
+
// Set default values when checked true
|
|
61
|
+
let defaults = {};
|
|
62
|
+
if (checked) {
|
|
63
|
+
const cfg = rmaConfigData && rmaConfigData.lofmpRmaConfigurations;
|
|
64
|
+
const firstReason = cfg && cfg.reasons && cfg.reasons.length > 0 ? cfg.reasons[0].id : null;
|
|
65
|
+
const firstCondition = cfg && cfg.conditions && cfg.conditions.length > 0 ? cfg.conditions[0].id : null;
|
|
66
|
+
const firstResolution = cfg && cfg.resolutions && cfg.resolutions.length > 0 ? cfg.resolutions[0].id : null;
|
|
67
|
+
defaults = {
|
|
68
|
+
qty_requested: current.qty_requested != null ? current.qty_requested : 1,
|
|
69
|
+
reason_id: current.reason_id != null ? current.reason_id : (firstReason != null ? firstReason : null),
|
|
70
|
+
condition_id: current.condition_id != null ? current.condition_id : (firstCondition != null ? firstCondition : null),
|
|
71
|
+
resolution_id: current.resolution_id != null ? current.resolution_id : (firstResolution != null ? firstResolution : null)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...prev,
|
|
76
|
+
[itemId]: {
|
|
77
|
+
...current,
|
|
78
|
+
...defaults,
|
|
79
|
+
checked
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Build input mutation sesuai struktur backend
|
|
86
|
+
const buildRmaInput = () => {
|
|
87
|
+
if (!order || !order.items) return null;
|
|
88
|
+
// Ambil shipping address
|
|
89
|
+
const shipping = order.shipping_address || {};
|
|
90
|
+
// Ambil item yang dicentang dan sudah diisi field wajib
|
|
91
|
+
const cfg = rmaConfigData && rmaConfigData.lofmpRmaConfigurations;
|
|
92
|
+
const defReason = cfg && cfg.reasons && cfg.reasons[0] ? cfg.reasons[0].id : 0;
|
|
93
|
+
const defCondition = cfg && cfg.conditions && cfg.conditions[0] ? cfg.conditions[0].id : 0;
|
|
94
|
+
const defResolution = cfg && cfg.resolutions && cfg.resolutions[0] ? cfg.resolutions[0].id : 0;
|
|
95
|
+
const items = order.items
|
|
96
|
+
.filter(it => itemReturnState[it.id] && itemReturnState[it.id].checked)
|
|
97
|
+
.map(it => {
|
|
98
|
+
const st = itemReturnState[it.id] || {};
|
|
99
|
+
let condition_id = parseInt(st.condition_id, 10);
|
|
100
|
+
let qty_requested = parseFloat(st.qty_requested);
|
|
101
|
+
let reason_id = parseInt(st.reason_id, 10);
|
|
102
|
+
let resolution_id = parseInt(st.resolution_id, 10);
|
|
103
|
+
if (isNaN(condition_id)) condition_id = defCondition;
|
|
104
|
+
if (isNaN(qty_requested) || qty_requested <= 0) qty_requested = 1;
|
|
105
|
+
if (isNaN(reason_id)) reason_id = defReason;
|
|
106
|
+
if (isNaN(resolution_id)) resolution_id = defResolution;
|
|
107
|
+
return {
|
|
108
|
+
order_item_id: it.id,
|
|
109
|
+
condition_id,
|
|
110
|
+
qty_requested,
|
|
111
|
+
reason_id,
|
|
112
|
+
resolution_id
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
if (!items.length) return null;
|
|
116
|
+
return {
|
|
117
|
+
order_number: order.number || order.increment_id,
|
|
118
|
+
items,
|
|
119
|
+
city: shipping.city,
|
|
120
|
+
country_id: shipping.country_code,
|
|
121
|
+
postcode: shipping.postcode,
|
|
122
|
+
region: shipping.region,
|
|
123
|
+
street: Array.isArray(shipping.street) ? shipping.street.join(' ') : shipping.street
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleSubmit = async () => {
|
|
128
|
+
setSubmitError(null);
|
|
129
|
+
setSubmitSuccess(null);
|
|
130
|
+
const input = buildRmaInput();
|
|
131
|
+
if (!input) {
|
|
132
|
+
setSubmitError('Pilih minimal 1 item dan lengkapi data.');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { data, error } = await createRma(input);
|
|
137
|
+
if (error) {
|
|
138
|
+
const message = error.message || 'Failed to create RMA.';
|
|
139
|
+
setSubmitError(message);
|
|
140
|
+
addToast({
|
|
141
|
+
type: 'error',
|
|
142
|
+
icon: <AlertCircleIcon size={18} />,
|
|
143
|
+
message,
|
|
144
|
+
dismissable: true,
|
|
145
|
+
timeout: 6000
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const payload = data && data.lofmpCreateRma;
|
|
150
|
+
if (payload && payload.success) {
|
|
151
|
+
const message = 'RMA request created successfully!';
|
|
152
|
+
setSubmitSuccess(message);
|
|
153
|
+
addToast({
|
|
154
|
+
type: 'info',
|
|
155
|
+
icon: <CheckCircleIcon size={18} />,
|
|
156
|
+
message,
|
|
157
|
+
dismissable: true,
|
|
158
|
+
timeout: 4000
|
|
159
|
+
});
|
|
160
|
+
// Redirect to RMA list after brief delay (optional immediate)
|
|
161
|
+
setTimeout(() => {
|
|
162
|
+
history.push('/return');
|
|
163
|
+
}, 400); // small delay for user feedback
|
|
164
|
+
} else {
|
|
165
|
+
const message = (payload && payload.message) || 'Failed to create RMA.';
|
|
166
|
+
setSubmitError(message);
|
|
167
|
+
addToast({
|
|
168
|
+
type: 'error',
|
|
169
|
+
icon: <AlertCircleIcon size={18} />,
|
|
170
|
+
message,
|
|
171
|
+
dismissable: true,
|
|
172
|
+
timeout: 6000
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
11
176
|
const { formatMessage } = useIntl();
|
|
12
177
|
const PAGE_TITLE = formatMessage({
|
|
13
178
|
id: 'Quotes.pageTitleTextRMACreate',
|
|
14
179
|
defaultMessage: 'New Return'
|
|
15
180
|
});
|
|
16
181
|
|
|
17
|
-
const urlImage = 'https://pwa-tcgcollective.local:8255/media/catalog/product/s/-/s-l1600_6__1.jpg?auto=webp&format=pjpg&width=495&height=618.75&fit=cover';
|
|
18
182
|
const dummyChat = [
|
|
19
183
|
{
|
|
20
184
|
"message": "May I help you",
|
|
@@ -72,7 +236,7 @@ const RMACreate = () => {
|
|
|
72
236
|
<div className='relative grid gap-y-md'>
|
|
73
237
|
<StoreTitle>{PAGE_TITLE}</StoreTitle>
|
|
74
238
|
<div aria-live="polite" className="text-xl font-medium text-left">
|
|
75
|
-
{PAGE_TITLE}
|
|
239
|
+
{PAGE_TITLE} {order ? `- ${order.number || order.increment_id}` : ''}
|
|
76
240
|
</div>
|
|
77
241
|
<div className='block relative'>
|
|
78
242
|
<div aria-live="polite" className="text-lg font-medium text-left mb-4">
|
|
@@ -91,57 +255,43 @@ const RMACreate = () => {
|
|
|
91
255
|
{
|
|
92
256
|
formatMessage({
|
|
93
257
|
id: 'RMA.Status',
|
|
94
|
-
defaultMessage: 'Status'
|
|
258
|
+
defaultMessage: 'Status Order'
|
|
95
259
|
})
|
|
96
260
|
}
|
|
97
261
|
</span>
|
|
98
262
|
<span className='font-medium block text-blue-700'>
|
|
99
|
-
|
|
263
|
+
{order?.status}
|
|
100
264
|
</span>
|
|
101
265
|
</p>
|
|
102
266
|
</div>
|
|
103
267
|
<div className='block'>
|
|
104
268
|
<p className='text-[13px] text-colorDefault flex justify-between'>
|
|
105
269
|
<span className='font-medium block'>
|
|
106
|
-
{
|
|
107
|
-
formatMessage({
|
|
108
|
-
id: 'RMA.RMANumber',
|
|
109
|
-
defaultMessage: 'RMA'
|
|
110
|
-
})
|
|
111
|
-
}
|
|
270
|
+
{formatMessage({ id: 'RMA.RMANumber', defaultMessage: 'RMA' })}
|
|
112
271
|
</span>
|
|
113
272
|
<span className='font-normal block'>
|
|
114
|
-
|
|
273
|
+
{order ? order.increment_id || order.number : '-'}
|
|
115
274
|
</span>
|
|
116
275
|
</p>
|
|
117
276
|
</div>
|
|
118
277
|
<div className='block'>
|
|
119
278
|
<p className='text-[13px] text-colorDefault flex justify-between'>
|
|
120
279
|
<span className='font-medium block'>
|
|
121
|
-
{
|
|
122
|
-
formatMessage({
|
|
123
|
-
id: 'RMA.OrderNumber',
|
|
124
|
-
defaultMessage: 'Order Number'
|
|
125
|
-
})
|
|
126
|
-
}
|
|
280
|
+
{formatMessage({ id: 'RMA.OrderNumber', defaultMessage: 'Order Number' })}
|
|
127
281
|
</span>
|
|
128
282
|
<span className='font-normal block'>
|
|
129
|
-
|
|
283
|
+
{order ? order.number || order.increment_id : '-'}
|
|
284
|
+
{order && order.order_date ? ` at ${new Date(order.order_date.replace(' ', 'T')).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}` : ''}
|
|
130
285
|
</span>
|
|
131
286
|
</p>
|
|
132
287
|
</div>
|
|
133
288
|
<div className='block'>
|
|
134
289
|
<p className='text-[13px] text-colorDefault flex justify-between'>
|
|
135
290
|
<span className='font-medium block'>
|
|
136
|
-
{
|
|
137
|
-
formatMessage({
|
|
138
|
-
id: 'RMA.dateRequested',
|
|
139
|
-
defaultMessage: 'Date Requested'
|
|
140
|
-
})
|
|
141
|
-
}
|
|
291
|
+
{formatMessage({ id: 'RMA.dateRequested', defaultMessage: 'Date Requested' })}
|
|
142
292
|
</span>
|
|
143
293
|
<span className='font-normal block'>
|
|
144
|
-
|
|
294
|
+
{new Date().toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}
|
|
145
295
|
</span>
|
|
146
296
|
</p>
|
|
147
297
|
</div>
|
|
@@ -159,13 +309,20 @@ const RMACreate = () => {
|
|
|
159
309
|
</span>
|
|
160
310
|
</p>
|
|
161
311
|
<p className='text-[13px] text-colorDefault whitespace-pre-wrap'>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
312
|
+
{order && order.shipping_address ? (
|
|
313
|
+
<>
|
|
314
|
+
{order.shipping_address.firstname} {order.shipping_address.lastname}{'\n'}
|
|
315
|
+
{order.shipping_address.telephone}{'\n'}
|
|
316
|
+
{order.shipping_address.street && Array.isArray(order.shipping_address.street) ? order.shipping_address.street.join(', ') : order.shipping_address.street}{'\n'}
|
|
317
|
+
{order.shipping_address.city}{order.shipping_address.region ? ', ' + order.shipping_address.region : ''}{'\n'}
|
|
318
|
+
{order.shipping_address.postcode}{'\n'}
|
|
319
|
+
{order.shipping_address.country_code}
|
|
320
|
+
</>
|
|
321
|
+
) : (
|
|
322
|
+
<>
|
|
323
|
+
-
|
|
324
|
+
</>
|
|
325
|
+
)}
|
|
169
326
|
</p>
|
|
170
327
|
</div>
|
|
171
328
|
</div>
|
|
@@ -176,9 +333,22 @@ const RMACreate = () => {
|
|
|
176
333
|
Items
|
|
177
334
|
</div>
|
|
178
335
|
<div className='border-t border-gray-100 py-4 flex flex-col gap-y-4'>
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
336
|
+
{order && order.items && order.items.length > 0 ? (
|
|
337
|
+
order.items.map((item, idx) => (
|
|
338
|
+
<Item
|
|
339
|
+
key={item.id || idx}
|
|
340
|
+
item={item}
|
|
341
|
+
order={order}
|
|
342
|
+
withCheckbox
|
|
343
|
+
rmaConfigData={rmaConfigData}
|
|
344
|
+
itemState={itemReturnState[item.id] || {}}
|
|
345
|
+
onItemChange={(field, value) => handleItemChange(item.id, field, value)}
|
|
346
|
+
onItemCheck={checked => handleItemCheck(item.id, checked)}
|
|
347
|
+
/>
|
|
348
|
+
))
|
|
349
|
+
) : (
|
|
350
|
+
<span className='text-gray-400'>No items found.</span>
|
|
351
|
+
)}
|
|
182
352
|
</div>
|
|
183
353
|
</div>
|
|
184
354
|
<div className=' flex flex-col mb-10'>
|
|
@@ -211,6 +381,25 @@ const RMACreate = () => {
|
|
|
211
381
|
</Button>
|
|
212
382
|
</div>
|
|
213
383
|
</div>
|
|
384
|
+
<div className='flex justify-end flex-row gap-4 mt-6 mb-4'>
|
|
385
|
+
<Button
|
|
386
|
+
priority='high'
|
|
387
|
+
onClick={handleSubmit}
|
|
388
|
+
disabled={createRmaLoading}
|
|
389
|
+
className={cn(
|
|
390
|
+
'px-6 py-2 rounded-full text-white border flex items-center gap-2',
|
|
391
|
+
createRmaLoading
|
|
392
|
+
? 'bg-gray-400 border-gray-400 cursor-not-allowed'
|
|
393
|
+
: 'bg-blue-700 border-blue-700 hover_bg-blue-700 hover_border-blue-700',
|
|
394
|
+
'focus-visible_outline-none'
|
|
395
|
+
)}
|
|
396
|
+
>
|
|
397
|
+
{createRmaLoading && (
|
|
398
|
+
<span className="inline-block h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin" />
|
|
399
|
+
)}
|
|
400
|
+
{createRmaLoading ? 'Submitting...' : 'Submit RMA Request'}
|
|
401
|
+
</Button>
|
|
402
|
+
</div>
|
|
214
403
|
</div>
|
|
215
404
|
<style jsx="true">
|
|
216
405
|
{`
|