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