order-management 0.0.91 → 0.0.93
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/.medusa/server/src/admin/index.js +154 -103
- package/.medusa/server/src/admin/index.mjs +154 -103
- package/.medusa/server/src/api/admin/orders/[order_id]/refund-context/route.js +203 -27
- package/.medusa/server/src/api/admin/payment-transactions/validators.js +2 -2
- package/.medusa/server/src/api/admin/refund-payment-mapping/[return_id]/mark-refunded/route.js +38 -1
- package/.medusa/server/src/api/admin/refund-payment-mapping/validators.js +2 -2
- package/.medusa/server/src/api/admin/refunds/validators.js +2 -2
- package/.medusa/server/src/api/admin/return/[id]/reject/route.js +3 -3
- package/.medusa/server/src/api/admin/return/[id]/route.js +20 -5
- package/.medusa/server/src/api/admin/return/route.js +4 -10
- package/.medusa/server/src/api/admin/return/validators.js +2 -2
- package/.medusa/server/src/api/admin/swaps/validators.js +3 -3
- package/.medusa/server/src/api/middlewares/block-refund-until-return-received.js +97 -0
- package/.medusa/server/src/api/middlewares.js +7 -1
- package/.medusa/server/src/api/store/guest-orders/[id]/payment-details/route.js +161 -0
- package/.medusa/server/src/api/store/guest-orders/[id]/returns/[return_id]/refund-payment/route.js +132 -0
- package/.medusa/server/src/api/store/guest-orders/[id]/returns/route.js +132 -12
- package/.medusa/server/src/api/store/guest-orders/[id]/swaps/route.js +2 -2
- package/.medusa/server/src/api/store/orders/[order_id]/refund-payment-mappings/route.js +9 -4
- package/.medusa/server/src/api/store/payment-details/validators.js +63 -31
- package/.medusa/server/src/api/store/returns/[id]/route.js +16 -9
- package/.medusa/server/src/api/store/returns/route.js +39 -15
- package/.medusa/server/src/api/store/returns/validators.js +15 -3
- package/.medusa/server/src/api/store/swaps/route.js +2 -2
- package/.medusa/server/src/api/store/validators/cancel-order.js +2 -2
- package/.medusa/server/src/helpers/detect-cod.js +81 -13
- package/.medusa/server/src/helpers/index.js +2 -1
- package/.medusa/server/src/helpers/refund-calculation.js +3 -2
- package/.medusa/server/src/helpers/refund-receive-guard.js +48 -0
- package/.medusa/server/src/helpers/resolve-return-refund-payment.js +66 -0
- package/.medusa/server/src/helpers/returns.js +140 -2
- package/.medusa/server/src/modules/payment-detail/service.js +9 -1
- package/README.md +52 -10
- package/package.json +17 -17
|
@@ -375,15 +375,14 @@ const s = {
|
|
|
375
375
|
const OrderGiftItemsWidget = ({ data }) => {
|
|
376
376
|
const [fetchedItems, setFetchedItems] = react.useState(null);
|
|
377
377
|
react.useEffect(() => {
|
|
378
|
-
if (!
|
|
378
|
+
if (!data?.id) return;
|
|
379
379
|
fetch(
|
|
380
380
|
`/admin/orders/${data.id}?fields=*items,items.metadata`
|
|
381
|
-
).then((r) => r.json()).then(({ order }) => setFetchedItems(
|
|
382
|
-
}, [data
|
|
383
|
-
const items = fetchedItems ??
|
|
381
|
+
).then((r) => r.json()).then(({ order }) => setFetchedItems(order?.items ?? [])).catch(() => setFetchedItems(data?.items ?? []));
|
|
382
|
+
}, [data?.id]);
|
|
383
|
+
const items = fetchedItems ?? data?.items ?? [];
|
|
384
384
|
const giftedItems = items.filter((i) => {
|
|
385
|
-
|
|
386
|
-
const flag = (_a = i.metadata) == null ? void 0 : _a.is_gift;
|
|
385
|
+
const flag = i.metadata?.is_gift;
|
|
387
386
|
return flag === "true" || flag === true;
|
|
388
387
|
});
|
|
389
388
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.widget, children: [
|
|
@@ -412,9 +411,9 @@ const OrderGiftItemsWidget = ({ data }) => {
|
|
|
412
411
|
),
|
|
413
412
|
giftedItems.map((item) => {
|
|
414
413
|
const meta = item.metadata;
|
|
415
|
-
const from = meta
|
|
416
|
-
const to = meta
|
|
417
|
-
const message = meta
|
|
414
|
+
const from = meta?.gift_from;
|
|
415
|
+
const to = meta?.gift_to;
|
|
416
|
+
const message = meta?.gift_message;
|
|
418
417
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.card, children: [
|
|
419
418
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.ribbon, children: [
|
|
420
419
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.bowCenter, children: "🎀" }),
|
|
@@ -478,7 +477,7 @@ function formatRefundCurrency(amount, currencyCode = "inr", options) {
|
|
|
478
477
|
minimumFractionDigits: 2,
|
|
479
478
|
maximumFractionDigits: 2
|
|
480
479
|
}).format(amount);
|
|
481
|
-
if (
|
|
480
|
+
if (options?.signed && amount > 0) {
|
|
482
481
|
return `−${formatted}`;
|
|
483
482
|
}
|
|
484
483
|
return formatted;
|
|
@@ -533,8 +532,7 @@ function getOrderIdFromPath() {
|
|
|
533
532
|
return m ? m[1] : void 0;
|
|
534
533
|
}
|
|
535
534
|
const OrderRefundContextWidget = (props) => {
|
|
536
|
-
|
|
537
|
-
const orderId = ((_a = props.order) == null ? void 0 : _a.id) ?? ((_c = (_b = props.data) == null ? void 0 : _b.order) == null ? void 0 : _c.id) ?? getOrderIdFromPath();
|
|
535
|
+
const orderId = props.order?.id ?? props.data?.order?.id ?? getOrderIdFromPath();
|
|
538
536
|
const [context, setContext] = react.useState(null);
|
|
539
537
|
const [loading, setLoading] = react.useState(!!orderId);
|
|
540
538
|
const [error, setError] = react.useState(null);
|
|
@@ -572,7 +570,9 @@ const OrderRefundContextWidget = (props) => {
|
|
|
572
570
|
};
|
|
573
571
|
}, [orderId]);
|
|
574
572
|
const handleMarkRefunded = async () => {
|
|
575
|
-
if (!
|
|
573
|
+
if (!context?.return_id || !context?.refund_mapping || context.refund_mapping.is_refunded || !context.can_process_refund) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
576
|
setMarking(true);
|
|
577
577
|
setMarkError(null);
|
|
578
578
|
try {
|
|
@@ -587,16 +587,14 @@ const OrderRefundContextWidget = (props) => {
|
|
|
587
587
|
}
|
|
588
588
|
const data = await res.json();
|
|
589
589
|
setContext(
|
|
590
|
-
(prev) => {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
refund_mapping
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
} : prev;
|
|
599
|
-
}
|
|
590
|
+
(prev) => prev && prev.refund_mapping ? {
|
|
591
|
+
...prev,
|
|
592
|
+
can_process_refund: false,
|
|
593
|
+
refund_mapping: {
|
|
594
|
+
...prev.refund_mapping,
|
|
595
|
+
is_refunded: data.refund_payment_mapping?.is_refunded ?? true
|
|
596
|
+
}
|
|
597
|
+
} : prev
|
|
600
598
|
);
|
|
601
599
|
} catch (e) {
|
|
602
600
|
setMarkError(e instanceof Error ? e.message : "Failed to mark refunded");
|
|
@@ -605,20 +603,19 @@ const OrderRefundContextWidget = (props) => {
|
|
|
605
603
|
}
|
|
606
604
|
};
|
|
607
605
|
const handleEditClick = () => {
|
|
608
|
-
const mapping = context
|
|
609
|
-
const mode = mapping
|
|
606
|
+
const mapping = context?.refund_mapping;
|
|
607
|
+
const mode = mapping?.refund_mode;
|
|
610
608
|
setEditRefundMode(
|
|
611
609
|
mode === "offline" || mode === "online" ? mode : ""
|
|
612
610
|
);
|
|
613
|
-
setEditDetails(
|
|
614
|
-
setEditImageUrls(
|
|
611
|
+
setEditDetails(mapping?.details ?? "");
|
|
612
|
+
setEditImageUrls(mapping?.images ?? []);
|
|
615
613
|
setSaveError(null);
|
|
616
614
|
setUploadError(null);
|
|
617
615
|
setEditing(true);
|
|
618
616
|
};
|
|
619
617
|
const handleUploadImage = async (e) => {
|
|
620
|
-
|
|
621
|
-
const file = (_a2 = e.target.files) == null ? void 0 : _a2[0];
|
|
618
|
+
const file = e.target.files?.[0];
|
|
622
619
|
if (!file) return;
|
|
623
620
|
setUploading(true);
|
|
624
621
|
setUploadError(null);
|
|
@@ -635,7 +632,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
635
632
|
throw new Error(data2.message || "Upload failed");
|
|
636
633
|
}
|
|
637
634
|
const data = await res.json();
|
|
638
|
-
const url =
|
|
635
|
+
const url = data.files?.[0]?.url;
|
|
639
636
|
if (url) setEditImageUrls((prev) => [...prev, url]);
|
|
640
637
|
} catch (err) {
|
|
641
638
|
setUploadError(err instanceof Error ? err.message : "Upload failed");
|
|
@@ -648,7 +645,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
648
645
|
setEditImageUrls((prev) => prev.filter((_, i) => i !== index));
|
|
649
646
|
};
|
|
650
647
|
const handleSaveAdminFields = async () => {
|
|
651
|
-
if (!
|
|
648
|
+
if (!context?.return_id) return;
|
|
652
649
|
setSaving(true);
|
|
653
650
|
setSaveError(null);
|
|
654
651
|
try {
|
|
@@ -685,43 +682,62 @@ const OrderRefundContextWidget = (props) => {
|
|
|
685
682
|
if (error) {
|
|
686
683
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mt-6 divide-y p-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: error }) }) });
|
|
687
684
|
}
|
|
688
|
-
const hasReturn = !!
|
|
689
|
-
const hasMapping = !!
|
|
690
|
-
const canMarkRefunded =
|
|
691
|
-
const
|
|
685
|
+
const hasReturn = !!context?.return_id;
|
|
686
|
+
const hasMapping = !!context?.refund_mapping;
|
|
687
|
+
const canMarkRefunded = Boolean(context?.can_process_refund);
|
|
688
|
+
const returnStatus = context?.return_status ?? null;
|
|
689
|
+
const showReceiveFirstHint = hasReturn && !context?.refund_mapping?.is_refunded && returnStatus !== "received" && returnStatus !== "canceled";
|
|
690
|
+
const paymentDetail = context?.payment_detail;
|
|
691
|
+
const paymentDetails = context?.payment_details && context.payment_details.length > 0 ? context.payment_details : paymentDetail ? [paymentDetail] : [];
|
|
692
|
+
const orderPayment = context?.order_payment;
|
|
692
693
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mt-6 divide-y p-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 py-4", children: [
|
|
693
694
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Heading, { level: "h2", className: "flex items-center gap-2", children: [
|
|
694
695
|
/* @__PURE__ */ jsxRuntime.jsx(icons.CashSolid, { className: "text-ui-fg-subtle" }),
|
|
695
696
|
"Refund payment"
|
|
696
697
|
] }),
|
|
697
698
|
!hasReturn && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No return for this order." }),
|
|
699
|
+
showReceiveFirstHint && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Receive returned items before processing a refund. Do not refund from Payments until items are received." }),
|
|
698
700
|
hasMapping && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: [
|
|
699
701
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
700
702
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Return" }),
|
|
701
703
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: context.return_id }),
|
|
702
|
-
|
|
704
|
+
context.refund_mapping?.is_refunded ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Refunded" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Not refunded" })
|
|
703
705
|
] }),
|
|
704
706
|
context.refund ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 border-t border-ui-border-base pt-3", children: /* @__PURE__ */ jsxRuntime.jsx(RefundCalculationBlock, { refund: context.refund }) }) : null,
|
|
707
|
+
orderPayment && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
|
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Order payment method" }),
|
|
709
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
710
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: orderPayment.label }),
|
|
711
|
+
orderPayment.is_cod ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "COD" }) : null
|
|
712
|
+
] }),
|
|
713
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: orderPayment.provider_id })
|
|
714
|
+
] }),
|
|
705
715
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
|
|
706
716
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
707
717
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Payment method (refund destination)" }),
|
|
708
|
-
|
|
718
|
+
context.refund_mapping?.payment_id ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Customer specified" }) : paymentDetail ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Customer default" }) : orderPayment && !orderPayment.is_cod ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "blue", children: "Original payment method" }) : null
|
|
709
719
|
] }),
|
|
710
|
-
|
|
711
|
-
!
|
|
712
|
-
!
|
|
713
|
-
|
|
720
|
+
context.refund_mapping?.payment_id && !paymentDetail && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-orange-200 bg-orange-50 px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "The customer specified a payment method for this return, but that payment method has since been removed from their account. Ask the customer to update their refund payment method." }) }),
|
|
721
|
+
!context.refund_mapping?.payment_id && paymentDetail?.source === "default" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "The customer did not specify a payment method for this return. Showing their default payment method." }) }),
|
|
722
|
+
!context.refund_mapping?.payment_id && !paymentDetail && orderPayment && !orderPayment.is_cod && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: [
|
|
723
|
+
"Refund will go to the original payment method (",
|
|
724
|
+
orderPayment.label,
|
|
725
|
+
")."
|
|
726
|
+
] }) }),
|
|
727
|
+
!context.refund_mapping?.payment_id && !paymentDetail && (context.is_cod || orderPayment?.is_cod) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "This order was paid with Cash on Delivery. No stored bank/UPI refund destination." }) }),
|
|
728
|
+
!context.refund_mapping?.payment_id && !paymentDetail && !orderPayment && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "No payment method found for this customer." }) }),
|
|
729
|
+
paymentDetails.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: paymentDetails.map((detail) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
714
730
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
715
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children:
|
|
716
|
-
|
|
731
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: detail.type.toUpperCase() }),
|
|
732
|
+
detail.is_default && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "blue", children: "Default" })
|
|
717
733
|
] }),
|
|
718
|
-
Object.keys(
|
|
734
|
+
Object.keys(detail.detail_json).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-x-6 gap-y-2", children: Object.entries(detail.detail_json).map(([k, v]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
719
735
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: FIELD_LABELS[k] ?? k }),
|
|
720
736
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "block", children: String(v) })
|
|
721
|
-
] }, k)) })
|
|
722
|
-
] })
|
|
737
|
+
] }, `${detail.id}-${k}`)) })
|
|
738
|
+
] }, detail.id)) })
|
|
723
739
|
] }),
|
|
724
|
-
|
|
740
|
+
context?.refund_mapping && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-3 border-t border-ui-border-base pt-3", children: [
|
|
725
741
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
726
742
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Refund mode, details & images" }),
|
|
727
743
|
!editing ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -809,10 +825,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
809
825
|
variant: "secondary",
|
|
810
826
|
type: "button",
|
|
811
827
|
disabled: uploading,
|
|
812
|
-
onClick: () =>
|
|
813
|
-
var _a2;
|
|
814
|
-
return (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
815
|
-
},
|
|
828
|
+
onClick: () => fileInputRef.current?.click(),
|
|
816
829
|
children: uploading ? "Uploading…" : "Upload image"
|
|
817
830
|
}
|
|
818
831
|
),
|
|
@@ -863,7 +876,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
863
876
|
] }),
|
|
864
877
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
865
878
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: "Images" }),
|
|
866
|
-
|
|
879
|
+
context.refund_mapping.images?.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-wrap gap-2", children: context.refund_mapping.images.map((url, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
867
880
|
"a",
|
|
868
881
|
{
|
|
869
882
|
href: url,
|
|
@@ -892,10 +905,18 @@ const OrderRefundContextWidget = (props) => {
|
|
|
892
905
|
}
|
|
893
906
|
),
|
|
894
907
|
markError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: markError })
|
|
895
|
-
] })
|
|
908
|
+
] }),
|
|
909
|
+
hasMapping && !canMarkRefunded && !context.refund_mapping?.is_refunded && showReceiveFirstHint && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-4 text-ui-fg-muted", children: "Mark refunded is available after the return is received." })
|
|
896
910
|
] }),
|
|
897
911
|
hasReturn && !hasMapping && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: [
|
|
898
|
-
|
|
912
|
+
context?.refund ? /* @__PURE__ */ jsxRuntime.jsx(RefundCalculationBlock, { refund: context.refund }) : null,
|
|
913
|
+
orderPayment && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-3 space-y-1", children: [
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Order payment method" }),
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: orderPayment.label }),
|
|
917
|
+
orderPayment.is_cod ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "COD" }) : null
|
|
918
|
+
] })
|
|
919
|
+
] }),
|
|
899
920
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No refund payment mapping for this return. Ensure the refund_payment_mapping module is registered and a mapping was created when the return was created." })
|
|
900
921
|
] })
|
|
901
922
|
] }) });
|
|
@@ -1440,7 +1461,6 @@ const ReturnsPage = () => {
|
|
|
1440
1461
|
const limit = 50;
|
|
1441
1462
|
const loadReturns = react.useCallback(
|
|
1442
1463
|
async (nextOffset, replace = false) => {
|
|
1443
|
-
var _a;
|
|
1444
1464
|
try {
|
|
1445
1465
|
if (replace) {
|
|
1446
1466
|
setIsLoading(true);
|
|
@@ -1471,7 +1491,7 @@ const ReturnsPage = () => {
|
|
|
1471
1491
|
}
|
|
1472
1492
|
const payload = await response.json();
|
|
1473
1493
|
setCount(payload.count ?? 0);
|
|
1474
|
-
setOffset(nextOffset + (
|
|
1494
|
+
setOffset(nextOffset + (payload.returns?.length ?? 0));
|
|
1475
1495
|
setItems(
|
|
1476
1496
|
(prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
|
|
1477
1497
|
);
|
|
@@ -1583,7 +1603,7 @@ const ReturnsPage = () => {
|
|
|
1583
1603
|
) }),
|
|
1584
1604
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1585
1605
|
const calc = returnOrder.refund;
|
|
1586
|
-
if (
|
|
1606
|
+
if (calc?.is_processed && calc.final_refund_amount != null) {
|
|
1587
1607
|
return formatRefundCurrency(
|
|
1588
1608
|
calc.final_refund_amount,
|
|
1589
1609
|
calc.currency_code || returnOrder.currency_code
|
|
@@ -1682,7 +1702,6 @@ const SwapsPage = () => {
|
|
|
1682
1702
|
const limit = 50;
|
|
1683
1703
|
const loadSwaps = react.useCallback(
|
|
1684
1704
|
async (nextOffset, replace = false) => {
|
|
1685
|
-
var _a;
|
|
1686
1705
|
try {
|
|
1687
1706
|
if (replace) {
|
|
1688
1707
|
setIsLoading(true);
|
|
@@ -1712,7 +1731,7 @@ const SwapsPage = () => {
|
|
|
1712
1731
|
}
|
|
1713
1732
|
const payload = await response.json();
|
|
1714
1733
|
setCount(payload.count ?? 0);
|
|
1715
|
-
setOffset(nextOffset + (
|
|
1734
|
+
setOffset(nextOffset + (payload.swaps?.length ?? 0));
|
|
1716
1735
|
setItems(
|
|
1717
1736
|
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1718
1737
|
);
|
|
@@ -1879,10 +1898,9 @@ const getStatusBadgeClass$3 = (status) => {
|
|
|
1879
1898
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1880
1899
|
};
|
|
1881
1900
|
const PaymentDetailPage = () => {
|
|
1882
|
-
var _a;
|
|
1883
1901
|
const navigate = reactRouterDom.useNavigate();
|
|
1884
1902
|
const params = reactRouterDom.useParams();
|
|
1885
|
-
const id =
|
|
1903
|
+
const id = params?.id?.trim();
|
|
1886
1904
|
const [detail, setDetail] = react.useState(null);
|
|
1887
1905
|
const [loading, setLoading] = react.useState(!!id);
|
|
1888
1906
|
const [error, setError] = react.useState(null);
|
|
@@ -1909,8 +1927,8 @@ const PaymentDetailPage = () => {
|
|
|
1909
1927
|
};
|
|
1910
1928
|
}, [id]);
|
|
1911
1929
|
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
1912
|
-
const sessionStatusRaw =
|
|
1913
|
-
const paymentStatusRaw =
|
|
1930
|
+
const sessionStatusRaw = detail?.session_status ?? "—";
|
|
1931
|
+
const paymentStatusRaw = detail?.payment_id != null ? detail?.payment_status ?? "—" : "—";
|
|
1914
1932
|
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
1915
1933
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
1916
1934
|
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
@@ -2001,10 +2019,9 @@ const formatAmount = (value) => {
|
|
|
2001
2019
|
return String(value);
|
|
2002
2020
|
};
|
|
2003
2021
|
const RefundDetailPage = () => {
|
|
2004
|
-
var _a, _b, _c;
|
|
2005
2022
|
const navigate = reactRouterDom.useNavigate();
|
|
2006
2023
|
const params = reactRouterDom.useParams();
|
|
2007
|
-
const id =
|
|
2024
|
+
const id = params?.id?.trim();
|
|
2008
2025
|
const [detail, setDetail] = react.useState(null);
|
|
2009
2026
|
const [loading, setLoading] = react.useState(!!id);
|
|
2010
2027
|
const [error, setError] = react.useState(null);
|
|
@@ -2031,8 +2048,8 @@ const RefundDetailPage = () => {
|
|
|
2031
2048
|
cancelled = true;
|
|
2032
2049
|
};
|
|
2033
2050
|
}, [id]);
|
|
2034
|
-
const paymentStatus =
|
|
2035
|
-
const hasGatewayData =
|
|
2051
|
+
const paymentStatus = detail?.payment?.status ?? "—";
|
|
2052
|
+
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
2036
2053
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
2037
2054
|
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2038
2055
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
@@ -2207,7 +2224,6 @@ const getStatusBadgeClass$1 = (status) => {
|
|
|
2207
2224
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2208
2225
|
};
|
|
2209
2226
|
const ReturnDetailPage = () => {
|
|
2210
|
-
var _a, _b;
|
|
2211
2227
|
const navigate = reactRouterDom.useNavigate();
|
|
2212
2228
|
const { id } = reactRouterDom.useParams();
|
|
2213
2229
|
const [returnOrder, setReturnOrder] = react.useState(null);
|
|
@@ -2290,7 +2306,7 @@ const ReturnDetailPage = () => {
|
|
|
2290
2306
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2291
2307
|
] }) }) });
|
|
2292
2308
|
}
|
|
2293
|
-
const statusHistory =
|
|
2309
|
+
const statusHistory = returnOrder.metadata?.status_history || [];
|
|
2294
2310
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
2295
2311
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2296
2312
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2426,7 +2442,11 @@ const ReturnDetailPage = () => {
|
|
|
2426
2442
|
] }),
|
|
2427
2443
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2428
2444
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2429
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2445
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.customer?.email || returnOrder.order.email || "—" })
|
|
2446
|
+
] }),
|
|
2447
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2448
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
|
|
2449
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.order_payment?.label || "—" })
|
|
2430
2450
|
] }),
|
|
2431
2451
|
returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2432
2452
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
@@ -2483,13 +2503,12 @@ const getStatusBadgeClass = (status) => {
|
|
|
2483
2503
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2484
2504
|
};
|
|
2485
2505
|
const SwapDetailPage = () => {
|
|
2486
|
-
var _a, _b, _c;
|
|
2487
2506
|
const navigate = reactRouterDom.useNavigate();
|
|
2488
2507
|
const { id } = reactRouterDom.useParams();
|
|
2489
2508
|
const [swap, setSwap] = react.useState(null);
|
|
2490
2509
|
const [order, setOrder] = react.useState(null);
|
|
2491
2510
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
2492
|
-
react.useState(false);
|
|
2511
|
+
const [isRejecting, setIsRejecting] = react.useState(false);
|
|
2493
2512
|
const [isCancelling, setIsCancelling] = react.useState(false);
|
|
2494
2513
|
const [error, setError] = react.useState(null);
|
|
2495
2514
|
const [updateError, setUpdateError] = react.useState(null);
|
|
@@ -2560,9 +2579,9 @@ const SwapDetailPage = () => {
|
|
|
2560
2579
|
setIsCancelling(false);
|
|
2561
2580
|
}
|
|
2562
2581
|
};
|
|
2563
|
-
const isOrderExchange = Boolean(swap
|
|
2582
|
+
const isOrderExchange = Boolean(swap?.exchange_id);
|
|
2564
2583
|
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2565
|
-
|
|
2584
|
+
swap.status?.toLowerCase() ?? ""
|
|
2566
2585
|
);
|
|
2567
2586
|
if (isLoading) {
|
|
2568
2587
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
|
|
@@ -2573,7 +2592,7 @@ const SwapDetailPage = () => {
|
|
|
2573
2592
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2574
2593
|
] }) }) });
|
|
2575
2594
|
}
|
|
2576
|
-
const statusHistory =
|
|
2595
|
+
const statusHistory = swap.metadata?.status_history || [];
|
|
2577
2596
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
2578
2597
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2579
2598
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2694,7 +2713,7 @@ const SwapDetailPage = () => {
|
|
|
2694
2713
|
] }),
|
|
2695
2714
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2696
2715
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2697
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2716
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.customer?.email || order.email || "—" })
|
|
2698
2717
|
] }),
|
|
2699
2718
|
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2700
2719
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
@@ -2743,98 +2762,124 @@ const i18nTranslations0 = {};
|
|
|
2743
2762
|
const widgetModule = { widgets: [
|
|
2744
2763
|
{
|
|
2745
2764
|
Component: OrderGiftItemsWidget,
|
|
2746
|
-
zone: ["order.details.side.after"]
|
|
2765
|
+
zone: ["order.details.side.after"],
|
|
2766
|
+
widgetId: "Widget-b753"
|
|
2747
2767
|
},
|
|
2748
2768
|
{
|
|
2749
2769
|
Component: OrderRefundContextWidget,
|
|
2750
|
-
zone: ["order.details.after"]
|
|
2770
|
+
zone: ["order.details.after"],
|
|
2771
|
+
widgetId: "Widget-0606"
|
|
2751
2772
|
}
|
|
2752
2773
|
] };
|
|
2753
2774
|
const routeModule = {
|
|
2754
2775
|
routes: [
|
|
2755
2776
|
{
|
|
2756
2777
|
Component: PaymentsPage,
|
|
2757
|
-
path: "/payments"
|
|
2778
|
+
path: "/payments",
|
|
2779
|
+
handle: { label: config$7.label, translationNs: config$7.translationNs }
|
|
2758
2780
|
},
|
|
2759
2781
|
{
|
|
2760
2782
|
Component: RefundsPage,
|
|
2761
|
-
path: "/refunds"
|
|
2783
|
+
path: "/refunds",
|
|
2784
|
+
handle: { label: config$6.label, translationNs: config$6.translationNs }
|
|
2762
2785
|
},
|
|
2763
2786
|
{
|
|
2764
2787
|
Component: ReturnsPage,
|
|
2765
|
-
path: "/returns"
|
|
2788
|
+
path: "/returns",
|
|
2789
|
+
handle: { label: config$5.label, translationNs: config$5.translationNs }
|
|
2766
2790
|
},
|
|
2767
2791
|
{
|
|
2768
2792
|
Component: SwapsPage,
|
|
2769
|
-
path: "/swaps"
|
|
2793
|
+
path: "/swaps",
|
|
2794
|
+
handle: { label: config$4.label, translationNs: config$4.translationNs }
|
|
2770
2795
|
},
|
|
2771
2796
|
{
|
|
2772
2797
|
Component: PaymentDetailPage,
|
|
2773
|
-
path: "/payments/:id"
|
|
2798
|
+
path: "/payments/:id",
|
|
2799
|
+
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
2774
2800
|
},
|
|
2775
2801
|
{
|
|
2776
2802
|
Component: RefundDetailPage,
|
|
2777
|
-
path: "/refunds/:id"
|
|
2803
|
+
path: "/refunds/:id",
|
|
2804
|
+
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
2778
2805
|
},
|
|
2779
2806
|
{
|
|
2780
2807
|
Component: ReturnDetailPage,
|
|
2781
|
-
path: "/returns/:id"
|
|
2808
|
+
path: "/returns/:id",
|
|
2809
|
+
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
2782
2810
|
},
|
|
2783
2811
|
{
|
|
2784
2812
|
Component: SwapDetailPage,
|
|
2785
|
-
path: "/swaps/:id"
|
|
2813
|
+
path: "/swaps/:id",
|
|
2814
|
+
handle: { label: config.label, translationNs: config.translationNs }
|
|
2786
2815
|
}
|
|
2787
2816
|
]
|
|
2788
2817
|
};
|
|
2789
2818
|
const menuItemModule = {
|
|
2790
2819
|
menuItems: [
|
|
2820
|
+
{
|
|
2821
|
+
label: config$7.label,
|
|
2822
|
+
icon: config$7.icon,
|
|
2823
|
+
path: "/payments",
|
|
2824
|
+
nested: void 0,
|
|
2825
|
+
rank: void 0,
|
|
2826
|
+
translationNs: void 0
|
|
2827
|
+
},
|
|
2791
2828
|
{
|
|
2792
2829
|
label: config$6.label,
|
|
2793
2830
|
icon: config$6.icon,
|
|
2794
2831
|
path: "/refunds",
|
|
2795
|
-
nested: void 0
|
|
2832
|
+
nested: void 0,
|
|
2833
|
+
rank: void 0,
|
|
2834
|
+
translationNs: void 0
|
|
2796
2835
|
},
|
|
2797
2836
|
{
|
|
2798
2837
|
label: config$5.label,
|
|
2799
2838
|
icon: config$5.icon,
|
|
2800
2839
|
path: "/returns",
|
|
2801
|
-
nested: void 0
|
|
2840
|
+
nested: void 0,
|
|
2841
|
+
rank: void 0,
|
|
2842
|
+
translationNs: void 0
|
|
2802
2843
|
},
|
|
2803
2844
|
{
|
|
2804
2845
|
label: config$4.label,
|
|
2805
2846
|
icon: config$4.icon,
|
|
2806
2847
|
path: "/swaps",
|
|
2807
|
-
nested: void 0
|
|
2848
|
+
nested: void 0,
|
|
2849
|
+
rank: void 0,
|
|
2850
|
+
translationNs: void 0
|
|
2808
2851
|
},
|
|
2809
2852
|
{
|
|
2810
|
-
label: config$
|
|
2811
|
-
icon: config$
|
|
2812
|
-
path: "/payments",
|
|
2813
|
-
nested: void 0
|
|
2853
|
+
label: config$3.label,
|
|
2854
|
+
icon: config$3.icon,
|
|
2855
|
+
path: "/payments/:id",
|
|
2856
|
+
nested: void 0,
|
|
2857
|
+
rank: void 0,
|
|
2858
|
+
translationNs: void 0
|
|
2814
2859
|
},
|
|
2815
2860
|
{
|
|
2816
2861
|
label: config$2.label,
|
|
2817
2862
|
icon: config$2.icon,
|
|
2818
2863
|
path: "/refunds/:id",
|
|
2819
|
-
nested: void 0
|
|
2864
|
+
nested: void 0,
|
|
2865
|
+
rank: void 0,
|
|
2866
|
+
translationNs: void 0
|
|
2820
2867
|
},
|
|
2821
2868
|
{
|
|
2822
2869
|
label: config$1.label,
|
|
2823
2870
|
icon: config$1.icon,
|
|
2824
2871
|
path: "/returns/:id",
|
|
2825
|
-
nested: void 0
|
|
2872
|
+
nested: void 0,
|
|
2873
|
+
rank: void 0,
|
|
2874
|
+
translationNs: void 0
|
|
2826
2875
|
},
|
|
2827
2876
|
{
|
|
2828
2877
|
label: config.label,
|
|
2829
2878
|
icon: config.icon,
|
|
2830
2879
|
path: "/swaps/:id",
|
|
2831
|
-
nested: void 0
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
label: config$3.label,
|
|
2835
|
-
icon: config$3.icon,
|
|
2836
|
-
path: "/payments/:id",
|
|
2837
|
-
nested: void 0
|
|
2880
|
+
nested: void 0,
|
|
2881
|
+
rank: void 0,
|
|
2882
|
+
translationNs: void 0
|
|
2838
2883
|
}
|
|
2839
2884
|
]
|
|
2840
2885
|
};
|
|
@@ -2843,12 +2888,18 @@ const displayModule = {
|
|
|
2843
2888
|
displays: {}
|
|
2844
2889
|
};
|
|
2845
2890
|
const i18nModule = { resources: i18nTranslations0 };
|
|
2891
|
+
const cellRendererModule = {};
|
|
2892
|
+
const layoutModule = { layouts: [] };
|
|
2893
|
+
const searchEntityModule = {};
|
|
2846
2894
|
const plugin = {
|
|
2847
2895
|
widgetModule,
|
|
2848
2896
|
routeModule,
|
|
2849
2897
|
menuItemModule,
|
|
2850
2898
|
formModule,
|
|
2851
2899
|
displayModule,
|
|
2852
|
-
i18nModule
|
|
2900
|
+
i18nModule,
|
|
2901
|
+
cellRendererModule,
|
|
2902
|
+
layoutModule,
|
|
2903
|
+
searchEntityModule
|
|
2853
2904
|
};
|
|
2854
2905
|
module.exports = plugin;
|