order-management 0.0.96 → 0.0.98
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 +2863 -824
- package/.medusa/server/src/admin/index.mjs +2867 -828
- package/.medusa/server/src/api/admin/deleted-records-audit/[id]/route.js +30 -0
- package/.medusa/server/src/api/admin/deleted-records-audit/route.js +48 -0
- package/.medusa/server/src/api/admin/deleted-records-audit/stats/route.js +27 -0
- package/.medusa/server/src/api/admin/deleted-records-audit/validators.js +57 -0
- package/.medusa/server/src/modules/deleted-records-audit/audited-tables.js +257 -0
- package/.medusa/server/src/modules/deleted-records-audit/index.js +14 -0
- package/.medusa/server/src/modules/deleted-records-audit/migrations/Migration20261008120000.js +81 -0
- package/.medusa/server/src/modules/deleted-records-audit/models/deleted-records-audit.js +15 -0
- package/.medusa/server/src/modules/deleted-records-audit/service.js +164 -0
- package/.medusa/server/src/modules/deleted-records-audit/types.js +3 -0
- package/.medusa/server/src/utils/notification-handler.js +38 -11
- package/README.md +79 -1
- package/package.json +1 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
5
|
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
-
import { useState, useEffect, useRef,
|
|
4
|
-
import { Text, Container, Heading, Badge, Button, Label, Select, Textarea, Input } from "@medusajs/ui";
|
|
5
|
-
import { CashSolid, PencilSquareSolid, Trash,
|
|
6
|
-
import { useNavigate, useParams } from "react-router-dom";
|
|
6
|
+
import { useState, useEffect, useRef, useMemo, useCallback } from "react";
|
|
7
|
+
import { Text, Container, Heading, Badge, Button, Label, Select, Textarea, Popover, clx, Input, Copy, Skeleton, Tooltip, toast } from "@medusajs/ui";
|
|
8
|
+
import { CashSolid, PencilSquareSolid, Trash, ChevronDownMini, Check, ArrowPath, InformationCircle, ChevronRightMini, MagnifierAlert, ExclamationCircle, Receipt, CreditCard, ArrowLeft, ClockSolid, SquareTwoStack, ShieldCheck, CheckCircle } from "@medusajs/icons";
|
|
9
|
+
import { useNavigate, useLocation, useSearchParams, useParams } from "react-router-dom";
|
|
7
10
|
function roundRectPath(ctx, x, y, w, h, r) {
|
|
8
11
|
ctx.beginPath();
|
|
9
12
|
ctx.moveTo(x + r, y);
|
|
@@ -374,14 +377,15 @@ const s = {
|
|
|
374
377
|
const OrderGiftItemsWidget = ({ data }) => {
|
|
375
378
|
const [fetchedItems, setFetchedItems] = useState(null);
|
|
376
379
|
useEffect(() => {
|
|
377
|
-
if (!data
|
|
380
|
+
if (!(data == null ? void 0 : data.id)) return;
|
|
378
381
|
fetch(
|
|
379
382
|
`/admin/orders/${data.id}?fields=*items,items.metadata`
|
|
380
|
-
).then((r) => r.json()).then(({ order }) => setFetchedItems(order
|
|
381
|
-
}, [data
|
|
382
|
-
const items = fetchedItems ?? data
|
|
383
|
+
).then((r) => r.json()).then(({ order }) => setFetchedItems((order == null ? void 0 : order.items) ?? [])).catch(() => setFetchedItems((data == null ? void 0 : data.items) ?? []));
|
|
384
|
+
}, [data == null ? void 0 : data.id]);
|
|
385
|
+
const items = fetchedItems ?? (data == null ? void 0 : data.items) ?? [];
|
|
383
386
|
const giftedItems = items.filter((i) => {
|
|
384
|
-
|
|
387
|
+
var _a;
|
|
388
|
+
const flag = (_a = i.metadata) == null ? void 0 : _a.is_gift;
|
|
385
389
|
return flag === "true" || flag === true;
|
|
386
390
|
});
|
|
387
391
|
return /* @__PURE__ */ jsxs("div", { style: s.widget, children: [
|
|
@@ -410,9 +414,9 @@ const OrderGiftItemsWidget = ({ data }) => {
|
|
|
410
414
|
),
|
|
411
415
|
giftedItems.map((item) => {
|
|
412
416
|
const meta = item.metadata;
|
|
413
|
-
const from = meta
|
|
414
|
-
const to = meta
|
|
415
|
-
const message = meta
|
|
417
|
+
const from = meta == null ? void 0 : meta.gift_from;
|
|
418
|
+
const to = meta == null ? void 0 : meta.gift_to;
|
|
419
|
+
const message = meta == null ? void 0 : meta.gift_message;
|
|
416
420
|
return /* @__PURE__ */ jsxs("div", { style: s.card, children: [
|
|
417
421
|
/* @__PURE__ */ jsxs("div", { style: s.ribbon, children: [
|
|
418
422
|
/* @__PURE__ */ jsx("span", { style: s.bowCenter, children: "🎀" }),
|
|
@@ -476,7 +480,7 @@ function formatRefundCurrency(amount, currencyCode = "inr", options) {
|
|
|
476
480
|
minimumFractionDigits: 2,
|
|
477
481
|
maximumFractionDigits: 2
|
|
478
482
|
}).format(amount);
|
|
479
|
-
if (options
|
|
483
|
+
if ((options == null ? void 0 : options.signed) && amount > 0) {
|
|
480
484
|
return `−${formatted}`;
|
|
481
485
|
}
|
|
482
486
|
return formatted;
|
|
@@ -531,7 +535,8 @@ function getOrderIdFromPath() {
|
|
|
531
535
|
return m ? m[1] : void 0;
|
|
532
536
|
}
|
|
533
537
|
const OrderRefundContextWidget = (props) => {
|
|
534
|
-
|
|
538
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
539
|
+
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
540
|
const [context, setContext] = useState(null);
|
|
536
541
|
const [loading, setLoading] = useState(!!orderId);
|
|
537
542
|
const [error, setError] = useState(null);
|
|
@@ -569,7 +574,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
569
574
|
};
|
|
570
575
|
}, [orderId]);
|
|
571
576
|
const handleMarkRefunded = async () => {
|
|
572
|
-
if (!context
|
|
577
|
+
if (!(context == null ? void 0 : context.return_id) || !(context == null ? void 0 : context.refund_mapping) || context.refund_mapping.is_refunded || !context.can_process_refund) {
|
|
573
578
|
return;
|
|
574
579
|
}
|
|
575
580
|
setMarking(true);
|
|
@@ -586,14 +591,17 @@ const OrderRefundContextWidget = (props) => {
|
|
|
586
591
|
}
|
|
587
592
|
const data = await res.json();
|
|
588
593
|
setContext(
|
|
589
|
-
(prev) =>
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
594
|
+
(prev) => {
|
|
595
|
+
var _a2;
|
|
596
|
+
return prev && prev.refund_mapping ? {
|
|
597
|
+
...prev,
|
|
598
|
+
can_process_refund: false,
|
|
599
|
+
refund_mapping: {
|
|
600
|
+
...prev.refund_mapping,
|
|
601
|
+
is_refunded: ((_a2 = data.refund_payment_mapping) == null ? void 0 : _a2.is_refunded) ?? true
|
|
602
|
+
}
|
|
603
|
+
} : prev;
|
|
604
|
+
}
|
|
597
605
|
);
|
|
598
606
|
} catch (e) {
|
|
599
607
|
setMarkError(e instanceof Error ? e.message : "Failed to mark refunded");
|
|
@@ -602,19 +610,20 @@ const OrderRefundContextWidget = (props) => {
|
|
|
602
610
|
}
|
|
603
611
|
};
|
|
604
612
|
const handleEditClick = () => {
|
|
605
|
-
const mapping = context
|
|
606
|
-
const mode = mapping
|
|
613
|
+
const mapping = context == null ? void 0 : context.refund_mapping;
|
|
614
|
+
const mode = mapping == null ? void 0 : mapping.refund_mode;
|
|
607
615
|
setEditRefundMode(
|
|
608
616
|
mode === "offline" || mode === "online" ? mode : ""
|
|
609
617
|
);
|
|
610
|
-
setEditDetails(mapping
|
|
611
|
-
setEditImageUrls(mapping
|
|
618
|
+
setEditDetails((mapping == null ? void 0 : mapping.details) ?? "");
|
|
619
|
+
setEditImageUrls((mapping == null ? void 0 : mapping.images) ?? []);
|
|
612
620
|
setSaveError(null);
|
|
613
621
|
setUploadError(null);
|
|
614
622
|
setEditing(true);
|
|
615
623
|
};
|
|
616
624
|
const handleUploadImage = async (e) => {
|
|
617
|
-
|
|
625
|
+
var _a2, _b2, _c2;
|
|
626
|
+
const file = (_a2 = e.target.files) == null ? void 0 : _a2[0];
|
|
618
627
|
if (!file) return;
|
|
619
628
|
setUploading(true);
|
|
620
629
|
setUploadError(null);
|
|
@@ -631,7 +640,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
631
640
|
throw new Error(data2.message || "Upload failed");
|
|
632
641
|
}
|
|
633
642
|
const data = await res.json();
|
|
634
|
-
const url = data.files
|
|
643
|
+
const url = (_c2 = (_b2 = data.files) == null ? void 0 : _b2[0]) == null ? void 0 : _c2.url;
|
|
635
644
|
if (url) setEditImageUrls((prev) => [...prev, url]);
|
|
636
645
|
} catch (err) {
|
|
637
646
|
setUploadError(err instanceof Error ? err.message : "Upload failed");
|
|
@@ -644,7 +653,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
644
653
|
setEditImageUrls((prev) => prev.filter((_, i) => i !== index));
|
|
645
654
|
};
|
|
646
655
|
const handleSaveAdminFields = async () => {
|
|
647
|
-
if (!context
|
|
656
|
+
if (!(context == null ? void 0 : context.return_id)) return;
|
|
648
657
|
setSaving(true);
|
|
649
658
|
setSaveError(null);
|
|
650
659
|
try {
|
|
@@ -681,14 +690,14 @@ const OrderRefundContextWidget = (props) => {
|
|
|
681
690
|
if (error) {
|
|
682
691
|
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 }) }) });
|
|
683
692
|
}
|
|
684
|
-
const hasReturn = !!context
|
|
685
|
-
const hasMapping = !!context
|
|
686
|
-
const canMarkRefunded = Boolean(context
|
|
687
|
-
const returnStatus = context
|
|
688
|
-
const showReceiveFirstHint = hasReturn && !context
|
|
689
|
-
const paymentDetail = context
|
|
690
|
-
const paymentDetails = context
|
|
691
|
-
const orderPayment = context
|
|
693
|
+
const hasReturn = !!(context == null ? void 0 : context.return_id);
|
|
694
|
+
const hasMapping = !!(context == null ? void 0 : context.refund_mapping);
|
|
695
|
+
const canMarkRefunded = Boolean(context == null ? void 0 : context.can_process_refund);
|
|
696
|
+
const returnStatus = (context == null ? void 0 : context.return_status) ?? null;
|
|
697
|
+
const showReceiveFirstHint = hasReturn && !((_d = context == null ? void 0 : context.refund_mapping) == null ? void 0 : _d.is_refunded) && returnStatus !== "received" && returnStatus !== "canceled";
|
|
698
|
+
const paymentDetail = context == null ? void 0 : context.payment_detail;
|
|
699
|
+
const paymentDetails = (context == null ? void 0 : context.payment_details) && context.payment_details.length > 0 ? context.payment_details : paymentDetail ? [paymentDetail] : [];
|
|
700
|
+
const orderPayment = context == null ? void 0 : context.order_payment;
|
|
692
701
|
return /* @__PURE__ */ jsx(Container, { className: "mt-6 divide-y p-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 py-4", children: [
|
|
693
702
|
/* @__PURE__ */ jsxs(Heading, { level: "h2", className: "flex items-center gap-2", children: [
|
|
694
703
|
/* @__PURE__ */ jsx(CashSolid, { className: "text-ui-fg-subtle" }),
|
|
@@ -700,7 +709,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
700
709
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
701
710
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Return" }),
|
|
702
711
|
/* @__PURE__ */ jsx(Text, { size: "small", children: context.return_id }),
|
|
703
|
-
context.refund_mapping
|
|
712
|
+
((_e = context.refund_mapping) == null ? void 0 : _e.is_refunded) ? /* @__PURE__ */ jsx(Badge, { color: "green", children: "Refunded" }) : /* @__PURE__ */ jsx(Badge, { color: "orange", children: "Not refunded" })
|
|
704
713
|
] }),
|
|
705
714
|
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
715
|
orderPayment && /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
|
|
@@ -714,17 +723,17 @@ const OrderRefundContextWidget = (props) => {
|
|
|
714
723
|
/* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
|
|
715
724
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
716
725
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Payment method (refund destination)" }),
|
|
717
|
-
context.refund_mapping
|
|
726
|
+
((_f = context.refund_mapping) == null ? void 0 : _f.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
|
|
718
727
|
] }),
|
|
719
|
-
context.refund_mapping
|
|
720
|
-
!context.refund_mapping
|
|
721
|
-
!context.refund_mapping
|
|
728
|
+
((_g = context.refund_mapping) == null ? void 0 : _g.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." }) }),
|
|
729
|
+
!((_h = context.refund_mapping) == null ? void 0 : _h.payment_id) && (paymentDetail == null ? void 0 : 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." }) }),
|
|
730
|
+
!((_i = context.refund_mapping) == null ? void 0 : _i.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
731
|
"Refund will go to the original payment method (",
|
|
723
732
|
orderPayment.label,
|
|
724
733
|
")."
|
|
725
734
|
] }) }),
|
|
726
|
-
!context.refund_mapping
|
|
727
|
-
!context.refund_mapping
|
|
735
|
+
!((_j = context.refund_mapping) == null ? void 0 : _j.payment_id) && !paymentDetail && (context.is_cod || (orderPayment == null ? void 0 : 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." }) }),
|
|
736
|
+
!((_k = context.refund_mapping) == null ? void 0 : _k.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
737
|
paymentDetails.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-3", children: paymentDetails.map((detail) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
729
738
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
730
739
|
/* @__PURE__ */ jsx(Badge, { children: detail.type.toUpperCase() }),
|
|
@@ -736,7 +745,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
736
745
|
] }, `${detail.id}-${k}`)) })
|
|
737
746
|
] }, detail.id)) })
|
|
738
747
|
] }),
|
|
739
|
-
context
|
|
748
|
+
(context == null ? void 0 : context.refund_mapping) && /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-3 border-t border-ui-border-base pt-3", children: [
|
|
740
749
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
741
750
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Refund mode, details & images" }),
|
|
742
751
|
!editing ? /* @__PURE__ */ jsxs(
|
|
@@ -824,7 +833,10 @@ const OrderRefundContextWidget = (props) => {
|
|
|
824
833
|
variant: "secondary",
|
|
825
834
|
type: "button",
|
|
826
835
|
disabled: uploading,
|
|
827
|
-
onClick: () =>
|
|
836
|
+
onClick: () => {
|
|
837
|
+
var _a2;
|
|
838
|
+
return (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
839
|
+
},
|
|
828
840
|
children: uploading ? "Uploading…" : "Upload image"
|
|
829
841
|
}
|
|
830
842
|
),
|
|
@@ -875,7 +887,7 @@ const OrderRefundContextWidget = (props) => {
|
|
|
875
887
|
] }),
|
|
876
888
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
877
889
|
/* @__PURE__ */ jsx(Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: "Images" }),
|
|
878
|
-
context.refund_mapping.images
|
|
890
|
+
((_l = context.refund_mapping.images) == null ? void 0 : _l.length) ? /* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-wrap gap-2", children: context.refund_mapping.images.map((url, i) => /* @__PURE__ */ jsxs(
|
|
879
891
|
"a",
|
|
880
892
|
{
|
|
881
893
|
href: url,
|
|
@@ -905,10 +917,10 @@ const OrderRefundContextWidget = (props) => {
|
|
|
905
917
|
),
|
|
906
918
|
markError && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-error", children: markError })
|
|
907
919
|
] }),
|
|
908
|
-
hasMapping && !canMarkRefunded && !context.refund_mapping
|
|
920
|
+
hasMapping && !canMarkRefunded && !((_m = context.refund_mapping) == null ? void 0 : _m.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." })
|
|
909
921
|
] }),
|
|
910
922
|
hasReturn && !hasMapping && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: [
|
|
911
|
-
context
|
|
923
|
+
(context == null ? void 0 : context.refund) ? /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: context.refund }) : null,
|
|
912
924
|
orderPayment && /* @__PURE__ */ jsxs("div", { className: "mb-3 space-y-1", children: [
|
|
913
925
|
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Order payment method" }),
|
|
914
926
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
@@ -923,6 +935,1301 @@ const OrderRefundContextWidget = (props) => {
|
|
|
923
935
|
defineWidgetConfig({
|
|
924
936
|
zone: "order.details.after"
|
|
925
937
|
});
|
|
938
|
+
const AUDITED_TABLE_NAMES = [
|
|
939
|
+
"account_deletion_request",
|
|
940
|
+
"account_holder",
|
|
941
|
+
"api_key",
|
|
942
|
+
"application_method_buy_rules",
|
|
943
|
+
"application_method_target_rules",
|
|
944
|
+
"auth_identity",
|
|
945
|
+
"auth_mfa_factor",
|
|
946
|
+
"auth_mfa_recovery_code",
|
|
947
|
+
"auth_password_reset_token",
|
|
948
|
+
"auth_verification",
|
|
949
|
+
"cancel_order_reason_mapping",
|
|
950
|
+
"capture",
|
|
951
|
+
"cart",
|
|
952
|
+
"cart_address",
|
|
953
|
+
"cart_line_item",
|
|
954
|
+
"cart_line_item_adjustment",
|
|
955
|
+
"cart_line_item_tax_line",
|
|
956
|
+
"cart_payment_collection",
|
|
957
|
+
"cart_promotion",
|
|
958
|
+
"cart_shipping_method",
|
|
959
|
+
"cart_shipping_method_adjustment",
|
|
960
|
+
"cart_shipping_method_tax_line",
|
|
961
|
+
"contact_email_subscription",
|
|
962
|
+
"contact_request",
|
|
963
|
+
"contact_request_comment",
|
|
964
|
+
"credit_line",
|
|
965
|
+
"currency",
|
|
966
|
+
"customer",
|
|
967
|
+
"customer_account_holder",
|
|
968
|
+
"customer_address",
|
|
969
|
+
"customer_group",
|
|
970
|
+
"customer_group_customer",
|
|
971
|
+
"dynamic_config_value",
|
|
972
|
+
"fulfillment",
|
|
973
|
+
"fulfillment_address",
|
|
974
|
+
"fulfillment_item",
|
|
975
|
+
"fulfillment_label",
|
|
976
|
+
"fulfillment_provider",
|
|
977
|
+
"fulfillment_set",
|
|
978
|
+
"geo_zone",
|
|
979
|
+
"image",
|
|
980
|
+
"inventory_count_item",
|
|
981
|
+
"inventory_count_session",
|
|
982
|
+
"inventory_item",
|
|
983
|
+
"inventory_level",
|
|
984
|
+
"inventory_movement",
|
|
985
|
+
"inventory_purchase",
|
|
986
|
+
"inventory_purchase_attachment",
|
|
987
|
+
"inventory_purchase_audit_event",
|
|
988
|
+
"inventory_purchase_batch",
|
|
989
|
+
"inventory_purchase_line_item",
|
|
990
|
+
"invite",
|
|
991
|
+
"invite_rbac_role",
|
|
992
|
+
"invoice",
|
|
993
|
+
"invoice_sequence",
|
|
994
|
+
"layout_configuration",
|
|
995
|
+
"link_module_migrations",
|
|
996
|
+
"location_fulfillment_provider",
|
|
997
|
+
"location_fulfillment_set",
|
|
998
|
+
"loyalty_gift_card",
|
|
999
|
+
"mikro_orm_migrations",
|
|
1000
|
+
"notification",
|
|
1001
|
+
"notification_provider",
|
|
1002
|
+
"notification_tokens",
|
|
1003
|
+
"order",
|
|
1004
|
+
"order_address",
|
|
1005
|
+
"order_cart",
|
|
1006
|
+
"order_change",
|
|
1007
|
+
"order_change_action",
|
|
1008
|
+
"order_claim",
|
|
1009
|
+
"order_claim_item",
|
|
1010
|
+
"order_claim_item_image",
|
|
1011
|
+
"order_credit_line",
|
|
1012
|
+
"order_exchange",
|
|
1013
|
+
"order_exchange_item",
|
|
1014
|
+
"order_fulfillment",
|
|
1015
|
+
"order_item",
|
|
1016
|
+
"order_line_item",
|
|
1017
|
+
"order_line_item_adjustment",
|
|
1018
|
+
"order_line_item_tax_line",
|
|
1019
|
+
"order_payment_collection",
|
|
1020
|
+
"order_promotion",
|
|
1021
|
+
"order_shipping",
|
|
1022
|
+
"order_shipping_method",
|
|
1023
|
+
"order_shipping_method_adjustment",
|
|
1024
|
+
"order_shipping_method_tax_line",
|
|
1025
|
+
"order_summary",
|
|
1026
|
+
"order_transaction",
|
|
1027
|
+
"otp_verification",
|
|
1028
|
+
"payment",
|
|
1029
|
+
"payment_collection",
|
|
1030
|
+
"payment_collection_payment_providers",
|
|
1031
|
+
"payment_detail",
|
|
1032
|
+
"payment_provider",
|
|
1033
|
+
"payment_session",
|
|
1034
|
+
"payout_request",
|
|
1035
|
+
"price",
|
|
1036
|
+
"price_list",
|
|
1037
|
+
"price_list_rule",
|
|
1038
|
+
"price_preference",
|
|
1039
|
+
"price_rule",
|
|
1040
|
+
"price_set",
|
|
1041
|
+
"product",
|
|
1042
|
+
"product_category",
|
|
1043
|
+
"product_category_product",
|
|
1044
|
+
"product_collection",
|
|
1045
|
+
"product_display_priority",
|
|
1046
|
+
"product_option",
|
|
1047
|
+
"product_option_value",
|
|
1048
|
+
"product_product_option",
|
|
1049
|
+
"product_product_option_value",
|
|
1050
|
+
"product_sales_channel",
|
|
1051
|
+
"product_shipping_profile",
|
|
1052
|
+
"product_tag",
|
|
1053
|
+
"product_tags",
|
|
1054
|
+
"product_type",
|
|
1055
|
+
"product_variant",
|
|
1056
|
+
"product_variant_inventory_item",
|
|
1057
|
+
"product_variant_option",
|
|
1058
|
+
"product_variant_price_set",
|
|
1059
|
+
"product_variant_product_image",
|
|
1060
|
+
"product_view",
|
|
1061
|
+
"promotion",
|
|
1062
|
+
"promotion_application_method",
|
|
1063
|
+
"promotion_campaign",
|
|
1064
|
+
"promotion_campaign_budget",
|
|
1065
|
+
"promotion_campaign_budget_usage",
|
|
1066
|
+
"promotion_promotion_rule",
|
|
1067
|
+
"promotion_rule",
|
|
1068
|
+
"promotion_rule_value",
|
|
1069
|
+
"property_label",
|
|
1070
|
+
"provider_identity",
|
|
1071
|
+
"publishable_api_key_sales_channel",
|
|
1072
|
+
"purchase_supplier",
|
|
1073
|
+
"referral_link",
|
|
1074
|
+
"referral_reward",
|
|
1075
|
+
"refund",
|
|
1076
|
+
"refund_payment_mapping",
|
|
1077
|
+
"refund_reason",
|
|
1078
|
+
"region",
|
|
1079
|
+
"region_country",
|
|
1080
|
+
"region_payment_provider",
|
|
1081
|
+
"reservation_item",
|
|
1082
|
+
"return",
|
|
1083
|
+
"return_fulfillment",
|
|
1084
|
+
"return_item",
|
|
1085
|
+
"return_reason",
|
|
1086
|
+
"review",
|
|
1087
|
+
"sales_channel",
|
|
1088
|
+
"sales_channel_stock_location",
|
|
1089
|
+
"script_migrations",
|
|
1090
|
+
"search_index",
|
|
1091
|
+
"search_index_sync",
|
|
1092
|
+
"search_index_version",
|
|
1093
|
+
"search_postgres_index",
|
|
1094
|
+
"service_zone",
|
|
1095
|
+
"shipment_tracking_event",
|
|
1096
|
+
"shipping_option",
|
|
1097
|
+
"shipping_option_price_set",
|
|
1098
|
+
"shipping_option_rule",
|
|
1099
|
+
"shipping_option_type",
|
|
1100
|
+
"shipping_profile",
|
|
1101
|
+
"skip_merge_cart",
|
|
1102
|
+
"stock_location",
|
|
1103
|
+
"stock_location_address",
|
|
1104
|
+
"store",
|
|
1105
|
+
"store_credit_account",
|
|
1106
|
+
"store_credit_account_transaction",
|
|
1107
|
+
"store_currency",
|
|
1108
|
+
"store_locale",
|
|
1109
|
+
"tax_provider",
|
|
1110
|
+
"tax_rate",
|
|
1111
|
+
"tax_rate_rule",
|
|
1112
|
+
"tax_region",
|
|
1113
|
+
"telegram_config",
|
|
1114
|
+
"telegram_notification_log",
|
|
1115
|
+
"user",
|
|
1116
|
+
"user_preference",
|
|
1117
|
+
"user_rbac_role",
|
|
1118
|
+
"view_configuration",
|
|
1119
|
+
"wallet_account",
|
|
1120
|
+
"wallet_credit_lot",
|
|
1121
|
+
"wallet_gift_card",
|
|
1122
|
+
"wallet_hold",
|
|
1123
|
+
"wallet_ledger_entry",
|
|
1124
|
+
"wallet_rate_limit",
|
|
1125
|
+
"wallet_refund_intent",
|
|
1126
|
+
"wallet_top_up_request",
|
|
1127
|
+
"wishlist",
|
|
1128
|
+
"workflow_execution"
|
|
1129
|
+
];
|
|
1130
|
+
const ENTITY_CATEGORIES = [
|
|
1131
|
+
{ id: "orders", label: "Orders", description: "Orders, items, returns, exchanges and claims" },
|
|
1132
|
+
{ id: "carts", label: "Carts", description: "Shopping carts and checkout data" },
|
|
1133
|
+
{ id: "customers", label: "Customers", description: "Customers, addresses and groups" },
|
|
1134
|
+
{ id: "catalog", label: "Catalog", description: "Products, variants, categories and collections" },
|
|
1135
|
+
{ id: "pricing", label: "Pricing & Promotions", description: "Prices, price lists and promotions" },
|
|
1136
|
+
{ id: "payments", label: "Payments & Refunds", description: "Payments, sessions, captures and refunds" },
|
|
1137
|
+
{ id: "fulfillment", label: "Fulfillment & Shipping", description: "Fulfillments, shipping options and tracking" },
|
|
1138
|
+
{ id: "inventory", label: "Inventory & Purchasing", description: "Stock, locations, reservations and purchases" },
|
|
1139
|
+
{ id: "wallet", label: "Wallet & Credits", description: "Wallets, store credit and gift cards" },
|
|
1140
|
+
{ id: "access", label: "Users & Access", description: "Admin users, logins, roles and API keys" },
|
|
1141
|
+
{ id: "store", label: "Store & Regions", description: "Store, regions, currencies, taxes and sales channels" },
|
|
1142
|
+
{ id: "engagement", label: "Engagement", description: "Reviews, wishlists, referrals and contact requests" },
|
|
1143
|
+
{ id: "notifications", label: "Notifications", description: "Notifications and messaging" },
|
|
1144
|
+
{ id: "system", label: "System & Configuration", description: "Settings, search, workflows and migrations" }
|
|
1145
|
+
];
|
|
1146
|
+
const ENTITY_DEFINITIONS = {
|
|
1147
|
+
// Orders
|
|
1148
|
+
order: { label: "Order", category: "orders" },
|
|
1149
|
+
order_address: { label: "Order Address", category: "orders" },
|
|
1150
|
+
order_cart: { label: "Order–Cart Link", category: "orders" },
|
|
1151
|
+
order_change: { label: "Order Change", category: "orders" },
|
|
1152
|
+
order_change_action: { label: "Order Change Action", category: "orders" },
|
|
1153
|
+
order_claim: { label: "Claim", category: "orders" },
|
|
1154
|
+
order_claim_item: { label: "Claim Item", category: "orders" },
|
|
1155
|
+
order_claim_item_image: { label: "Claim Item Image", category: "orders" },
|
|
1156
|
+
order_credit_line: { label: "Order Credit Line", category: "orders" },
|
|
1157
|
+
order_exchange: { label: "Exchange", category: "orders" },
|
|
1158
|
+
order_exchange_item: { label: "Exchange Item", category: "orders" },
|
|
1159
|
+
order_fulfillment: { label: "Order–Fulfillment Link", category: "orders" },
|
|
1160
|
+
order_item: { label: "Order Item Quantity", category: "orders" },
|
|
1161
|
+
order_line_item: { label: "Order Item", category: "orders" },
|
|
1162
|
+
order_line_item_adjustment: { label: "Order Item Discount", category: "orders" },
|
|
1163
|
+
order_line_item_tax_line: { label: "Order Item Tax", category: "orders" },
|
|
1164
|
+
order_payment_collection: { label: "Order–Payment Link", category: "orders" },
|
|
1165
|
+
order_promotion: { label: "Order Promotion", category: "orders" },
|
|
1166
|
+
order_shipping: { label: "Order Shipping", category: "orders" },
|
|
1167
|
+
order_shipping_method: { label: "Order Shipping Method", category: "orders" },
|
|
1168
|
+
order_shipping_method_adjustment: { label: "Order Shipping Discount", category: "orders" },
|
|
1169
|
+
order_shipping_method_tax_line: { label: "Order Shipping Tax", category: "orders" },
|
|
1170
|
+
order_summary: { label: "Order Summary", category: "orders" },
|
|
1171
|
+
order_transaction: { label: "Order Transaction", category: "orders" },
|
|
1172
|
+
return: { label: "Return", category: "orders" },
|
|
1173
|
+
return_fulfillment: { label: "Return–Fulfillment Link", category: "orders" },
|
|
1174
|
+
return_item: { label: "Return Item", category: "orders" },
|
|
1175
|
+
return_reason: { label: "Return Reason", category: "orders" },
|
|
1176
|
+
cancel_order_reason_mapping: { label: "Order Cancellation Reason", category: "orders" },
|
|
1177
|
+
credit_line: { label: "Credit Line", category: "orders" },
|
|
1178
|
+
invoice: { label: "Invoice", category: "orders" },
|
|
1179
|
+
invoice_sequence: { label: "Invoice Number Sequence", category: "orders" },
|
|
1180
|
+
// Carts
|
|
1181
|
+
cart: { label: "Cart", category: "carts" },
|
|
1182
|
+
cart_address: { label: "Cart Address", category: "carts" },
|
|
1183
|
+
cart_line_item: { label: "Cart Item", category: "carts" },
|
|
1184
|
+
cart_line_item_adjustment: { label: "Cart Item Discount", category: "carts" },
|
|
1185
|
+
cart_line_item_tax_line: { label: "Cart Item Tax", category: "carts" },
|
|
1186
|
+
cart_payment_collection: { label: "Cart–Payment Link", category: "carts" },
|
|
1187
|
+
cart_promotion: { label: "Cart Promotion", category: "carts" },
|
|
1188
|
+
cart_shipping_method: { label: "Cart Shipping Method", category: "carts" },
|
|
1189
|
+
cart_shipping_method_adjustment: { label: "Cart Shipping Discount", category: "carts" },
|
|
1190
|
+
cart_shipping_method_tax_line: { label: "Cart Shipping Tax", category: "carts" },
|
|
1191
|
+
skip_merge_cart: { label: "Cart Merge Exclusion", category: "carts" },
|
|
1192
|
+
// Customers
|
|
1193
|
+
customer: { label: "Customer", category: "customers" },
|
|
1194
|
+
customer_address: { label: "Customer Address", category: "customers" },
|
|
1195
|
+
customer_group: { label: "Customer Group", category: "customers" },
|
|
1196
|
+
customer_group_customer: { label: "Customer Group Member", category: "customers" },
|
|
1197
|
+
customer_account_holder: { label: "Customer–Account Holder Link", category: "customers" },
|
|
1198
|
+
account_holder: { label: "Payment Account Holder", category: "customers" },
|
|
1199
|
+
account_deletion_request: { label: "Account Deletion Request", category: "customers" },
|
|
1200
|
+
payment_detail: { label: "Customer Refund Method", category: "customers" },
|
|
1201
|
+
otp_verification: { label: "OTP Verification", category: "customers" },
|
|
1202
|
+
// Catalog
|
|
1203
|
+
product: { label: "Product", category: "catalog" },
|
|
1204
|
+
product_variant: { label: "Product Variant", category: "catalog" },
|
|
1205
|
+
product_category: { label: "Product Category", category: "catalog" },
|
|
1206
|
+
product_category_product: { label: "Product–Category Link", category: "catalog" },
|
|
1207
|
+
product_collection: { label: "Collection", category: "catalog" },
|
|
1208
|
+
product_option: { label: "Product Option", category: "catalog" },
|
|
1209
|
+
product_option_value: { label: "Product Option Value", category: "catalog" },
|
|
1210
|
+
product_product_option: { label: "Product–Option Link", category: "catalog" },
|
|
1211
|
+
product_product_option_value: { label: "Product–Option Value Link", category: "catalog" },
|
|
1212
|
+
product_tag: { label: "Product Tag", category: "catalog" },
|
|
1213
|
+
product_tags: { label: "Product–Tag Link", category: "catalog" },
|
|
1214
|
+
product_type: { label: "Product Type", category: "catalog" },
|
|
1215
|
+
product_sales_channel: { label: "Product–Sales Channel Link", category: "catalog" },
|
|
1216
|
+
product_shipping_profile: { label: "Product–Shipping Profile Link", category: "catalog" },
|
|
1217
|
+
product_variant_inventory_item: { label: "Variant–Inventory Link", category: "catalog" },
|
|
1218
|
+
product_variant_option: { label: "Variant Option", category: "catalog" },
|
|
1219
|
+
product_variant_price_set: { label: "Variant–Price Link", category: "catalog" },
|
|
1220
|
+
product_variant_product_image: { label: "Variant Image", category: "catalog" },
|
|
1221
|
+
product_display_priority: { label: "Product Display Priority", category: "catalog" },
|
|
1222
|
+
product_view: { label: "Product View", category: "catalog" },
|
|
1223
|
+
image: { label: "Product Image", category: "catalog" },
|
|
1224
|
+
property_label: { label: "Property Label", category: "catalog" },
|
|
1225
|
+
// Pricing & promotions
|
|
1226
|
+
price: { label: "Price", category: "pricing" },
|
|
1227
|
+
price_list: { label: "Price List", category: "pricing" },
|
|
1228
|
+
price_list_rule: { label: "Price List Rule", category: "pricing" },
|
|
1229
|
+
price_preference: { label: "Price Preference", category: "pricing" },
|
|
1230
|
+
price_rule: { label: "Price Rule", category: "pricing" },
|
|
1231
|
+
price_set: { label: "Price Set", category: "pricing" },
|
|
1232
|
+
promotion: { label: "Promotion", category: "pricing" },
|
|
1233
|
+
promotion_application_method: { label: "Promotion Application Method", category: "pricing" },
|
|
1234
|
+
promotion_campaign: { label: "Campaign", category: "pricing" },
|
|
1235
|
+
promotion_campaign_budget: { label: "Campaign Budget", category: "pricing" },
|
|
1236
|
+
promotion_campaign_budget_usage: { label: "Campaign Budget Usage", category: "pricing" },
|
|
1237
|
+
promotion_promotion_rule: { label: "Promotion–Rule Link", category: "pricing" },
|
|
1238
|
+
promotion_rule: { label: "Promotion Rule", category: "pricing" },
|
|
1239
|
+
promotion_rule_value: { label: "Promotion Rule Value", category: "pricing" },
|
|
1240
|
+
application_method_buy_rules: { label: "Promotion Buy Rule", category: "pricing" },
|
|
1241
|
+
application_method_target_rules: { label: "Promotion Target Rule", category: "pricing" },
|
|
1242
|
+
// Payments
|
|
1243
|
+
payment: { label: "Payment", category: "payments" },
|
|
1244
|
+
payment_collection: { label: "Payment Collection", category: "payments" },
|
|
1245
|
+
payment_collection_payment_providers: { label: "Payment Collection–Provider Link", category: "payments" },
|
|
1246
|
+
payment_provider: { label: "Payment Provider", category: "payments" },
|
|
1247
|
+
payment_session: { label: "Payment Session", category: "payments" },
|
|
1248
|
+
capture: { label: "Payment Capture", category: "payments" },
|
|
1249
|
+
refund: { label: "Refund", category: "payments" },
|
|
1250
|
+
refund_reason: { label: "Refund Reason", category: "payments" },
|
|
1251
|
+
refund_payment_mapping: { label: "Return Refund Mapping", category: "payments" },
|
|
1252
|
+
payout_request: { label: "Payout Request", category: "payments" },
|
|
1253
|
+
// Fulfillment
|
|
1254
|
+
fulfillment: { label: "Fulfillment", category: "fulfillment" },
|
|
1255
|
+
fulfillment_address: { label: "Fulfillment Address", category: "fulfillment" },
|
|
1256
|
+
fulfillment_item: { label: "Fulfillment Item", category: "fulfillment" },
|
|
1257
|
+
fulfillment_label: { label: "Shipping Label", category: "fulfillment" },
|
|
1258
|
+
fulfillment_provider: { label: "Fulfillment Provider", category: "fulfillment" },
|
|
1259
|
+
fulfillment_set: { label: "Fulfillment Set", category: "fulfillment" },
|
|
1260
|
+
geo_zone: { label: "Geo Zone", category: "fulfillment" },
|
|
1261
|
+
service_zone: { label: "Service Zone", category: "fulfillment" },
|
|
1262
|
+
shipping_option: { label: "Shipping Option", category: "fulfillment" },
|
|
1263
|
+
shipping_option_price_set: { label: "Shipping Option–Price Link", category: "fulfillment" },
|
|
1264
|
+
shipping_option_rule: { label: "Shipping Option Rule", category: "fulfillment" },
|
|
1265
|
+
shipping_option_type: { label: "Shipping Option Type", category: "fulfillment" },
|
|
1266
|
+
shipping_profile: { label: "Shipping Profile", category: "fulfillment" },
|
|
1267
|
+
shipment_tracking_event: { label: "Shipment Tracking Event", category: "fulfillment" },
|
|
1268
|
+
location_fulfillment_provider: { label: "Location–Fulfillment Provider Link", category: "fulfillment" },
|
|
1269
|
+
location_fulfillment_set: { label: "Location–Fulfillment Set Link", category: "fulfillment" },
|
|
1270
|
+
// Inventory
|
|
1271
|
+
inventory_item: { label: "Inventory Item", category: "inventory" },
|
|
1272
|
+
inventory_level: { label: "Inventory Level", category: "inventory" },
|
|
1273
|
+
inventory_movement: { label: "Inventory Movement", category: "inventory" },
|
|
1274
|
+
inventory_count_item: { label: "Stock Count Item", category: "inventory" },
|
|
1275
|
+
inventory_count_session: { label: "Stock Count Session", category: "inventory" },
|
|
1276
|
+
inventory_purchase: { label: "Purchase", category: "inventory" },
|
|
1277
|
+
inventory_purchase_attachment: { label: "Purchase Attachment", category: "inventory" },
|
|
1278
|
+
inventory_purchase_audit_event: { label: "Purchase Audit Event", category: "inventory" },
|
|
1279
|
+
inventory_purchase_batch: { label: "Purchase Batch", category: "inventory" },
|
|
1280
|
+
inventory_purchase_line_item: { label: "Purchase Item", category: "inventory" },
|
|
1281
|
+
purchase_supplier: { label: "Supplier", category: "inventory" },
|
|
1282
|
+
reservation_item: { label: "Stock Reservation", category: "inventory" },
|
|
1283
|
+
stock_location: { label: "Stock Location", category: "inventory" },
|
|
1284
|
+
stock_location_address: { label: "Stock Location Address", category: "inventory" },
|
|
1285
|
+
sales_channel_stock_location: { label: "Sales Channel–Location Link", category: "inventory" },
|
|
1286
|
+
// Wallet
|
|
1287
|
+
wallet_account: { label: "Wallet Account", category: "wallet" },
|
|
1288
|
+
wallet_credit_lot: { label: "Wallet Credit Lot", category: "wallet" },
|
|
1289
|
+
wallet_gift_card: { label: "Wallet Gift Card", category: "wallet" },
|
|
1290
|
+
wallet_hold: { label: "Wallet Hold", category: "wallet" },
|
|
1291
|
+
wallet_ledger_entry: { label: "Wallet Ledger Entry", category: "wallet" },
|
|
1292
|
+
wallet_rate_limit: { label: "Wallet Rate Limit", category: "wallet" },
|
|
1293
|
+
wallet_refund_intent: { label: "Wallet Refund", category: "wallet" },
|
|
1294
|
+
wallet_top_up_request: { label: "Wallet Top-up Request", category: "wallet" },
|
|
1295
|
+
store_credit_account: { label: "Store Credit Account", category: "wallet" },
|
|
1296
|
+
store_credit_account_transaction: { label: "Store Credit Transaction", category: "wallet" },
|
|
1297
|
+
loyalty_gift_card: { label: "Loyalty Gift Card", category: "wallet" },
|
|
1298
|
+
// Users & access
|
|
1299
|
+
user: { label: "Admin User", category: "access" },
|
|
1300
|
+
user_preference: { label: "User Preference", category: "access" },
|
|
1301
|
+
user_rbac_role: { label: "User Role", category: "access" },
|
|
1302
|
+
invite: { label: "Admin Invite", category: "access" },
|
|
1303
|
+
invite_rbac_role: { label: "Invite Role", category: "access" },
|
|
1304
|
+
api_key: { label: "API Key", category: "access" },
|
|
1305
|
+
publishable_api_key_sales_channel: { label: "API Key–Sales Channel Link", category: "access" },
|
|
1306
|
+
auth_identity: { label: "Login Identity", category: "access" },
|
|
1307
|
+
auth_mfa_factor: { label: "MFA Factor", category: "access" },
|
|
1308
|
+
auth_mfa_recovery_code: { label: "MFA Recovery Code", category: "access" },
|
|
1309
|
+
auth_password_reset_token: { label: "Password Reset Token", category: "access" },
|
|
1310
|
+
auth_verification: { label: "Auth Verification", category: "access" },
|
|
1311
|
+
provider_identity: { label: "Login Provider Identity", category: "access" },
|
|
1312
|
+
// Store & regions
|
|
1313
|
+
store: { label: "Store", category: "store" },
|
|
1314
|
+
store_currency: { label: "Store Currency", category: "store" },
|
|
1315
|
+
store_locale: { label: "Store Locale", category: "store" },
|
|
1316
|
+
currency: { label: "Currency", category: "store" },
|
|
1317
|
+
region: { label: "Region", category: "store" },
|
|
1318
|
+
region_country: { label: "Region Country", category: "store" },
|
|
1319
|
+
region_payment_provider: { label: "Region–Payment Provider Link", category: "store" },
|
|
1320
|
+
sales_channel: { label: "Sales Channel", category: "store" },
|
|
1321
|
+
tax_provider: { label: "Tax Provider", category: "store" },
|
|
1322
|
+
tax_rate: { label: "Tax Rate", category: "store" },
|
|
1323
|
+
tax_rate_rule: { label: "Tax Rate Rule", category: "store" },
|
|
1324
|
+
tax_region: { label: "Tax Region", category: "store" },
|
|
1325
|
+
// Engagement
|
|
1326
|
+
review: { label: "Review", category: "engagement" },
|
|
1327
|
+
wishlist: { label: "Wishlist", category: "engagement" },
|
|
1328
|
+
referral_link: { label: "Referral Link", category: "engagement" },
|
|
1329
|
+
referral_reward: { label: "Referral Reward", category: "engagement" },
|
|
1330
|
+
contact_request: { label: "Contact Request", category: "engagement" },
|
|
1331
|
+
contact_request_comment: { label: "Contact Request Comment", category: "engagement" },
|
|
1332
|
+
contact_email_subscription: { label: "Email Subscription", category: "engagement" },
|
|
1333
|
+
// Notifications
|
|
1334
|
+
notification: { label: "Notification", category: "notifications" },
|
|
1335
|
+
notification_provider: { label: "Notification Provider", category: "notifications" },
|
|
1336
|
+
notification_tokens: { label: "Push Notification Token", category: "notifications" },
|
|
1337
|
+
telegram_config: { label: "Telegram Settings", category: "notifications" },
|
|
1338
|
+
telegram_notification_log: { label: "Telegram Notification Log", category: "notifications" },
|
|
1339
|
+
// System
|
|
1340
|
+
dynamic_config_value: { label: "Plugin Setting", category: "system" },
|
|
1341
|
+
layout_configuration: { label: "Layout Configuration", category: "system" },
|
|
1342
|
+
view_configuration: { label: "View Configuration", category: "system" },
|
|
1343
|
+
workflow_execution: { label: "Workflow Execution", category: "system" },
|
|
1344
|
+
search_index: { label: "Search Index", category: "system" },
|
|
1345
|
+
search_index_sync: { label: "Search Index Sync", category: "system" },
|
|
1346
|
+
search_index_version: { label: "Search Index Version", category: "system" },
|
|
1347
|
+
search_postgres_index: { label: "Search Index Entry", category: "system" },
|
|
1348
|
+
link_module_migrations: { label: "Link Migration Record", category: "system" },
|
|
1349
|
+
mikro_orm_migrations: { label: "Database Migration Record", category: "system" },
|
|
1350
|
+
script_migrations: { label: "Script Migration Record", category: "system" }
|
|
1351
|
+
};
|
|
1352
|
+
const CATEGORY_BY_ID = new Map(ENTITY_CATEGORIES.map((c) => [c.id, c]));
|
|
1353
|
+
const SYSTEM_CATEGORY = CATEGORY_BY_ID.get("system");
|
|
1354
|
+
function humanizeTableName(tableName) {
|
|
1355
|
+
return tableName.split("_").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
1356
|
+
}
|
|
1357
|
+
function getEntityInfo(tableName) {
|
|
1358
|
+
const def = ENTITY_DEFINITIONS[tableName];
|
|
1359
|
+
return {
|
|
1360
|
+
tableName,
|
|
1361
|
+
label: (def == null ? void 0 : def.label) ?? humanizeTableName(tableName),
|
|
1362
|
+
category: def && CATEGORY_BY_ID.get(def.category) || SYSTEM_CATEGORY
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function getEntitiesByCategory() {
|
|
1366
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1367
|
+
for (const table of AUDITED_TABLE_NAMES) {
|
|
1368
|
+
const info = getEntityInfo(table);
|
|
1369
|
+
const list = groups.get(info.category.id) ?? [];
|
|
1370
|
+
list.push(info);
|
|
1371
|
+
groups.set(info.category.id, list);
|
|
1372
|
+
}
|
|
1373
|
+
return ENTITY_CATEGORIES.filter((category) => groups.has(category.id)).map((category) => ({
|
|
1374
|
+
category,
|
|
1375
|
+
entities: (groups.get(category.id) ?? []).sort((a, b) => a.label.localeCompare(b.label))
|
|
1376
|
+
}));
|
|
1377
|
+
}
|
|
1378
|
+
function getCategory(id) {
|
|
1379
|
+
return CATEGORY_BY_ID.get(id);
|
|
1380
|
+
}
|
|
1381
|
+
function getTablesForCategory(id) {
|
|
1382
|
+
return AUDITED_TABLE_NAMES.filter((table) => getEntityInfo(table).category.id === id);
|
|
1383
|
+
}
|
|
1384
|
+
const GROUPS = getEntitiesByCategory();
|
|
1385
|
+
function triggerLabel(entity, category) {
|
|
1386
|
+
var _a;
|
|
1387
|
+
if (entity) return getEntityInfo(entity).label;
|
|
1388
|
+
if (category) return `All ${((_a = getCategory(category)) == null ? void 0 : _a.label) ?? category}`;
|
|
1389
|
+
return "All entities";
|
|
1390
|
+
}
|
|
1391
|
+
const EntityPicker = ({ entity, category, onChange }) => {
|
|
1392
|
+
var _a;
|
|
1393
|
+
const [open, setOpen] = useState(false);
|
|
1394
|
+
const [search, setSearch] = useState("");
|
|
1395
|
+
const searchRef = useRef(null);
|
|
1396
|
+
const filteredGroups = useMemo(() => {
|
|
1397
|
+
const term = search.trim().toLowerCase();
|
|
1398
|
+
if (!term) return GROUPS;
|
|
1399
|
+
return GROUPS.map((group) => {
|
|
1400
|
+
const categoryMatches = group.category.label.toLowerCase().includes(term);
|
|
1401
|
+
const entities = categoryMatches ? group.entities : group.entities.filter(
|
|
1402
|
+
(e) => e.label.toLowerCase().includes(term) || e.tableName.includes(term.replace(/\s+/g, "_"))
|
|
1403
|
+
);
|
|
1404
|
+
return { ...group, entities };
|
|
1405
|
+
}).filter((group) => group.entities.length > 0);
|
|
1406
|
+
}, [search]);
|
|
1407
|
+
const select = (next) => {
|
|
1408
|
+
onChange(next);
|
|
1409
|
+
setOpen(false);
|
|
1410
|
+
setSearch("");
|
|
1411
|
+
};
|
|
1412
|
+
const firstMatch = (_a = filteredGroups[0]) == null ? void 0 : _a.entities[0];
|
|
1413
|
+
const isAll = !entity && !category;
|
|
1414
|
+
return /* @__PURE__ */ jsxs(
|
|
1415
|
+
Popover,
|
|
1416
|
+
{
|
|
1417
|
+
open,
|
|
1418
|
+
onOpenChange: (next) => {
|
|
1419
|
+
setOpen(next);
|
|
1420
|
+
if (!next) setSearch("");
|
|
1421
|
+
},
|
|
1422
|
+
children: [
|
|
1423
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1424
|
+
"button",
|
|
1425
|
+
{
|
|
1426
|
+
type: "button",
|
|
1427
|
+
"aria-label": "Filter by entity",
|
|
1428
|
+
className: clx(
|
|
1429
|
+
"txt-compact-small flex h-7 w-full min-w-[200px] items-center justify-between gap-2 rounded-md bg-ui-bg-field px-2 text-left shadow-borders-base outline-none transition-fg",
|
|
1430
|
+
"hover:bg-ui-bg-field-hover focus-visible:shadow-borders-interactive-with-active md:w-auto",
|
|
1431
|
+
isAll ? "text-ui-fg-muted" : "text-ui-fg-base"
|
|
1432
|
+
),
|
|
1433
|
+
children: [
|
|
1434
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: triggerLabel(entity, category) }),
|
|
1435
|
+
/* @__PURE__ */ jsx(ChevronDownMini, { className: "shrink-0 text-ui-fg-muted" })
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
) }),
|
|
1439
|
+
/* @__PURE__ */ jsxs(
|
|
1440
|
+
Popover.Content,
|
|
1441
|
+
{
|
|
1442
|
+
align: "start",
|
|
1443
|
+
className: "w-[min(360px,calc(100vw-2rem))] p-0",
|
|
1444
|
+
onOpenAutoFocus: (event) => {
|
|
1445
|
+
var _a2;
|
|
1446
|
+
event.preventDefault();
|
|
1447
|
+
(_a2 = searchRef.current) == null ? void 0 : _a2.focus();
|
|
1448
|
+
},
|
|
1449
|
+
children: [
|
|
1450
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-ui-border-base p-2", children: /* @__PURE__ */ jsx(
|
|
1451
|
+
Input,
|
|
1452
|
+
{
|
|
1453
|
+
ref: searchRef,
|
|
1454
|
+
size: "small",
|
|
1455
|
+
type: "search",
|
|
1456
|
+
placeholder: "Search entities, e.g. order, wallet…",
|
|
1457
|
+
value: search,
|
|
1458
|
+
onChange: (e) => setSearch(e.target.value),
|
|
1459
|
+
onKeyDown: (e) => {
|
|
1460
|
+
if (e.key === "Enter" && firstMatch) {
|
|
1461
|
+
e.preventDefault();
|
|
1462
|
+
select({ entity: firstMatch.tableName, category: "" });
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
"aria-label": "Search entities"
|
|
1466
|
+
}
|
|
1467
|
+
) }),
|
|
1468
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-[360px] overflow-y-auto p-1", role: "listbox", "aria-label": "Entities", children: [
|
|
1469
|
+
!search.trim() ? /* @__PURE__ */ jsx(PickerOption, { selected: isAll, onSelect: () => select({ entity: "", category: "" }), children: "All entities" }) : null,
|
|
1470
|
+
filteredGroups.length === 0 ? /* @__PURE__ */ jsxs(Text, { size: "small", className: "px-3 py-6 text-center text-ui-fg-muted", children: [
|
|
1471
|
+
"No entities match “",
|
|
1472
|
+
search.trim(),
|
|
1473
|
+
"”"
|
|
1474
|
+
] }) : null,
|
|
1475
|
+
filteredGroups.map((group) => /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
1476
|
+
/* @__PURE__ */ jsx("div", { className: "px-2 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-ui-fg-muted", children: group.category.label }),
|
|
1477
|
+
!search.trim() ? /* @__PURE__ */ jsxs(
|
|
1478
|
+
PickerOption,
|
|
1479
|
+
{
|
|
1480
|
+
selected: !entity && category === group.category.id,
|
|
1481
|
+
onSelect: () => select({ entity: "", category: group.category.id }),
|
|
1482
|
+
secondary: group.category.description,
|
|
1483
|
+
children: [
|
|
1484
|
+
"All ",
|
|
1485
|
+
group.category.label
|
|
1486
|
+
]
|
|
1487
|
+
}
|
|
1488
|
+
) : null,
|
|
1489
|
+
group.entities.map((info) => /* @__PURE__ */ jsx(
|
|
1490
|
+
PickerOption,
|
|
1491
|
+
{
|
|
1492
|
+
selected: entity === info.tableName,
|
|
1493
|
+
onSelect: () => select({ entity: info.tableName, category: "" }),
|
|
1494
|
+
secondary: info.tableName,
|
|
1495
|
+
secondaryMono: true,
|
|
1496
|
+
indent: !search.trim(),
|
|
1497
|
+
children: info.label
|
|
1498
|
+
},
|
|
1499
|
+
info.tableName
|
|
1500
|
+
))
|
|
1501
|
+
] }, group.category.id))
|
|
1502
|
+
] })
|
|
1503
|
+
]
|
|
1504
|
+
}
|
|
1505
|
+
)
|
|
1506
|
+
]
|
|
1507
|
+
}
|
|
1508
|
+
);
|
|
1509
|
+
};
|
|
1510
|
+
const PickerOption = ({ selected, onSelect, children, secondary, secondaryMono, indent }) => /* @__PURE__ */ jsxs(
|
|
1511
|
+
"button",
|
|
1512
|
+
{
|
|
1513
|
+
type: "button",
|
|
1514
|
+
role: "option",
|
|
1515
|
+
"aria-selected": selected,
|
|
1516
|
+
onClick: onSelect,
|
|
1517
|
+
className: clx(
|
|
1518
|
+
"flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left outline-none transition-fg",
|
|
1519
|
+
"hover:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-hover",
|
|
1520
|
+
indent && "pl-4"
|
|
1521
|
+
),
|
|
1522
|
+
children: [
|
|
1523
|
+
/* @__PURE__ */ jsx("span", { className: "mt-0.5 flex size-4 shrink-0 items-center justify-center text-ui-fg-interactive", children: selected ? /* @__PURE__ */ jsx(Check, {}) : null }),
|
|
1524
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
1525
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm text-ui-fg-base", children }),
|
|
1526
|
+
secondary ? /* @__PURE__ */ jsx("span", { className: clx("truncate text-xs text-ui-fg-muted", secondaryMono && "font-mono"), children: secondary }) : null
|
|
1527
|
+
] })
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
);
|
|
1531
|
+
const CopyableId = ({ value, emptyLabel = "No ID", className }) => {
|
|
1532
|
+
if (!value) {
|
|
1533
|
+
return /* @__PURE__ */ jsx(Text, { size: "small", className: "italic text-ui-fg-muted", children: emptyLabel });
|
|
1534
|
+
}
|
|
1535
|
+
return /* @__PURE__ */ jsxs("span", { className: clx("inline-flex min-w-0 max-w-full items-center gap-1", className), children: [
|
|
1536
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-mono text-xs text-ui-fg-base", title: value, children: value }),
|
|
1537
|
+
/* @__PURE__ */ jsx("span", { onClick: (e) => e.stopPropagation(), className: "inline-flex shrink-0", children: /* @__PURE__ */ jsx(Copy, { content: value, variant: "mini", className: "text-ui-fg-muted", "aria-label": `Copy ${value}` }) })
|
|
1538
|
+
] });
|
|
1539
|
+
};
|
|
1540
|
+
const RELATIVE_UNITS = [
|
|
1541
|
+
{ unit: "year", seconds: 60 * 60 * 24 * 365 },
|
|
1542
|
+
{ unit: "month", seconds: 60 * 60 * 24 * 30 },
|
|
1543
|
+
{ unit: "week", seconds: 60 * 60 * 24 * 7 },
|
|
1544
|
+
{ unit: "day", seconds: 60 * 60 * 24 },
|
|
1545
|
+
{ unit: "hour", seconds: 60 * 60 },
|
|
1546
|
+
{ unit: "minute", seconds: 60 }
|
|
1547
|
+
];
|
|
1548
|
+
function toDate(value) {
|
|
1549
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
1550
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
1551
|
+
}
|
|
1552
|
+
function formatRelativeTime(value, now = /* @__PURE__ */ new Date()) {
|
|
1553
|
+
const date = toDate(value);
|
|
1554
|
+
if (!date) return "—";
|
|
1555
|
+
const diffSeconds = Math.round((date.getTime() - now.getTime()) / 1e3);
|
|
1556
|
+
if (Math.abs(diffSeconds) < 45) return "just now";
|
|
1557
|
+
const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
1558
|
+
for (const { unit, seconds } of RELATIVE_UNITS) {
|
|
1559
|
+
if (Math.abs(diffSeconds) >= seconds) {
|
|
1560
|
+
return rtf.format(Math.round(diffSeconds / seconds), unit);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return rtf.format(Math.round(diffSeconds / 60), "minute");
|
|
1564
|
+
}
|
|
1565
|
+
function formatExactDateTime(value) {
|
|
1566
|
+
const date = toDate(value);
|
|
1567
|
+
if (!date) return "—";
|
|
1568
|
+
return new Intl.DateTimeFormat(void 0, {
|
|
1569
|
+
day: "2-digit",
|
|
1570
|
+
month: "short",
|
|
1571
|
+
year: "numeric",
|
|
1572
|
+
hour: "2-digit",
|
|
1573
|
+
minute: "2-digit",
|
|
1574
|
+
second: "2-digit",
|
|
1575
|
+
timeZoneName: "short"
|
|
1576
|
+
}).format(date);
|
|
1577
|
+
}
|
|
1578
|
+
function formatDate(value) {
|
|
1579
|
+
const date = toDate(value);
|
|
1580
|
+
if (!date) return "—";
|
|
1581
|
+
return new Intl.DateTimeFormat(void 0, { day: "2-digit", month: "short", year: "numeric" }).format(date);
|
|
1582
|
+
}
|
|
1583
|
+
function formatNumber(value) {
|
|
1584
|
+
return new Intl.NumberFormat().format(value);
|
|
1585
|
+
}
|
|
1586
|
+
function formatMoney(amount, currencyCode) {
|
|
1587
|
+
const code = currencyCode == null ? void 0 : currencyCode.trim().toUpperCase();
|
|
1588
|
+
if (code && /^[A-Z]{3}$/.test(code)) {
|
|
1589
|
+
try {
|
|
1590
|
+
return new Intl.NumberFormat(void 0, { style: "currency", currency: code }).format(amount);
|
|
1591
|
+
} catch {
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return code ? `${code} ${formatNumber(amount)}` : formatNumber(amount);
|
|
1595
|
+
}
|
|
1596
|
+
const SOURCE_ALIASES = {
|
|
1597
|
+
admin: { kind: "admin", label: "Admin Panel" },
|
|
1598
|
+
admin_panel: { kind: "admin", label: "Admin Panel" },
|
|
1599
|
+
dashboard: { kind: "admin", label: "Admin Panel" },
|
|
1600
|
+
api: { kind: "api", label: "API" },
|
|
1601
|
+
store_api: { kind: "api", label: "Storefront API" },
|
|
1602
|
+
admin_api: { kind: "api", label: "Admin API" },
|
|
1603
|
+
system: { kind: "system", label: "System" },
|
|
1604
|
+
job: { kind: "job", label: "Background Job" },
|
|
1605
|
+
background_job: { kind: "job", label: "Background Job" },
|
|
1606
|
+
scheduled_job: { kind: "job", label: "Background Job" },
|
|
1607
|
+
cron: { kind: "job", label: "Background Job" },
|
|
1608
|
+
workflow: { kind: "workflow", label: "Workflow" },
|
|
1609
|
+
migration: { kind: "system", label: "Migration" }
|
|
1610
|
+
};
|
|
1611
|
+
function describeSource(source) {
|
|
1612
|
+
if (!source || !source.trim()) return { kind: "unknown", label: "Unknown" };
|
|
1613
|
+
const key = source.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
1614
|
+
return SOURCE_ALIASES[key] ?? { kind: "other", label: source.trim() };
|
|
1615
|
+
}
|
|
1616
|
+
function sourceBadgeColor(kind) {
|
|
1617
|
+
switch (kind) {
|
|
1618
|
+
case "admin":
|
|
1619
|
+
return "blue";
|
|
1620
|
+
case "api":
|
|
1621
|
+
return "purple";
|
|
1622
|
+
case "job":
|
|
1623
|
+
case "workflow":
|
|
1624
|
+
return "orange";
|
|
1625
|
+
case "system":
|
|
1626
|
+
return "green";
|
|
1627
|
+
default:
|
|
1628
|
+
return "grey";
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
const CARDS = [
|
|
1632
|
+
{ key: "total", label: "Total deleted", hint: "All records captured since auditing began" },
|
|
1633
|
+
{ key: "today", label: "Today", hint: "Deleted since midnight (your time)" },
|
|
1634
|
+
{ key: "last_7_days", label: "Last 7 days", hint: "Including today" },
|
|
1635
|
+
{ key: "tables_affected", label: "Entity types affected", hint: "Distinct kinds of records deleted" }
|
|
1636
|
+
];
|
|
1637
|
+
const SummaryCards = ({ stats, loading, failed }) => {
|
|
1638
|
+
if (failed && !stats) return null;
|
|
1639
|
+
return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3 lg:grid-cols-4", children: CARDS.map((card) => /* @__PURE__ */ jsxs(
|
|
1640
|
+
"div",
|
|
1641
|
+
{
|
|
1642
|
+
className: "flex flex-col gap-1 rounded-lg border border-ui-border-base bg-ui-bg-subtle px-4 py-3",
|
|
1643
|
+
title: card.hint,
|
|
1644
|
+
children: [
|
|
1645
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: card.label }),
|
|
1646
|
+
loading || !stats ? /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-16" }) : /* @__PURE__ */ jsx(Text, { className: "text-2xl font-semibold leading-8 text-ui-fg-base", children: formatNumber(stats[card.key]) })
|
|
1647
|
+
]
|
|
1648
|
+
},
|
|
1649
|
+
card.key
|
|
1650
|
+
)) });
|
|
1651
|
+
};
|
|
1652
|
+
const BASE = "/admin/deleted-records-audit";
|
|
1653
|
+
class AuditApiError extends Error {
|
|
1654
|
+
constructor(message, status) {
|
|
1655
|
+
super(message);
|
|
1656
|
+
__publicField(this, "status");
|
|
1657
|
+
this.status = status;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
async function getJson(url, signal) {
|
|
1661
|
+
const response = await fetch(url, { credentials: "include", signal });
|
|
1662
|
+
if (!response.ok) {
|
|
1663
|
+
let message = response.statusText || "Request failed";
|
|
1664
|
+
try {
|
|
1665
|
+
const body = await response.json();
|
|
1666
|
+
if (body && typeof body === "object" && "message" in body && typeof body.message === "string") {
|
|
1667
|
+
message = body.message;
|
|
1668
|
+
}
|
|
1669
|
+
} catch {
|
|
1670
|
+
}
|
|
1671
|
+
throw new AuditApiError(message, response.status);
|
|
1672
|
+
}
|
|
1673
|
+
return await response.json();
|
|
1674
|
+
}
|
|
1675
|
+
function fetchAuditList(params, signal) {
|
|
1676
|
+
return getJson(`${BASE}?${params.toString()}`, signal);
|
|
1677
|
+
}
|
|
1678
|
+
async function fetchAuditStats(signal) {
|
|
1679
|
+
const todayStart = /* @__PURE__ */ new Date();
|
|
1680
|
+
todayStart.setHours(0, 0, 0, 0);
|
|
1681
|
+
const params = new URLSearchParams({ today_start: todayStart.toISOString() });
|
|
1682
|
+
const body = await getJson(`${BASE}/stats?${params.toString()}`, signal);
|
|
1683
|
+
return body.stats;
|
|
1684
|
+
}
|
|
1685
|
+
async function fetchAuditDetail(id, signal) {
|
|
1686
|
+
const body = await getJson(`${BASE}/${encodeURIComponent(id)}`, signal);
|
|
1687
|
+
return body.audit;
|
|
1688
|
+
}
|
|
1689
|
+
const LAST_LIST_URL_KEY = "om.deleted-records-audit.last-list-search";
|
|
1690
|
+
const DATE_PRESETS = [
|
|
1691
|
+
{ value: "any", label: "Any time" },
|
|
1692
|
+
{ value: "today", label: "Today" },
|
|
1693
|
+
{ value: "yesterday", label: "Yesterday" },
|
|
1694
|
+
{ value: "7d", label: "Last 7 days" },
|
|
1695
|
+
{ value: "30d", label: "Last 30 days" },
|
|
1696
|
+
{ value: "custom", label: "Custom range" }
|
|
1697
|
+
];
|
|
1698
|
+
const EMPTY_FILTERS = {
|
|
1699
|
+
q: "",
|
|
1700
|
+
entity: "",
|
|
1701
|
+
category: "",
|
|
1702
|
+
date: "any",
|
|
1703
|
+
from: "",
|
|
1704
|
+
to: "",
|
|
1705
|
+
source: "",
|
|
1706
|
+
deletedBy: ""
|
|
1707
|
+
};
|
|
1708
|
+
const URL_KEYS = {
|
|
1709
|
+
q: "q",
|
|
1710
|
+
entity: "entity",
|
|
1711
|
+
category: "category",
|
|
1712
|
+
date: "date",
|
|
1713
|
+
from: "from",
|
|
1714
|
+
to: "to",
|
|
1715
|
+
source: "source",
|
|
1716
|
+
deletedBy: "deleted_by"
|
|
1717
|
+
};
|
|
1718
|
+
const DATE_PRESET_VALUES = new Set(DATE_PRESETS.map((p) => p.value));
|
|
1719
|
+
const DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
1720
|
+
function filtersFromSearchParams(params) {
|
|
1721
|
+
const read = (key) => {
|
|
1722
|
+
var _a;
|
|
1723
|
+
return ((_a = params.get(URL_KEYS[key])) == null ? void 0 : _a.trim()) ?? "";
|
|
1724
|
+
};
|
|
1725
|
+
const date = read("date");
|
|
1726
|
+
const from = read("from");
|
|
1727
|
+
const to = read("to");
|
|
1728
|
+
return {
|
|
1729
|
+
q: read("q"),
|
|
1730
|
+
entity: read("entity"),
|
|
1731
|
+
category: read("category"),
|
|
1732
|
+
date: DATE_PRESET_VALUES.has(date) ? date : "any",
|
|
1733
|
+
from: DAY_PATTERN.test(from) ? from : "",
|
|
1734
|
+
to: DAY_PATTERN.test(to) ? to : "",
|
|
1735
|
+
source: read("source"),
|
|
1736
|
+
deletedBy: read("deletedBy")
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
function filtersToSearchParams(filters) {
|
|
1740
|
+
const params = new URLSearchParams();
|
|
1741
|
+
for (const key of Object.keys(URL_KEYS)) {
|
|
1742
|
+
const value = filters[key];
|
|
1743
|
+
if (!value || value === EMPTY_FILTERS[key]) continue;
|
|
1744
|
+
if ((key === "from" || key === "to") && filters.date !== "custom") continue;
|
|
1745
|
+
params.set(URL_KEYS[key], value);
|
|
1746
|
+
}
|
|
1747
|
+
return params;
|
|
1748
|
+
}
|
|
1749
|
+
function hasActiveFilters(filters) {
|
|
1750
|
+
return filtersToSearchParams(filters).toString() !== "";
|
|
1751
|
+
}
|
|
1752
|
+
function startOfDay(date) {
|
|
1753
|
+
const d = new Date(date);
|
|
1754
|
+
d.setHours(0, 0, 0, 0);
|
|
1755
|
+
return d;
|
|
1756
|
+
}
|
|
1757
|
+
function endOfDay(date) {
|
|
1758
|
+
const d = new Date(date);
|
|
1759
|
+
d.setHours(23, 59, 59, 999);
|
|
1760
|
+
return d;
|
|
1761
|
+
}
|
|
1762
|
+
function parseDay(day) {
|
|
1763
|
+
if (!DAY_PATTERN.test(day)) return null;
|
|
1764
|
+
const [y, m, d] = day.split("-").map(Number);
|
|
1765
|
+
const date = new Date(y, m - 1, d);
|
|
1766
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
1767
|
+
}
|
|
1768
|
+
function resolveDateRange(filters, now = /* @__PURE__ */ new Date()) {
|
|
1769
|
+
const today = startOfDay(now);
|
|
1770
|
+
switch (filters.date) {
|
|
1771
|
+
case "today":
|
|
1772
|
+
return { from: today };
|
|
1773
|
+
case "yesterday": {
|
|
1774
|
+
const y = new Date(today);
|
|
1775
|
+
y.setDate(y.getDate() - 1);
|
|
1776
|
+
return { from: y, to: endOfDay(y) };
|
|
1777
|
+
}
|
|
1778
|
+
case "7d": {
|
|
1779
|
+
const from = new Date(today);
|
|
1780
|
+
from.setDate(from.getDate() - 6);
|
|
1781
|
+
return { from };
|
|
1782
|
+
}
|
|
1783
|
+
case "30d": {
|
|
1784
|
+
const from = new Date(today);
|
|
1785
|
+
from.setDate(from.getDate() - 29);
|
|
1786
|
+
return { from };
|
|
1787
|
+
}
|
|
1788
|
+
case "custom": {
|
|
1789
|
+
const from = parseDay(filters.from);
|
|
1790
|
+
const to = parseDay(filters.to);
|
|
1791
|
+
return { from: from ?? void 0, to: to ? endOfDay(to) : void 0 };
|
|
1792
|
+
}
|
|
1793
|
+
default:
|
|
1794
|
+
return {};
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
function filtersToApiParams(filters, page, now = /* @__PURE__ */ new Date()) {
|
|
1798
|
+
const params = new URLSearchParams();
|
|
1799
|
+
params.set("limit", String(page.limit));
|
|
1800
|
+
params.set("offset", String(page.offset));
|
|
1801
|
+
if (filters.q) params.set("q", filters.q);
|
|
1802
|
+
if (filters.entity) {
|
|
1803
|
+
params.set("table_name", filters.entity);
|
|
1804
|
+
} else if (filters.category) {
|
|
1805
|
+
const tables = getTablesForCategory(filters.category);
|
|
1806
|
+
if (tables.length) params.set("table_names", tables.join(","));
|
|
1807
|
+
}
|
|
1808
|
+
const range = resolveDateRange(filters, now);
|
|
1809
|
+
if (range.from) params.set("date_from", range.from.toISOString());
|
|
1810
|
+
if (range.to) params.set("date_to", range.to.toISOString());
|
|
1811
|
+
if (filters.source) params.set("source", filters.source);
|
|
1812
|
+
if (filters.deletedBy) params.set("deleted_by", filters.deletedBy);
|
|
1813
|
+
return params;
|
|
1814
|
+
}
|
|
1815
|
+
const PAGE_SIZE = 50;
|
|
1816
|
+
const RESTORE_PAGE_SIZE = 100;
|
|
1817
|
+
const MAX_RESTORE_ROWS = 500;
|
|
1818
|
+
const ALL = "__all__";
|
|
1819
|
+
const UNKNOWN_SOURCE = "unknown";
|
|
1820
|
+
const LOADED_COUNT_KEY_PREFIX = "om.deleted-records-audit.loaded:";
|
|
1821
|
+
const LAST_VIEWED_KEY = "om.deleted-records-audit.last-viewed";
|
|
1822
|
+
function readSession(key) {
|
|
1823
|
+
try {
|
|
1824
|
+
return window.sessionStorage.getItem(key);
|
|
1825
|
+
} catch {
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function writeSession(key, value) {
|
|
1830
|
+
try {
|
|
1831
|
+
window.sessionStorage.setItem(key, value);
|
|
1832
|
+
} catch {
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
const DeletedRecordsPage = () => {
|
|
1836
|
+
const navigate = useNavigate();
|
|
1837
|
+
const location = useLocation();
|
|
1838
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
1839
|
+
const filters = useMemo(() => filtersFromSearchParams(searchParams), [searchParams]);
|
|
1840
|
+
const filterKey = filtersToSearchParams(filters).toString();
|
|
1841
|
+
const filtersActive = hasActiveFilters(filters);
|
|
1842
|
+
const [searchText, setSearchText] = useState(filters.q);
|
|
1843
|
+
const [items, setItems] = useState([]);
|
|
1844
|
+
const [count, setCount] = useState(0);
|
|
1845
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1846
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1847
|
+
const [error, setError] = useState(null);
|
|
1848
|
+
const [stats, setStats] = useState(null);
|
|
1849
|
+
const [statsLoading, setStatsLoading] = useState(true);
|
|
1850
|
+
const [statsFailed, setStatsFailed] = useState(false);
|
|
1851
|
+
const [reloadToken, setReloadToken] = useState(0);
|
|
1852
|
+
const [highlightId, setHighlightId] = useState(null);
|
|
1853
|
+
const restoredScrollRef = useRef(false);
|
|
1854
|
+
const updateFilters = useCallback(
|
|
1855
|
+
(patch) => {
|
|
1856
|
+
const next = { ...filters, ...patch };
|
|
1857
|
+
setSearchParams(filtersToSearchParams(next), { replace: true });
|
|
1858
|
+
},
|
|
1859
|
+
[filters, setSearchParams]
|
|
1860
|
+
);
|
|
1861
|
+
useEffect(() => {
|
|
1862
|
+
if (searchText.trim() === filters.q) return;
|
|
1863
|
+
const handle = setTimeout(() => updateFilters({ q: searchText.trim() }), 300);
|
|
1864
|
+
return () => clearTimeout(handle);
|
|
1865
|
+
}, [searchText, filters.q, updateFilters]);
|
|
1866
|
+
useEffect(() => {
|
|
1867
|
+
setSearchText((current) => current.trim() === filters.q ? current : filters.q);
|
|
1868
|
+
}, [filters.q]);
|
|
1869
|
+
useEffect(() => {
|
|
1870
|
+
writeSession(LAST_LIST_URL_KEY, location.search);
|
|
1871
|
+
}, [location.search]);
|
|
1872
|
+
const loadStats = useCallback(async (signal) => {
|
|
1873
|
+
setStatsLoading(true);
|
|
1874
|
+
setStatsFailed(false);
|
|
1875
|
+
try {
|
|
1876
|
+
setStats(await fetchAuditStats(signal));
|
|
1877
|
+
} catch (e) {
|
|
1878
|
+
if (!(signal == null ? void 0 : signal.aborted)) setStatsFailed(true);
|
|
1879
|
+
} finally {
|
|
1880
|
+
if (!(signal == null ? void 0 : signal.aborted)) setStatsLoading(false);
|
|
1881
|
+
}
|
|
1882
|
+
}, []);
|
|
1883
|
+
useEffect(() => {
|
|
1884
|
+
const controller = new AbortController();
|
|
1885
|
+
void loadStats(controller.signal);
|
|
1886
|
+
return () => controller.abort();
|
|
1887
|
+
}, [loadStats, reloadToken]);
|
|
1888
|
+
useEffect(() => {
|
|
1889
|
+
const controller = new AbortController();
|
|
1890
|
+
const restoreTarget = Math.min(
|
|
1891
|
+
MAX_RESTORE_ROWS,
|
|
1892
|
+
Math.max(PAGE_SIZE, Number(readSession(LOADED_COUNT_KEY_PREFIX + filterKey)) || 0)
|
|
1893
|
+
);
|
|
1894
|
+
setIsLoading(true);
|
|
1895
|
+
setError(null);
|
|
1896
|
+
(async () => {
|
|
1897
|
+
try {
|
|
1898
|
+
const collected = [];
|
|
1899
|
+
let total = 0;
|
|
1900
|
+
while (collected.length < restoreTarget) {
|
|
1901
|
+
const limit = restoreTarget > PAGE_SIZE ? RESTORE_PAGE_SIZE : PAGE_SIZE;
|
|
1902
|
+
const page = await fetchAuditList(
|
|
1903
|
+
filtersToApiParams(filters, { limit, offset: collected.length }),
|
|
1904
|
+
controller.signal
|
|
1905
|
+
);
|
|
1906
|
+
total = page.count;
|
|
1907
|
+
collected.push(...page.audits);
|
|
1908
|
+
if (page.audits.length < limit || collected.length >= total) break;
|
|
1909
|
+
}
|
|
1910
|
+
if (controller.signal.aborted) return;
|
|
1911
|
+
setItems(collected.slice(0, restoreTarget));
|
|
1912
|
+
setCount(total);
|
|
1913
|
+
} catch (e) {
|
|
1914
|
+
if (controller.signal.aborted) return;
|
|
1915
|
+
setItems([]);
|
|
1916
|
+
setCount(0);
|
|
1917
|
+
setError(e instanceof Error ? e.message : "Unknown error");
|
|
1918
|
+
} finally {
|
|
1919
|
+
if (!controller.signal.aborted) setIsLoading(false);
|
|
1920
|
+
}
|
|
1921
|
+
})();
|
|
1922
|
+
return () => controller.abort();
|
|
1923
|
+
}, [filterKey, reloadToken]);
|
|
1924
|
+
useEffect(() => {
|
|
1925
|
+
if (!isLoading) writeSession(LOADED_COUNT_KEY_PREFIX + filterKey, String(items.length));
|
|
1926
|
+
}, [items.length, isLoading, filterKey]);
|
|
1927
|
+
useEffect(() => {
|
|
1928
|
+
if (isLoading || restoredScrollRef.current) return;
|
|
1929
|
+
restoredScrollRef.current = true;
|
|
1930
|
+
const lastViewed = readSession(LAST_VIEWED_KEY);
|
|
1931
|
+
if (!lastViewed || !items.some((item) => item.id === lastViewed)) return;
|
|
1932
|
+
setHighlightId(lastViewed);
|
|
1933
|
+
requestAnimationFrame(() => {
|
|
1934
|
+
const visible = Array.from(document.querySelectorAll(`[data-audit-row="${lastViewed}"]`)).find(
|
|
1935
|
+
(el) => el.offsetParent !== null
|
|
1936
|
+
);
|
|
1937
|
+
visible == null ? void 0 : visible.scrollIntoView({ block: "center" });
|
|
1938
|
+
});
|
|
1939
|
+
const handle = setTimeout(() => setHighlightId(null), 2500);
|
|
1940
|
+
return () => clearTimeout(handle);
|
|
1941
|
+
}, [isLoading, items]);
|
|
1942
|
+
const loadMore = async () => {
|
|
1943
|
+
setIsFetchingMore(true);
|
|
1944
|
+
try {
|
|
1945
|
+
const page = await fetchAuditList(filtersToApiParams(filters, { limit: PAGE_SIZE, offset: items.length }));
|
|
1946
|
+
setItems((prev) => [...prev, ...page.audits]);
|
|
1947
|
+
setCount(page.count);
|
|
1948
|
+
} catch (e) {
|
|
1949
|
+
setError(e instanceof Error ? e.message : "Unknown error");
|
|
1950
|
+
} finally {
|
|
1951
|
+
setIsFetchingMore(false);
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
const openDetail = (id) => {
|
|
1955
|
+
writeSession(LAST_VIEWED_KEY, id);
|
|
1956
|
+
navigate(`/deleted-records-audit/${id}`, { state: { fromList: true } });
|
|
1957
|
+
};
|
|
1958
|
+
const clearFilters = () => {
|
|
1959
|
+
setSearchText("");
|
|
1960
|
+
setSearchParams(filtersToSearchParams(EMPTY_FILTERS), { replace: true });
|
|
1961
|
+
};
|
|
1962
|
+
const refresh = () => setReloadToken((t) => t + 1);
|
|
1963
|
+
const hasMore = items.length < count;
|
|
1964
|
+
const knownSources = (stats == null ? void 0 : stats.sources) ?? [];
|
|
1965
|
+
const knownDeletedBy = (stats == null ? void 0 : stats.deleted_by) ?? [];
|
|
1966
|
+
const attributionMissing = !!stats && stats.total > 0 && knownSources.length === 0 && knownDeletedBy.length === 0;
|
|
1967
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-3 md:p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-4 md:p-6", children: [
|
|
1968
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-start md:justify-between", children: [
|
|
1969
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1970
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Deleted Records" }),
|
|
1971
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Review records that were permanently deleted from the system." })
|
|
1972
|
+
] }),
|
|
1973
|
+
/* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: refresh, isLoading: isLoading && items.length > 0, children: [
|
|
1974
|
+
/* @__PURE__ */ jsx(ArrowPath, {}),
|
|
1975
|
+
"Refresh"
|
|
1976
|
+
] })
|
|
1977
|
+
] }),
|
|
1978
|
+
/* @__PURE__ */ jsx(SummaryCards, { stats, loading: statsLoading, failed: statsFailed }),
|
|
1979
|
+
/* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-3", "aria-label": "Search and filters", children: [
|
|
1980
|
+
/* @__PURE__ */ jsx(
|
|
1981
|
+
Input,
|
|
1982
|
+
{
|
|
1983
|
+
type: "search",
|
|
1984
|
+
size: "base",
|
|
1985
|
+
placeholder: "Search by record ID, e.g. order_01J…, prod_…, cus_…",
|
|
1986
|
+
value: searchText,
|
|
1987
|
+
onChange: (e) => setSearchText(e.target.value),
|
|
1988
|
+
"aria-label": "Search by record ID",
|
|
1989
|
+
className: "w-full"
|
|
1990
|
+
}
|
|
1991
|
+
),
|
|
1992
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center", children: [
|
|
1993
|
+
/* @__PURE__ */ jsx(
|
|
1994
|
+
EntityPicker,
|
|
1995
|
+
{
|
|
1996
|
+
entity: filters.entity,
|
|
1997
|
+
category: filters.category,
|
|
1998
|
+
onChange: (next) => updateFilters(next)
|
|
1999
|
+
}
|
|
2000
|
+
),
|
|
2001
|
+
/* @__PURE__ */ jsx("div", { className: "md:w-[160px]", children: /* @__PURE__ */ jsxs(
|
|
2002
|
+
Select,
|
|
2003
|
+
{
|
|
2004
|
+
size: "small",
|
|
2005
|
+
value: filters.date,
|
|
2006
|
+
onValueChange: (value) => updateFilters({ date: value }),
|
|
2007
|
+
children: [
|
|
2008
|
+
/* @__PURE__ */ jsx(Select.Trigger, { "aria-label": "Filter by date", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
2009
|
+
/* @__PURE__ */ jsx(Select.Content, { children: DATE_PRESETS.map((preset) => /* @__PURE__ */ jsx(Select.Item, { value: preset.value, children: preset.label }, preset.value)) })
|
|
2010
|
+
]
|
|
2011
|
+
}
|
|
2012
|
+
) }),
|
|
2013
|
+
filters.date === "custom" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2014
|
+
/* @__PURE__ */ jsx(
|
|
2015
|
+
Input,
|
|
2016
|
+
{
|
|
2017
|
+
type: "date",
|
|
2018
|
+
size: "small",
|
|
2019
|
+
value: filters.from,
|
|
2020
|
+
max: filters.to || void 0,
|
|
2021
|
+
onChange: (e) => updateFilters({ from: e.target.value }),
|
|
2022
|
+
"aria-label": "From date"
|
|
2023
|
+
}
|
|
2024
|
+
),
|
|
2025
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "to" }),
|
|
2026
|
+
/* @__PURE__ */ jsx(
|
|
2027
|
+
Input,
|
|
2028
|
+
{
|
|
2029
|
+
type: "date",
|
|
2030
|
+
size: "small",
|
|
2031
|
+
value: filters.to,
|
|
2032
|
+
min: filters.from || void 0,
|
|
2033
|
+
onChange: (e) => updateFilters({ to: e.target.value }),
|
|
2034
|
+
"aria-label": "To date"
|
|
2035
|
+
}
|
|
2036
|
+
)
|
|
2037
|
+
] }) : null,
|
|
2038
|
+
knownSources.length > 0 || filters.source ? /* @__PURE__ */ jsx("div", { className: "md:w-[170px]", children: /* @__PURE__ */ jsxs(
|
|
2039
|
+
Select,
|
|
2040
|
+
{
|
|
2041
|
+
size: "small",
|
|
2042
|
+
value: filters.source || ALL,
|
|
2043
|
+
onValueChange: (value) => updateFilters({ source: value === ALL ? "" : value }),
|
|
2044
|
+
children: [
|
|
2045
|
+
/* @__PURE__ */ jsx(Select.Trigger, { "aria-label": "Filter by source", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
2046
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
2047
|
+
/* @__PURE__ */ jsx(Select.Item, { value: ALL, children: "All sources" }),
|
|
2048
|
+
knownSources.map((source) => /* @__PURE__ */ jsx(Select.Item, { value: source, children: describeSource(source).label }, source)),
|
|
2049
|
+
/* @__PURE__ */ jsx(Select.Item, { value: UNKNOWN_SOURCE, children: "Unknown" })
|
|
2050
|
+
] })
|
|
2051
|
+
]
|
|
2052
|
+
}
|
|
2053
|
+
) }) : null,
|
|
2054
|
+
knownDeletedBy.length > 0 || filters.deletedBy ? /* @__PURE__ */ jsxs("div", { className: "md:w-[200px]", children: [
|
|
2055
|
+
/* @__PURE__ */ jsx(
|
|
2056
|
+
Input,
|
|
2057
|
+
{
|
|
2058
|
+
size: "small",
|
|
2059
|
+
list: "deleted-records-audit-deleted-by",
|
|
2060
|
+
placeholder: "Deleted by (all users)",
|
|
2061
|
+
defaultValue: filters.deletedBy,
|
|
2062
|
+
onBlur: (e) => updateFilters({ deletedBy: e.target.value.trim() }),
|
|
2063
|
+
onKeyDown: (e) => {
|
|
2064
|
+
if (e.key === "Enter") updateFilters({ deletedBy: e.currentTarget.value.trim() });
|
|
2065
|
+
},
|
|
2066
|
+
"aria-label": "Filter by who deleted the record"
|
|
2067
|
+
},
|
|
2068
|
+
filters.deletedBy
|
|
2069
|
+
),
|
|
2070
|
+
/* @__PURE__ */ jsx("datalist", { id: "deleted-records-audit-deleted-by", children: knownDeletedBy.map((value) => /* @__PURE__ */ jsx("option", { value }, value)) })
|
|
2071
|
+
] }) : null,
|
|
2072
|
+
filtersActive ? /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: clearFilters, children: "Clear filters" }) : null
|
|
2073
|
+
] })
|
|
2074
|
+
] }),
|
|
2075
|
+
attributionMissing ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 rounded-lg border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: [
|
|
2076
|
+
/* @__PURE__ */ jsx(InformationCircle, { className: "mt-0.5 shrink-0 text-ui-fg-muted" }),
|
|
2077
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Who deleted a record and where the deletion came from are not being recorded yet, so those columns show “Unknown”. Every deleted record is still captured in full." })
|
|
2078
|
+
] }) : null,
|
|
2079
|
+
!isLoading && !error && items.length > 0 ? /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", "aria-live": "polite", children: [
|
|
2080
|
+
"Showing ",
|
|
2081
|
+
formatNumber(items.length),
|
|
2082
|
+
" of ",
|
|
2083
|
+
formatNumber(count),
|
|
2084
|
+
" ",
|
|
2085
|
+
count === 1 ? "record" : "records",
|
|
2086
|
+
filtersActive ? " matching your filters" : ""
|
|
2087
|
+
] }) : null,
|
|
2088
|
+
error ? /* @__PURE__ */ jsx(ErrorState, { onRetry: refresh, detail: error }) : isLoading ? /* @__PURE__ */ jsx(ListSkeleton, {}) : items.length === 0 ? filtersActive ? /* @__PURE__ */ jsx(
|
|
2089
|
+
EmptyState,
|
|
2090
|
+
{
|
|
2091
|
+
title: "No deleted records found",
|
|
2092
|
+
body: "There are no audit records matching your current filters.",
|
|
2093
|
+
action: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: clearFilters, children: "Clear filters" })
|
|
2094
|
+
}
|
|
2095
|
+
) : /* @__PURE__ */ jsx(
|
|
2096
|
+
EmptyState,
|
|
2097
|
+
{
|
|
2098
|
+
title: "No deleted records yet",
|
|
2099
|
+
body: "Hard-deleted records will appear here automatically when a monitored database record is permanently deleted."
|
|
2100
|
+
}
|
|
2101
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2102
|
+
/* @__PURE__ */ jsx(AuditTable, { items, highlightId, onOpen: openDetail }),
|
|
2103
|
+
/* @__PURE__ */ jsx(AuditCards, { items, highlightId, onOpen: openDetail })
|
|
2104
|
+
] }),
|
|
2105
|
+
!error && !isLoading && hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", isLoading: isFetchingMore, onClick: loadMore, children: "Load more" }) }) : null
|
|
2106
|
+
] }) });
|
|
2107
|
+
};
|
|
2108
|
+
const HEADER_CELL = "px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted";
|
|
2109
|
+
const DeletedWhen = ({ occurredAt }) => /* @__PURE__ */ jsx(Tooltip, { content: formatExactDateTime(occurredAt), children: /* @__PURE__ */ jsx("span", { className: "cursor-default text-sm text-ui-fg-base", children: formatRelativeTime(occurredAt) }) });
|
|
2110
|
+
const SourceBadge = ({ source }) => {
|
|
2111
|
+
const info = describeSource(source);
|
|
2112
|
+
if (info.kind === "unknown") {
|
|
2113
|
+
return /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Unknown" });
|
|
2114
|
+
}
|
|
2115
|
+
return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: sourceBadgeColor(info.kind), className: "shrink-0 whitespace-nowrap", children: info.label });
|
|
2116
|
+
};
|
|
2117
|
+
const AuditTable = ({ items, highlightId, onOpen }) => /* @__PURE__ */ jsx("div", { className: "hidden w-full overflow-hidden rounded-xl border border-ui-border-base md:block", children: /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", children: [
|
|
2118
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2119
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[22%]"), children: "Entity" }),
|
|
2120
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[24%]"), children: "Record" }),
|
|
2121
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[13%]"), children: "Deleted" }),
|
|
2122
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[13%]"), children: "Deleted by" }),
|
|
2123
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[11%]"), children: "Source" }),
|
|
2124
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[8%]"), children: "Status" }),
|
|
2125
|
+
/* @__PURE__ */ jsx("th", { className: clx(HEADER_CELL, "w-[9%]"), children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Action" }) })
|
|
2126
|
+
] }) }),
|
|
2127
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((item) => {
|
|
2128
|
+
const entity = getEntityInfo(item.table_name);
|
|
2129
|
+
return /* @__PURE__ */ jsxs(
|
|
2130
|
+
"tr",
|
|
2131
|
+
{
|
|
2132
|
+
"data-audit-row": item.id,
|
|
2133
|
+
tabIndex: 0,
|
|
2134
|
+
onClick: () => onOpen(item.id),
|
|
2135
|
+
onKeyDown: (e) => {
|
|
2136
|
+
if (e.key === "Enter") onOpen(item.id);
|
|
2137
|
+
},
|
|
2138
|
+
className: clx(
|
|
2139
|
+
"cursor-pointer outline-none transition-colors hover:bg-ui-bg-subtle/60 focus-visible:bg-ui-bg-subtle",
|
|
2140
|
+
highlightId === item.id && "bg-ui-bg-highlight"
|
|
2141
|
+
),
|
|
2142
|
+
children: [
|
|
2143
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
2144
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-ui-fg-base", title: entity.label, children: entity.label }),
|
|
2145
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-ui-fg-muted", children: entity.category.label })
|
|
2146
|
+
] }) }),
|
|
2147
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(CopyableId, { value: item.record_id }) }),
|
|
2148
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(DeletedWhen, { occurredAt: item.occurred_at }) }),
|
|
2149
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-sm", title: item.deleted_by ?? void 0, children: item.deleted_by ? /* @__PURE__ */ jsx("span", { className: "text-ui-fg-base", children: item.deleted_by }) : /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "Unknown" }) }),
|
|
2150
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(SourceBadge, { source: item.source }) }),
|
|
2151
|
+
/* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "red", children: "Deleted" }) }),
|
|
2152
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-3 text-right", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-0.5 whitespace-nowrap text-sm font-medium text-ui-fg-interactive", children: [
|
|
2153
|
+
"View",
|
|
2154
|
+
/* @__PURE__ */ jsx(ChevronRightMini, {})
|
|
2155
|
+
] }) })
|
|
2156
|
+
]
|
|
2157
|
+
},
|
|
2158
|
+
item.id
|
|
2159
|
+
);
|
|
2160
|
+
}) })
|
|
2161
|
+
] }) });
|
|
2162
|
+
const AuditCards = ({ items, highlightId, onOpen }) => /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-2 md:hidden", children: items.map((item) => {
|
|
2163
|
+
const entity = getEntityInfo(item.table_name);
|
|
2164
|
+
return /* @__PURE__ */ jsx("li", { "data-audit-row": item.id, children: /* @__PURE__ */ jsxs(
|
|
2165
|
+
"div",
|
|
2166
|
+
{
|
|
2167
|
+
role: "button",
|
|
2168
|
+
tabIndex: 0,
|
|
2169
|
+
onClick: () => onOpen(item.id),
|
|
2170
|
+
onKeyDown: (e) => {
|
|
2171
|
+
if (e.key === "Enter") onOpen(item.id);
|
|
2172
|
+
},
|
|
2173
|
+
className: clx(
|
|
2174
|
+
"flex w-full flex-col gap-2 rounded-lg border border-ui-border-base p-3 text-left outline-none hover:bg-ui-bg-subtle/60 focus-visible:bg-ui-bg-subtle",
|
|
2175
|
+
highlightId === item.id && "bg-ui-bg-highlight"
|
|
2176
|
+
),
|
|
2177
|
+
children: [
|
|
2178
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
2179
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
2180
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-ui-fg-base", children: entity.label }),
|
|
2181
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-ui-fg-muted", children: entity.category.label })
|
|
2182
|
+
] }),
|
|
2183
|
+
/* @__PURE__ */ jsx(DeletedWhen, { occurredAt: item.occurred_at })
|
|
2184
|
+
] }),
|
|
2185
|
+
/* @__PURE__ */ jsx(CopyableId, { value: item.record_id }),
|
|
2186
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2187
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
2188
|
+
/* @__PURE__ */ jsx(SourceBadge, { source: item.source }),
|
|
2189
|
+
item.deleted_by ? /* @__PURE__ */ jsxs("span", { className: "truncate text-xs text-ui-fg-subtle", children: [
|
|
2190
|
+
"by ",
|
|
2191
|
+
item.deleted_by
|
|
2192
|
+
] }) : null
|
|
2193
|
+
] }),
|
|
2194
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex shrink-0 items-center whitespace-nowrap text-sm font-medium text-ui-fg-interactive", children: [
|
|
2195
|
+
"View details",
|
|
2196
|
+
/* @__PURE__ */ jsx(ChevronRightMini, {})
|
|
2197
|
+
] })
|
|
2198
|
+
] })
|
|
2199
|
+
]
|
|
2200
|
+
}
|
|
2201
|
+
) }, item.id);
|
|
2202
|
+
}) });
|
|
2203
|
+
const ListSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0 overflow-hidden rounded-xl border border-ui-border-base", "aria-busy": "true", children: [
|
|
2204
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-bg-subtle px-3 py-3", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-40" }) }),
|
|
2205
|
+
Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 border-t border-ui-border-subtle px-3 py-4", children: [
|
|
2206
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-[22%] flex-col gap-1.5", children: [
|
|
2207
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-28" }),
|
|
2208
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-16" })
|
|
2209
|
+
] }),
|
|
2210
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-[20%]" }),
|
|
2211
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-[10%]" }),
|
|
2212
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "hidden h-3.5 w-[10%] md:block" }),
|
|
2213
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "hidden h-5 w-14 rounded-full md:block" })
|
|
2214
|
+
] }, i))
|
|
2215
|
+
] });
|
|
2216
|
+
const EmptyState = ({ title, body, action }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-dashed border-ui-border-strong px-6 py-12 text-center", children: [
|
|
2217
|
+
/* @__PURE__ */ jsx(MagnifierAlert, { className: "text-ui-fg-muted" }),
|
|
2218
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: title }),
|
|
2219
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: body }),
|
|
2220
|
+
action ? /* @__PURE__ */ jsx("div", { className: "mt-2", children: action }) : null
|
|
2221
|
+
] });
|
|
2222
|
+
const ErrorState = ({ onRetry, detail }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-ui-border-base px-6 py-12 text-center", children: [
|
|
2223
|
+
/* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-error" }),
|
|
2224
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: "Unable to load deleted records" }),
|
|
2225
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: "We couldn’t retrieve the audit records right now. Check your connection and try again." }),
|
|
2226
|
+
/* @__PURE__ */ jsx(Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: detail }),
|
|
2227
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", className: "mt-2", onClick: onRetry, children: "Try again" })
|
|
2228
|
+
] });
|
|
2229
|
+
const config$8 = defineRouteConfig({
|
|
2230
|
+
label: "Deleted Records",
|
|
2231
|
+
icon: Trash
|
|
2232
|
+
});
|
|
926
2233
|
const useDebounce$3 = (value, delay) => {
|
|
927
2234
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
928
2235
|
useEffect(() => {
|
|
@@ -939,19 +2246,27 @@ const getStatusBadgeClass$7 = (status) => {
|
|
|
939
2246
|
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
940
2247
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
941
2248
|
};
|
|
942
|
-
const
|
|
2249
|
+
const RefundsPage = () => {
|
|
943
2250
|
const navigate = useNavigate();
|
|
944
2251
|
const [items, setItems] = useState([]);
|
|
945
|
-
const [statusFilter, setStatusFilter] = useState("all");
|
|
946
2252
|
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
947
2253
|
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
2254
|
+
const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
|
|
2255
|
+
const [providerSearch, setProviderSearch] = useState("");
|
|
2256
|
+
const debouncedProvider = useDebounce$3(providerSearch, 300);
|
|
2257
|
+
const [currencySearch, setCurrencySearch] = useState("");
|
|
2258
|
+
const debouncedCurrency = useDebounce$3(currencySearch, 300);
|
|
2259
|
+
const [dateFrom, setDateFrom] = useState("");
|
|
2260
|
+
const [dateTo, setDateTo] = useState("");
|
|
2261
|
+
const [amountMin, setAmountMin] = useState("");
|
|
2262
|
+
const [amountMax, setAmountMax] = useState("");
|
|
948
2263
|
const [isLoading, setIsLoading] = useState(true);
|
|
949
2264
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
950
2265
|
const [error, setError] = useState(null);
|
|
951
2266
|
const [offset, setOffset] = useState(0);
|
|
952
2267
|
const [count, setCount] = useState(0);
|
|
953
2268
|
const limit = 50;
|
|
954
|
-
const
|
|
2269
|
+
const loadRefunds = useCallback(
|
|
955
2270
|
async (nextOffset, replace) => {
|
|
956
2271
|
try {
|
|
957
2272
|
if (replace) setIsLoading(true);
|
|
@@ -960,18 +2275,25 @@ const PaymentsPage = () => {
|
|
|
960
2275
|
const params = new URLSearchParams();
|
|
961
2276
|
params.set("limit", String(limit));
|
|
962
2277
|
params.set("offset", String(nextOffset));
|
|
963
|
-
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
964
2278
|
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
);
|
|
2279
|
+
if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
|
|
2280
|
+
if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
|
|
2281
|
+
if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
|
|
2282
|
+
if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
|
|
2283
|
+
if (dateTo.trim()) params.set("date_to", dateTo.trim());
|
|
2284
|
+
const min = amountMin.trim() ? Number(amountMin) : void 0;
|
|
2285
|
+
const max = amountMax.trim() ? Number(amountMax) : void 0;
|
|
2286
|
+
if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
|
|
2287
|
+
if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
|
|
2288
|
+
const response = await fetch(`/admin/refunds?${params.toString()}`, {
|
|
2289
|
+
credentials: "include"
|
|
2290
|
+
});
|
|
969
2291
|
if (!response.ok) {
|
|
970
2292
|
const text = await response.text();
|
|
971
|
-
throw new Error(text || "Failed to load
|
|
2293
|
+
throw new Error(text || "Failed to load refunds");
|
|
972
2294
|
}
|
|
973
2295
|
const payload = await response.json();
|
|
974
|
-
const list = payload.
|
|
2296
|
+
const list = payload.refunds ?? [];
|
|
975
2297
|
setCount(payload.count ?? 0);
|
|
976
2298
|
setOffset(nextOffset + list.length);
|
|
977
2299
|
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
@@ -982,235 +2304,20 @@ const PaymentsPage = () => {
|
|
|
982
2304
|
setIsFetchingMore(false);
|
|
983
2305
|
}
|
|
984
2306
|
},
|
|
985
|
-
[
|
|
2307
|
+
[
|
|
2308
|
+
debouncedOrderId,
|
|
2309
|
+
paymentStatusFilter,
|
|
2310
|
+
debouncedProvider,
|
|
2311
|
+
debouncedCurrency,
|
|
2312
|
+
dateFrom,
|
|
2313
|
+
dateTo,
|
|
2314
|
+
amountMin,
|
|
2315
|
+
amountMax
|
|
2316
|
+
]
|
|
986
2317
|
);
|
|
987
2318
|
useEffect(() => {
|
|
988
|
-
void
|
|
989
|
-
}, [
|
|
990
|
-
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
991
|
-
const displayStatus = (t) => {
|
|
992
|
-
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
993
|
-
return s2 !== "" ? s2 : "—";
|
|
994
|
-
};
|
|
995
|
-
const displayAmount = (t) => {
|
|
996
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
997
|
-
return `${code} ${Number(t.amount)}`;
|
|
998
|
-
};
|
|
999
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1000
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1001
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1002
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
1003
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
1004
|
-
] }),
|
|
1005
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
1006
|
-
] }),
|
|
1007
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1008
|
-
/* @__PURE__ */ jsx(
|
|
1009
|
-
Input,
|
|
1010
|
-
{
|
|
1011
|
-
placeholder: "Search by Order ID",
|
|
1012
|
-
value: orderIdSearch,
|
|
1013
|
-
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
1014
|
-
className: "md:max-w-sm",
|
|
1015
|
-
"aria-label": "Search by order ID"
|
|
1016
|
-
}
|
|
1017
|
-
),
|
|
1018
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
1019
|
-
"select",
|
|
1020
|
-
{
|
|
1021
|
-
value: statusFilter,
|
|
1022
|
-
onChange: (e) => setStatusFilter(e.target.value),
|
|
1023
|
-
className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
|
|
1024
|
-
"aria-label": "Filter by status",
|
|
1025
|
-
children: [
|
|
1026
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1027
|
-
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1028
|
-
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1029
|
-
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1030
|
-
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1031
|
-
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1032
|
-
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1033
|
-
]
|
|
1034
|
-
}
|
|
1035
|
-
) })
|
|
1036
|
-
] }),
|
|
1037
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1038
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1039
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
1040
|
-
] }) : null,
|
|
1041
|
-
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1042
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
1043
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
1044
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1045
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1046
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1047
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1048
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1049
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1050
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
1051
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1052
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1053
|
-
] }) }),
|
|
1054
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
1055
|
-
"tr",
|
|
1056
|
-
{
|
|
1057
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1058
|
-
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1059
|
-
children: [
|
|
1060
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
1061
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
1062
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1063
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1064
|
-
Badge,
|
|
1065
|
-
{
|
|
1066
|
-
size: "2xsmall",
|
|
1067
|
-
className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
|
|
1068
|
-
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1069
|
-
}
|
|
1070
|
-
) }),
|
|
1071
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1072
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1073
|
-
year: "numeric",
|
|
1074
|
-
month: "short",
|
|
1075
|
-
day: "numeric",
|
|
1076
|
-
hour: "numeric",
|
|
1077
|
-
minute: "2-digit",
|
|
1078
|
-
hour12: true
|
|
1079
|
-
}) }),
|
|
1080
|
-
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
1081
|
-
/* @__PURE__ */ jsx(
|
|
1082
|
-
Button,
|
|
1083
|
-
{
|
|
1084
|
-
variant: "transparent",
|
|
1085
|
-
size: "small",
|
|
1086
|
-
onClick: (e) => {
|
|
1087
|
-
e.stopPropagation();
|
|
1088
|
-
navigate(`/payments/${t.payment_session_id}`);
|
|
1089
|
-
},
|
|
1090
|
-
children: "View details"
|
|
1091
|
-
}
|
|
1092
|
-
),
|
|
1093
|
-
t.order_id ? /* @__PURE__ */ jsx(
|
|
1094
|
-
Button,
|
|
1095
|
-
{
|
|
1096
|
-
variant: "transparent",
|
|
1097
|
-
size: "small",
|
|
1098
|
-
onClick: (e) => {
|
|
1099
|
-
e.stopPropagation();
|
|
1100
|
-
navigate(`/orders/${t.order_id}`);
|
|
1101
|
-
},
|
|
1102
|
-
children: "Order"
|
|
1103
|
-
}
|
|
1104
|
-
) : null
|
|
1105
|
-
] })
|
|
1106
|
-
]
|
|
1107
|
-
},
|
|
1108
|
-
t.payment_session_id
|
|
1109
|
-
)) })
|
|
1110
|
-
] }) }),
|
|
1111
|
-
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1112
|
-
Button,
|
|
1113
|
-
{
|
|
1114
|
-
variant: "secondary",
|
|
1115
|
-
isLoading: isFetchingMore,
|
|
1116
|
-
onClick: () => loadTransactions(offset, false),
|
|
1117
|
-
children: "Load more"
|
|
1118
|
-
}
|
|
1119
|
-
) }) : null
|
|
1120
|
-
] }) });
|
|
1121
|
-
};
|
|
1122
|
-
const config$7 = defineRouteConfig({
|
|
1123
|
-
label: "Payments",
|
|
1124
|
-
icon: CreditCard
|
|
1125
|
-
});
|
|
1126
|
-
const useDebounce$2 = (value, delay) => {
|
|
1127
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1128
|
-
useEffect(() => {
|
|
1129
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1130
|
-
return () => clearTimeout(handler);
|
|
1131
|
-
}, [value, delay]);
|
|
1132
|
-
return debouncedValue;
|
|
1133
|
-
};
|
|
1134
|
-
const getStatusBadgeClass$6 = (status) => {
|
|
1135
|
-
const s2 = status.toLowerCase();
|
|
1136
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1137
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1138
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1139
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1140
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1141
|
-
};
|
|
1142
|
-
const RefundsPage = () => {
|
|
1143
|
-
const navigate = useNavigate();
|
|
1144
|
-
const [items, setItems] = useState([]);
|
|
1145
|
-
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1146
|
-
const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
|
|
1147
|
-
const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
|
|
1148
|
-
const [providerSearch, setProviderSearch] = useState("");
|
|
1149
|
-
const debouncedProvider = useDebounce$2(providerSearch, 300);
|
|
1150
|
-
const [currencySearch, setCurrencySearch] = useState("");
|
|
1151
|
-
const debouncedCurrency = useDebounce$2(currencySearch, 300);
|
|
1152
|
-
const [dateFrom, setDateFrom] = useState("");
|
|
1153
|
-
const [dateTo, setDateTo] = useState("");
|
|
1154
|
-
const [amountMin, setAmountMin] = useState("");
|
|
1155
|
-
const [amountMax, setAmountMax] = useState("");
|
|
1156
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
1157
|
-
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1158
|
-
const [error, setError] = useState(null);
|
|
1159
|
-
const [offset, setOffset] = useState(0);
|
|
1160
|
-
const [count, setCount] = useState(0);
|
|
1161
|
-
const limit = 50;
|
|
1162
|
-
const loadRefunds = useCallback(
|
|
1163
|
-
async (nextOffset, replace) => {
|
|
1164
|
-
try {
|
|
1165
|
-
if (replace) setIsLoading(true);
|
|
1166
|
-
else setIsFetchingMore(true);
|
|
1167
|
-
setError(null);
|
|
1168
|
-
const params = new URLSearchParams();
|
|
1169
|
-
params.set("limit", String(limit));
|
|
1170
|
-
params.set("offset", String(nextOffset));
|
|
1171
|
-
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
1172
|
-
if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
|
|
1173
|
-
if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
|
|
1174
|
-
if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
|
|
1175
|
-
if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
|
|
1176
|
-
if (dateTo.trim()) params.set("date_to", dateTo.trim());
|
|
1177
|
-
const min = amountMin.trim() ? Number(amountMin) : void 0;
|
|
1178
|
-
const max = amountMax.trim() ? Number(amountMax) : void 0;
|
|
1179
|
-
if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
|
|
1180
|
-
if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
|
|
1181
|
-
const response = await fetch(`/admin/refunds?${params.toString()}`, {
|
|
1182
|
-
credentials: "include"
|
|
1183
|
-
});
|
|
1184
|
-
if (!response.ok) {
|
|
1185
|
-
const text = await response.text();
|
|
1186
|
-
throw new Error(text || "Failed to load refunds");
|
|
1187
|
-
}
|
|
1188
|
-
const payload = await response.json();
|
|
1189
|
-
const list = payload.refunds ?? [];
|
|
1190
|
-
setCount(payload.count ?? 0);
|
|
1191
|
-
setOffset(nextOffset + list.length);
|
|
1192
|
-
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
1193
|
-
} catch (e) {
|
|
1194
|
-
setError(e instanceof Error ? e.message : "Failed to load");
|
|
1195
|
-
} finally {
|
|
1196
|
-
setIsLoading(false);
|
|
1197
|
-
setIsFetchingMore(false);
|
|
1198
|
-
}
|
|
1199
|
-
},
|
|
1200
|
-
[
|
|
1201
|
-
debouncedOrderId,
|
|
1202
|
-
paymentStatusFilter,
|
|
1203
|
-
debouncedProvider,
|
|
1204
|
-
debouncedCurrency,
|
|
1205
|
-
dateFrom,
|
|
1206
|
-
dateTo,
|
|
1207
|
-
amountMin,
|
|
1208
|
-
amountMax
|
|
1209
|
-
]
|
|
1210
|
-
);
|
|
1211
|
-
useEffect(() => {
|
|
1212
|
-
void loadRefunds(0, true);
|
|
1213
|
-
}, [loadRefunds]);
|
|
2319
|
+
void loadRefunds(0, true);
|
|
2320
|
+
}, [loadRefunds]);
|
|
1214
2321
|
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1215
2322
|
const displayAmount = (r) => {
|
|
1216
2323
|
const code = (r.currency_code ?? "USD").toUpperCase();
|
|
@@ -1360,7 +2467,7 @@ const RefundsPage = () => {
|
|
|
1360
2467
|
Badge,
|
|
1361
2468
|
{
|
|
1362
2469
|
size: "2xsmall",
|
|
1363
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2470
|
+
className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
|
|
1364
2471
|
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
1365
2472
|
}
|
|
1366
2473
|
) }),
|
|
@@ -1414,11 +2521,11 @@ const RefundsPage = () => {
|
|
|
1414
2521
|
) }) : null
|
|
1415
2522
|
] }) });
|
|
1416
2523
|
};
|
|
1417
|
-
const config$
|
|
2524
|
+
const config$7 = defineRouteConfig({
|
|
1418
2525
|
label: "Refunds",
|
|
1419
2526
|
icon: Receipt
|
|
1420
2527
|
});
|
|
1421
|
-
const useDebounce$
|
|
2528
|
+
const useDebounce$2 = (value, delay) => {
|
|
1422
2529
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1423
2530
|
useEffect(() => {
|
|
1424
2531
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1426,43 +2533,244 @@ const useDebounce$1 = (value, delay) => {
|
|
|
1426
2533
|
}, [value, delay]);
|
|
1427
2534
|
return debouncedValue;
|
|
1428
2535
|
};
|
|
1429
|
-
const getStatusBadgeClass$
|
|
1430
|
-
const
|
|
1431
|
-
if (
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
if (
|
|
1435
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1436
|
-
}
|
|
1437
|
-
if (statusLower === "requires_action") {
|
|
1438
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1439
|
-
}
|
|
1440
|
-
if (statusLower === "completed") {
|
|
1441
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1442
|
-
}
|
|
1443
|
-
if (statusLower === "canceled") {
|
|
1444
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1445
|
-
}
|
|
2536
|
+
const getStatusBadgeClass$6 = (status) => {
|
|
2537
|
+
const s2 = status.toLowerCase();
|
|
2538
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2539
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2540
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2541
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1446
2542
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1447
2543
|
};
|
|
1448
|
-
const
|
|
2544
|
+
const PaymentsPage = () => {
|
|
1449
2545
|
const navigate = useNavigate();
|
|
1450
2546
|
const [items, setItems] = useState([]);
|
|
1451
2547
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1452
|
-
const [
|
|
1453
|
-
const
|
|
1454
|
-
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
2548
|
+
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
2549
|
+
const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
|
|
1455
2550
|
const [isLoading, setIsLoading] = useState(true);
|
|
1456
2551
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1457
2552
|
const [error, setError] = useState(null);
|
|
1458
2553
|
const [offset, setOffset] = useState(0);
|
|
1459
2554
|
const [count, setCount] = useState(0);
|
|
1460
2555
|
const limit = 50;
|
|
1461
|
-
const
|
|
1462
|
-
async (nextOffset, replace
|
|
2556
|
+
const loadTransactions = useCallback(
|
|
2557
|
+
async (nextOffset, replace) => {
|
|
1463
2558
|
try {
|
|
1464
|
-
if (replace)
|
|
1465
|
-
|
|
2559
|
+
if (replace) setIsLoading(true);
|
|
2560
|
+
else setIsFetchingMore(true);
|
|
2561
|
+
setError(null);
|
|
2562
|
+
const params = new URLSearchParams();
|
|
2563
|
+
params.set("limit", String(limit));
|
|
2564
|
+
params.set("offset", String(nextOffset));
|
|
2565
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
2566
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
2567
|
+
const response = await fetch(
|
|
2568
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
2569
|
+
{ credentials: "include" }
|
|
2570
|
+
);
|
|
2571
|
+
if (!response.ok) {
|
|
2572
|
+
const text = await response.text();
|
|
2573
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
2574
|
+
}
|
|
2575
|
+
const payload = await response.json();
|
|
2576
|
+
const list = payload.transactions ?? [];
|
|
2577
|
+
setCount(payload.count ?? 0);
|
|
2578
|
+
setOffset(nextOffset + list.length);
|
|
2579
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
2580
|
+
} catch (e) {
|
|
2581
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
2582
|
+
} finally {
|
|
2583
|
+
setIsLoading(false);
|
|
2584
|
+
setIsFetchingMore(false);
|
|
2585
|
+
}
|
|
2586
|
+
},
|
|
2587
|
+
[statusFilter, debouncedOrderId]
|
|
2588
|
+
);
|
|
2589
|
+
useEffect(() => {
|
|
2590
|
+
void loadTransactions(0, true);
|
|
2591
|
+
}, [loadTransactions]);
|
|
2592
|
+
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
2593
|
+
const displayStatus = (t) => {
|
|
2594
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
2595
|
+
return s2 !== "" ? s2 : "—";
|
|
2596
|
+
};
|
|
2597
|
+
const displayAmount = (t) => {
|
|
2598
|
+
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
2599
|
+
return `${code} ${Number(t.amount)}`;
|
|
2600
|
+
};
|
|
2601
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
2602
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2603
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2604
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
2605
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
2606
|
+
] }),
|
|
2607
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
2608
|
+
] }),
|
|
2609
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2610
|
+
/* @__PURE__ */ jsx(
|
|
2611
|
+
Input,
|
|
2612
|
+
{
|
|
2613
|
+
placeholder: "Search by Order ID",
|
|
2614
|
+
value: orderIdSearch,
|
|
2615
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
2616
|
+
className: "md:max-w-sm",
|
|
2617
|
+
"aria-label": "Search by order ID"
|
|
2618
|
+
}
|
|
2619
|
+
),
|
|
2620
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
2621
|
+
"select",
|
|
2622
|
+
{
|
|
2623
|
+
value: statusFilter,
|
|
2624
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
2625
|
+
className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
|
|
2626
|
+
"aria-label": "Filter by status",
|
|
2627
|
+
children: [
|
|
2628
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
2629
|
+
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
2630
|
+
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
2631
|
+
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
2632
|
+
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
2633
|
+
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
2634
|
+
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
2635
|
+
]
|
|
2636
|
+
}
|
|
2637
|
+
) })
|
|
2638
|
+
] }),
|
|
2639
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2640
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2641
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
2642
|
+
] }) : null,
|
|
2643
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
2644
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
2645
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
2646
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2647
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2648
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
2649
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
2650
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
2651
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
2652
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
2653
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
2654
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
2655
|
+
] }) }),
|
|
2656
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
2657
|
+
"tr",
|
|
2658
|
+
{
|
|
2659
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
2660
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
2661
|
+
children: [
|
|
2662
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
2663
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
2664
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
2665
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
2666
|
+
Badge,
|
|
2667
|
+
{
|
|
2668
|
+
size: "2xsmall",
|
|
2669
|
+
className: `uppercase ${getStatusBadgeClass$6(displayStatus(t))}`,
|
|
2670
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
2671
|
+
}
|
|
2672
|
+
) }),
|
|
2673
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
2674
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
2675
|
+
year: "numeric",
|
|
2676
|
+
month: "short",
|
|
2677
|
+
day: "numeric",
|
|
2678
|
+
hour: "numeric",
|
|
2679
|
+
minute: "2-digit",
|
|
2680
|
+
hour12: true
|
|
2681
|
+
}) }),
|
|
2682
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
2683
|
+
/* @__PURE__ */ jsx(
|
|
2684
|
+
Button,
|
|
2685
|
+
{
|
|
2686
|
+
variant: "transparent",
|
|
2687
|
+
size: "small",
|
|
2688
|
+
onClick: (e) => {
|
|
2689
|
+
e.stopPropagation();
|
|
2690
|
+
navigate(`/payments/${t.payment_session_id}`);
|
|
2691
|
+
},
|
|
2692
|
+
children: "View details"
|
|
2693
|
+
}
|
|
2694
|
+
),
|
|
2695
|
+
t.order_id ? /* @__PURE__ */ jsx(
|
|
2696
|
+
Button,
|
|
2697
|
+
{
|
|
2698
|
+
variant: "transparent",
|
|
2699
|
+
size: "small",
|
|
2700
|
+
onClick: (e) => {
|
|
2701
|
+
e.stopPropagation();
|
|
2702
|
+
navigate(`/orders/${t.order_id}`);
|
|
2703
|
+
},
|
|
2704
|
+
children: "Order"
|
|
2705
|
+
}
|
|
2706
|
+
) : null
|
|
2707
|
+
] })
|
|
2708
|
+
]
|
|
2709
|
+
},
|
|
2710
|
+
t.payment_session_id
|
|
2711
|
+
)) })
|
|
2712
|
+
] }) }),
|
|
2713
|
+
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
2714
|
+
Button,
|
|
2715
|
+
{
|
|
2716
|
+
variant: "secondary",
|
|
2717
|
+
isLoading: isFetchingMore,
|
|
2718
|
+
onClick: () => loadTransactions(offset, false),
|
|
2719
|
+
children: "Load more"
|
|
2720
|
+
}
|
|
2721
|
+
) }) : null
|
|
2722
|
+
] }) });
|
|
2723
|
+
};
|
|
2724
|
+
const config$6 = defineRouteConfig({
|
|
2725
|
+
label: "Payments",
|
|
2726
|
+
icon: CreditCard
|
|
2727
|
+
});
|
|
2728
|
+
const useDebounce$1 = (value, delay) => {
|
|
2729
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
2730
|
+
useEffect(() => {
|
|
2731
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
2732
|
+
return () => clearTimeout(handler);
|
|
2733
|
+
}, [value, delay]);
|
|
2734
|
+
return debouncedValue;
|
|
2735
|
+
};
|
|
2736
|
+
const getStatusBadgeClass$5 = (status) => {
|
|
2737
|
+
const statusLower = status.toLowerCase();
|
|
2738
|
+
if (statusLower === "requested") {
|
|
2739
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2740
|
+
}
|
|
2741
|
+
if (statusLower === "received") {
|
|
2742
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2743
|
+
}
|
|
2744
|
+
if (statusLower === "requires_action") {
|
|
2745
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2746
|
+
}
|
|
2747
|
+
if (statusLower === "completed") {
|
|
2748
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2749
|
+
}
|
|
2750
|
+
if (statusLower === "canceled") {
|
|
2751
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2752
|
+
}
|
|
2753
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2754
|
+
};
|
|
2755
|
+
const ReturnsPage = () => {
|
|
2756
|
+
const navigate = useNavigate();
|
|
2757
|
+
const [items, setItems] = useState([]);
|
|
2758
|
+
const [statusFilter, setStatusFilter] = useState("all");
|
|
2759
|
+
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
2760
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
2761
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
2762
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
2763
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
2764
|
+
const [error, setError] = useState(null);
|
|
2765
|
+
const [offset, setOffset] = useState(0);
|
|
2766
|
+
const [count, setCount] = useState(0);
|
|
2767
|
+
const limit = 50;
|
|
2768
|
+
const loadReturns = useCallback(
|
|
2769
|
+
async (nextOffset, replace = false) => {
|
|
2770
|
+
var _a;
|
|
2771
|
+
try {
|
|
2772
|
+
if (replace) {
|
|
2773
|
+
setIsLoading(true);
|
|
1466
2774
|
} else {
|
|
1467
2775
|
setIsFetchingMore(true);
|
|
1468
2776
|
}
|
|
@@ -1490,7 +2798,7 @@ const ReturnsPage = () => {
|
|
|
1490
2798
|
}
|
|
1491
2799
|
const payload = await response.json();
|
|
1492
2800
|
setCount(payload.count ?? 0);
|
|
1493
|
-
setOffset(nextOffset + (payload.returns
|
|
2801
|
+
setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
|
|
1494
2802
|
setItems(
|
|
1495
2803
|
(prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
|
|
1496
2804
|
);
|
|
@@ -1602,7 +2910,7 @@ const ReturnsPage = () => {
|
|
|
1602
2910
|
) }),
|
|
1603
2911
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1604
2912
|
const calc = returnOrder.refund;
|
|
1605
|
-
if (calc
|
|
2913
|
+
if ((calc == null ? void 0 : calc.is_processed) && calc.final_refund_amount != null) {
|
|
1606
2914
|
return formatRefundCurrency(
|
|
1607
2915
|
calc.final_refund_amount,
|
|
1608
2916
|
calc.currency_code || returnOrder.currency_code
|
|
@@ -1701,6 +3009,7 @@ const SwapsPage = () => {
|
|
|
1701
3009
|
const limit = 50;
|
|
1702
3010
|
const loadSwaps = useCallback(
|
|
1703
3011
|
async (nextOffset, replace = false) => {
|
|
3012
|
+
var _a;
|
|
1704
3013
|
try {
|
|
1705
3014
|
if (replace) {
|
|
1706
3015
|
setIsLoading(true);
|
|
@@ -1730,7 +3039,7 @@ const SwapsPage = () => {
|
|
|
1730
3039
|
}
|
|
1731
3040
|
const payload = await response.json();
|
|
1732
3041
|
setCount(payload.count ?? 0);
|
|
1733
|
-
setOffset(nextOffset + (payload.swaps
|
|
3042
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1734
3043
|
setItems(
|
|
1735
3044
|
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1736
3045
|
);
|
|
@@ -1888,52 +3197,989 @@ const config$4 = defineRouteConfig({
|
|
|
1888
3197
|
label: "Exchanges",
|
|
1889
3198
|
icon: ArrowPath
|
|
1890
3199
|
});
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
3200
|
+
const MASKED_VALUE = "••••••••••••";
|
|
3201
|
+
const SENSITIVE_KEY_PATTERNS = [
|
|
3202
|
+
/password|passwd|passphrase/i,
|
|
3203
|
+
/secret/i,
|
|
3204
|
+
/token/i,
|
|
3205
|
+
/api_?key$/i,
|
|
3206
|
+
/private_?key/i,
|
|
3207
|
+
/access_?key/i,
|
|
3208
|
+
/(^|_)hash(ed)?($|_)/i,
|
|
3209
|
+
/(^|_)salt$/i,
|
|
3210
|
+
/^cvv$|^cvc$|security_code/i,
|
|
3211
|
+
/card_?number/i,
|
|
3212
|
+
/account_?number/i,
|
|
3213
|
+
/credential/i,
|
|
3214
|
+
/authorization/i,
|
|
3215
|
+
/recovery_?code/i,
|
|
3216
|
+
/(^|_)otp($|_)/i,
|
|
3217
|
+
/verification_?code/i,
|
|
3218
|
+
/^code_hash$/i,
|
|
3219
|
+
/webhook_?signature/i
|
|
3220
|
+
];
|
|
3221
|
+
const TABLE_SENSITIVE_KEYS = {
|
|
3222
|
+
otp_verification: /* @__PURE__ */ new Set(["code", "value"]),
|
|
3223
|
+
auth_verification: /* @__PURE__ */ new Set(["code", "value"]),
|
|
3224
|
+
auth_mfa_factor: /* @__PURE__ */ new Set(["value", "config"])
|
|
1898
3225
|
};
|
|
1899
|
-
const
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
3226
|
+
const SAFE_KEYS = /* @__PURE__ */ new Set([
|
|
3227
|
+
"token_type",
|
|
3228
|
+
"redacted",
|
|
3229
|
+
"api_key_id",
|
|
3230
|
+
"token_id",
|
|
3231
|
+
"notification_token_id"
|
|
3232
|
+
]);
|
|
3233
|
+
function isSensitiveKey(key) {
|
|
3234
|
+
const normalized = key.trim().toLowerCase();
|
|
3235
|
+
if (SAFE_KEYS.has(normalized)) return false;
|
|
3236
|
+
return SENSITIVE_KEY_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
3237
|
+
}
|
|
3238
|
+
const FULLY_SECRET_TABLES = /* @__PURE__ */ new Set(["auth_mfa_recovery_code", "auth_password_reset_token"]);
|
|
3239
|
+
const ALWAYS_VISIBLE_KEYS = /* @__PURE__ */ new Set(["id", "created_at", "updated_at", "deleted_at", "expires_at", "used_at"]);
|
|
3240
|
+
function maskValue(value, ctx, depth) {
|
|
3241
|
+
var _a;
|
|
3242
|
+
if (Array.isArray(value)) return value.map((item) => maskValue(item, ctx, depth + 1));
|
|
3243
|
+
if (value !== null && typeof value === "object") {
|
|
3244
|
+
const out = {};
|
|
3245
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
3246
|
+
const topLevel = depth === 0;
|
|
3247
|
+
const secret = inner !== null && inner !== void 0 && inner !== "" && (isSensitiveKey(key) || topLevel && ((_a = ctx.tableKeys) == null ? void 0 : _a.has(key.toLowerCase())) === true || topLevel && ctx.maskAll && !ALWAYS_VISIBLE_KEYS.has(key) && !key.endsWith("_id"));
|
|
3248
|
+
if (secret) {
|
|
3249
|
+
ctx.count += 1;
|
|
3250
|
+
out[key] = MASKED_VALUE;
|
|
3251
|
+
} else {
|
|
3252
|
+
out[key] = maskValue(inner, ctx, depth + 1);
|
|
3253
|
+
}
|
|
1910
3254
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
const
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
/* @__PURE__ */ jsx(
|
|
1936
|
-
/* @__PURE__ */ jsx(
|
|
3255
|
+
return out;
|
|
3256
|
+
}
|
|
3257
|
+
return value;
|
|
3258
|
+
}
|
|
3259
|
+
function maskSensitiveData(data, tableName) {
|
|
3260
|
+
const ctx = {
|
|
3261
|
+
count: 0,
|
|
3262
|
+
maskAll: tableName ? FULLY_SECRET_TABLES.has(tableName) : false,
|
|
3263
|
+
tableKeys: tableName ? TABLE_SENSITIVE_KEYS[tableName] : void 0
|
|
3264
|
+
};
|
|
3265
|
+
const value = maskValue(data, ctx, 0);
|
|
3266
|
+
return { value, maskedCount: ctx.count };
|
|
3267
|
+
}
|
|
3268
|
+
const AUTO_EXPAND_DEPTH = 1;
|
|
3269
|
+
const LONG_STRING = 200;
|
|
3270
|
+
const JsonViewer = ({ data }) => {
|
|
3271
|
+
const [generation, setGeneration] = useState(0);
|
|
3272
|
+
const [expandAll, setExpandAll] = useState(null);
|
|
3273
|
+
const setAll = (value) => {
|
|
3274
|
+
setExpandAll(value);
|
|
3275
|
+
setGeneration((g) => g + 1);
|
|
3276
|
+
};
|
|
3277
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3278
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3279
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(true), children: "Expand all" }),
|
|
3280
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => setAll(false), children: "Collapse all" })
|
|
3281
|
+
] }),
|
|
3282
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[560px] overflow-auto rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 font-mono text-xs leading-5", children: /* @__PURE__ */ jsx(JsonNode, { value: data, depth: 0, forceExpand: expandAll }, generation) })
|
|
3283
|
+
] });
|
|
3284
|
+
};
|
|
3285
|
+
const JsonNode = ({ name, value, depth, forceExpand }) => {
|
|
3286
|
+
const isContainer = value !== null && typeof value === "object";
|
|
3287
|
+
const [open, setOpen] = useState(forceExpand ?? depth < AUTO_EXPAND_DEPTH);
|
|
3288
|
+
const label = name !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "text-ui-fg-subtle", children: [
|
|
3289
|
+
name,
|
|
3290
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: ": " })
|
|
3291
|
+
] }) : null;
|
|
3292
|
+
if (!isContainer) {
|
|
3293
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start", style: { paddingLeft: depth ? 16 : 0 }, children: [
|
|
3294
|
+
/* @__PURE__ */ jsx("span", { className: "w-4 shrink-0" }),
|
|
3295
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 break-words [overflow-wrap:anywhere]", children: [
|
|
3296
|
+
label,
|
|
3297
|
+
/* @__PURE__ */ jsx(Primitive, { value })
|
|
3298
|
+
] })
|
|
3299
|
+
] });
|
|
3300
|
+
}
|
|
3301
|
+
const entries = Array.isArray(value) ? value.map((v, i) => [String(i), v]) : Object.entries(value);
|
|
3302
|
+
const [openBracket, closeBracket] = Array.isArray(value) ? ["[", "]"] : ["{", "}"];
|
|
3303
|
+
const summary = Array.isArray(value) ? `${entries.length} items` : `${entries.length} keys`;
|
|
3304
|
+
return /* @__PURE__ */ jsxs("div", { style: { paddingLeft: depth ? 16 : 0 }, children: [
|
|
3305
|
+
/* @__PURE__ */ jsxs(
|
|
3306
|
+
"button",
|
|
3307
|
+
{
|
|
3308
|
+
type: "button",
|
|
3309
|
+
onClick: () => setOpen((o) => !o),
|
|
3310
|
+
className: "flex items-start text-left hover:bg-ui-bg-base-hover",
|
|
3311
|
+
"aria-expanded": open,
|
|
3312
|
+
children: [
|
|
3313
|
+
/* @__PURE__ */ jsx("span", { className: "flex w-4 shrink-0 items-center pt-0.5 text-ui-fg-muted", children: entries.length ? open ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}) : null }),
|
|
3314
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
3315
|
+
label,
|
|
3316
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: openBracket }),
|
|
3317
|
+
!open || entries.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3318
|
+
entries.length ? /* @__PURE__ */ jsx("span", { className: "px-1 italic text-ui-fg-muted", children: summary }) : null,
|
|
3319
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: closeBracket })
|
|
3320
|
+
] }) : null
|
|
3321
|
+
] })
|
|
3322
|
+
]
|
|
3323
|
+
}
|
|
3324
|
+
),
|
|
3325
|
+
open && entries.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3326
|
+
entries.map(([key, child]) => /* @__PURE__ */ jsx(JsonNode, { name: key, value: child, depth: depth + 1, forceExpand }, key)),
|
|
3327
|
+
/* @__PURE__ */ jsx("div", { style: { paddingLeft: 16 }, className: "text-ui-fg-muted", children: closeBracket })
|
|
3328
|
+
] }) : null
|
|
3329
|
+
] });
|
|
3330
|
+
};
|
|
3331
|
+
const Primitive = ({ value }) => {
|
|
3332
|
+
const [showFull, setShowFull] = useState(false);
|
|
3333
|
+
if (value === MASKED_VALUE) {
|
|
3334
|
+
return /* @__PURE__ */ jsx("span", { className: "rounded bg-ui-tag-orange-bg px-1 text-ui-tag-orange-text", title: "Hidden for security", children: MASKED_VALUE });
|
|
3335
|
+
}
|
|
3336
|
+
if (value === null || value === void 0) return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "null" });
|
|
3337
|
+
if (typeof value === "boolean") return /* @__PURE__ */ jsx("span", { className: "text-ui-tag-purple-text", children: String(value) });
|
|
3338
|
+
if (typeof value === "number") return /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-text", children: value });
|
|
3339
|
+
const text = String(value);
|
|
3340
|
+
const truncated = !showFull && text.length > LONG_STRING;
|
|
3341
|
+
return /* @__PURE__ */ jsxs("span", { className: clx("text-ui-tag-green-text"), children: [
|
|
3342
|
+
'"',
|
|
3343
|
+
truncated ? `${text.slice(0, LONG_STRING)}…` : text,
|
|
3344
|
+
'"',
|
|
3345
|
+
text.length > LONG_STRING ? /* @__PURE__ */ jsx(
|
|
3346
|
+
"button",
|
|
3347
|
+
{
|
|
3348
|
+
type: "button",
|
|
3349
|
+
onClick: () => setShowFull((s2) => !s2),
|
|
3350
|
+
className: "ml-1 font-sans text-ui-fg-interactive hover:underline",
|
|
3351
|
+
children: showFull ? "show less" : `show all (${text.length} chars)`
|
|
3352
|
+
}
|
|
3353
|
+
) : null
|
|
3354
|
+
] });
|
|
3355
|
+
};
|
|
3356
|
+
const GUIDANCE = {
|
|
3357
|
+
orders: {
|
|
3358
|
+
headline: "Order data affects customers, payments and reports.",
|
|
3359
|
+
recreate: "Orders can’t be recreated identically from the admin. If this deletion was not intended, ask a developer to restore it from a database backup using the snapshot on this page.",
|
|
3360
|
+
adminSection: { label: "Go to Orders", path: "/orders" }
|
|
3361
|
+
},
|
|
3362
|
+
carts: {
|
|
3363
|
+
headline: "Carts are usually cleaned up automatically.",
|
|
3364
|
+
recreate: "No action is normally needed. Customers can simply add items to a new cart."
|
|
3365
|
+
},
|
|
3366
|
+
customers: {
|
|
3367
|
+
headline: "Customer data may be needed for orders, support and compliance.",
|
|
3368
|
+
recreate: "If it was deleted by mistake, recreate it from Customers using the values shown above. A recreated customer gets a new ID and must reset their password.",
|
|
3369
|
+
adminSection: { label: "Go to Customers", path: "/customers" }
|
|
3370
|
+
},
|
|
3371
|
+
catalog: {
|
|
3372
|
+
headline: "Catalog changes affect what customers can see and buy.",
|
|
3373
|
+
recreate: "If it was deleted by mistake, recreate it from Products using the values shown above. It will get a new ID.",
|
|
3374
|
+
adminSection: { label: "Go to Products", path: "/products" }
|
|
3375
|
+
},
|
|
3376
|
+
pricing: {
|
|
3377
|
+
headline: "Pricing and promotions affect what customers pay.",
|
|
3378
|
+
recreate: "If it was deleted by mistake, recreate it from Promotions or Price Lists using the values shown above.",
|
|
3379
|
+
adminSection: { label: "Go to Promotions", path: "/promotions" }
|
|
3380
|
+
},
|
|
3381
|
+
payments: {
|
|
3382
|
+
headline: "Payment records are financial data.",
|
|
3383
|
+
recreate: "Do not recreate payment records by hand—this can make balances inconsistent. If this deletion was not expected, escalate to a developer or your finance team."
|
|
3384
|
+
},
|
|
3385
|
+
fulfillment: {
|
|
3386
|
+
headline: "Shipping and fulfillment settings affect checkout and delivery.",
|
|
3387
|
+
recreate: "If it was deleted by mistake, recreate it from Settings → Locations & Shipping using the values shown above.",
|
|
3388
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3389
|
+
},
|
|
3390
|
+
inventory: {
|
|
3391
|
+
headline: "Inventory changes can affect stock levels and availability.",
|
|
3392
|
+
recreate: "If it was deleted by mistake, recreate it from Inventory using the values shown above and re-check stock quantities.",
|
|
3393
|
+
adminSection: { label: "Go to Inventory", path: "/inventory" }
|
|
3394
|
+
},
|
|
3395
|
+
wallet: {
|
|
3396
|
+
headline: "Wallet and credit records are financial data.",
|
|
3397
|
+
recreate: "Do not recreate balances by hand. If this deletion was not expected, escalate to a developer or your finance team so balances can be verified."
|
|
3398
|
+
},
|
|
3399
|
+
access: {
|
|
3400
|
+
headline: "Access records control who can sign in.",
|
|
3401
|
+
recreate: "Secrets such as passwords and keys can’t be restored. Re-invite the user or create a new API key if access is still needed.",
|
|
3402
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3403
|
+
},
|
|
3404
|
+
store: {
|
|
3405
|
+
headline: "Store settings affect regions, currencies and taxes.",
|
|
3406
|
+
recreate: "If it was deleted by mistake, recreate it from Settings using the values shown above.",
|
|
3407
|
+
adminSection: { label: "Go to Settings", path: "/settings" }
|
|
3408
|
+
},
|
|
3409
|
+
engagement: {
|
|
3410
|
+
headline: "Customer-generated content.",
|
|
3411
|
+
recreate: "These usually can’t be recreated on the customer’s behalf. Keep the snapshot on this page if you need a record of it."
|
|
3412
|
+
},
|
|
3413
|
+
notifications: {
|
|
3414
|
+
headline: "Notification records are usually cleaned up automatically.",
|
|
3415
|
+
recreate: "No action is normally needed."
|
|
3416
|
+
},
|
|
3417
|
+
system: {
|
|
3418
|
+
headline: "Internal system data, usually removed automatically by the platform.",
|
|
3419
|
+
recreate: "No action is normally needed. If you suspect a problem, share this page with a developer."
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
function getNextSteps(category) {
|
|
3423
|
+
return GUIDANCE[category];
|
|
3424
|
+
}
|
|
3425
|
+
const RELATED_LINKS = [
|
|
3426
|
+
{ key: "order_id", label: "Order", path: (id) => `/orders/${id}`, selfTables: ["order"] },
|
|
3427
|
+
{ key: "customer_id", label: "Customer", path: (id) => `/customers/${id}`, selfTables: ["customer"] },
|
|
3428
|
+
{ key: "product_id", label: "Product", path: (id) => `/products/${id}`, selfTables: ["product"] }
|
|
3429
|
+
];
|
|
3430
|
+
function getRelatedLinks(tableName, oldData) {
|
|
3431
|
+
if (!oldData) return [];
|
|
3432
|
+
return RELATED_LINKS.flatMap((link) => {
|
|
3433
|
+
const id = oldData[link.key];
|
|
3434
|
+
if (link.selfTables.includes(tableName) || typeof id !== "string" || !id.trim()) return [];
|
|
3435
|
+
return [{ label: link.label, id, path: link.path(id) }];
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
const fullName = (row) => {
|
|
3439
|
+
const parts = [row.first_name, row.last_name].filter(
|
|
3440
|
+
(part) => typeof part === "string" && part.trim() !== ""
|
|
3441
|
+
);
|
|
3442
|
+
return parts.length ? parts.join(" ") : void 0;
|
|
3443
|
+
};
|
|
3444
|
+
const addressLine = (row) => {
|
|
3445
|
+
const parts = [row.address_1, row.address_2, row.city, row.province, row.postal_code, row.country_code].filter((part) => typeof part === "string" && part.trim() !== "").map((part) => part.trim());
|
|
3446
|
+
return parts.length ? parts.join(", ") : void 0;
|
|
3447
|
+
};
|
|
3448
|
+
const NAME = { key: "name", label: "Name", derive: fullName };
|
|
3449
|
+
const ADDRESS = { key: "address", label: "Address", derive: addressLine };
|
|
3450
|
+
const CREATED = { key: "created_at", label: "Created", kind: "date" };
|
|
3451
|
+
const ENTITY_FIELDS = {
|
|
3452
|
+
order: [
|
|
3453
|
+
{ key: "display_id", label: "Order number" },
|
|
3454
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3455
|
+
{ key: "email", label: "Customer email" },
|
|
3456
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3457
|
+
{ key: "currency_code", label: "Currency" },
|
|
3458
|
+
{ key: "region_id", label: "Region ID", kind: "id" },
|
|
3459
|
+
{ key: "sales_channel_id", label: "Sales channel ID", kind: "id" },
|
|
3460
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
3461
|
+
CREATED
|
|
3462
|
+
],
|
|
3463
|
+
order_line_item: [
|
|
3464
|
+
{ key: "title", label: "Item" },
|
|
3465
|
+
{ key: "variant_title", label: "Variant" },
|
|
3466
|
+
{ key: "variant_sku", label: "SKU" },
|
|
3467
|
+
{ key: "unit_price", label: "Unit price", kind: "money" },
|
|
3468
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3469
|
+
{ key: "variant_id", label: "Variant ID", kind: "id" },
|
|
3470
|
+
CREATED
|
|
3471
|
+
],
|
|
3472
|
+
cart_line_item: [
|
|
3473
|
+
{ key: "title", label: "Item" },
|
|
3474
|
+
{ key: "variant_sku", label: "SKU" },
|
|
3475
|
+
{ key: "quantity", label: "Quantity", kind: "number" },
|
|
3476
|
+
{ key: "unit_price", label: "Unit price", kind: "money" },
|
|
3477
|
+
{ key: "cart_id", label: "Cart ID", kind: "id" },
|
|
3478
|
+
{ key: "variant_id", label: "Variant ID", kind: "id" },
|
|
3479
|
+
CREATED
|
|
3480
|
+
],
|
|
3481
|
+
cart: [
|
|
3482
|
+
{ key: "email", label: "Email" },
|
|
3483
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3484
|
+
{ key: "currency_code", label: "Currency" },
|
|
3485
|
+
{ key: "region_id", label: "Region ID", kind: "id" },
|
|
3486
|
+
{ key: "completed_at", label: "Completed", kind: "date" },
|
|
3487
|
+
CREATED
|
|
3488
|
+
],
|
|
3489
|
+
customer: [
|
|
3490
|
+
NAME,
|
|
3491
|
+
{ key: "email", label: "Email" },
|
|
3492
|
+
{ key: "phone", label: "Phone" },
|
|
3493
|
+
{ key: "company_name", label: "Company" },
|
|
3494
|
+
{ key: "has_account", label: "Registered account", kind: "boolean" },
|
|
3495
|
+
CREATED
|
|
3496
|
+
],
|
|
3497
|
+
customer_address: [
|
|
3498
|
+
{ key: "address_name", label: "Label" },
|
|
3499
|
+
NAME,
|
|
3500
|
+
ADDRESS,
|
|
3501
|
+
{ key: "phone", label: "Phone" },
|
|
3502
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3503
|
+
{ key: "is_default_shipping", label: "Default shipping", kind: "boolean" },
|
|
3504
|
+
CREATED
|
|
3505
|
+
],
|
|
3506
|
+
order_address: [NAME, ADDRESS, { key: "phone", label: "Phone" }, CREATED],
|
|
3507
|
+
cart_address: [NAME, ADDRESS, { key: "phone", label: "Phone" }, CREATED],
|
|
3508
|
+
product: [
|
|
3509
|
+
{ key: "title", label: "Title" },
|
|
3510
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3511
|
+
{ key: "handle", label: "Handle" },
|
|
3512
|
+
{ key: "subtitle", label: "Subtitle" },
|
|
3513
|
+
{ key: "collection_id", label: "Collection ID", kind: "id" },
|
|
3514
|
+
{ key: "is_giftcard", label: "Gift card", kind: "boolean" },
|
|
3515
|
+
CREATED
|
|
3516
|
+
],
|
|
3517
|
+
product_variant: [
|
|
3518
|
+
{ key: "title", label: "Title" },
|
|
3519
|
+
{ key: "sku", label: "SKU" },
|
|
3520
|
+
{ key: "barcode", label: "Barcode" },
|
|
3521
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3522
|
+
{ key: "manage_inventory", label: "Manages inventory", kind: "boolean" },
|
|
3523
|
+
CREATED
|
|
3524
|
+
],
|
|
3525
|
+
product_category: [
|
|
3526
|
+
{ key: "name", label: "Name" },
|
|
3527
|
+
{ key: "handle", label: "Handle" },
|
|
3528
|
+
{ key: "is_active", label: "Active", kind: "boolean" },
|
|
3529
|
+
{ key: "parent_category_id", label: "Parent category ID", kind: "id" },
|
|
3530
|
+
CREATED
|
|
3531
|
+
],
|
|
3532
|
+
product_collection: [{ key: "title", label: "Title" }, { key: "handle", label: "Handle" }, CREATED],
|
|
3533
|
+
payment: [
|
|
3534
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
3535
|
+
{ key: "currency_code", label: "Currency" },
|
|
3536
|
+
{ key: "provider_id", label: "Provider" },
|
|
3537
|
+
{ key: "captured_at", label: "Captured", kind: "date" },
|
|
3538
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
3539
|
+
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
3540
|
+
CREATED
|
|
3541
|
+
],
|
|
3542
|
+
payment_session: [
|
|
3543
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
3544
|
+
{ key: "currency_code", label: "Currency" },
|
|
3545
|
+
{ key: "provider_id", label: "Provider" },
|
|
3546
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3547
|
+
{ key: "payment_collection_id", label: "Payment collection ID", kind: "id" },
|
|
3548
|
+
CREATED
|
|
3549
|
+
],
|
|
3550
|
+
payment_collection: [
|
|
3551
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
3552
|
+
{ key: "currency_code", label: "Currency" },
|
|
3553
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3554
|
+
CREATED
|
|
3555
|
+
],
|
|
3556
|
+
refund: [
|
|
3557
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
3558
|
+
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
3559
|
+
{ key: "refund_reason_id", label: "Refund reason ID", kind: "id" },
|
|
3560
|
+
{ key: "note", label: "Note" },
|
|
3561
|
+
{ key: "created_by", label: "Created by" },
|
|
3562
|
+
CREATED
|
|
3563
|
+
],
|
|
3564
|
+
return: [
|
|
3565
|
+
{ key: "display_id", label: "Return number" },
|
|
3566
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3567
|
+
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
3568
|
+
{ key: "refund_amount", label: "Refund amount", kind: "money" },
|
|
3569
|
+
{ key: "received_at", label: "Received", kind: "date" },
|
|
3570
|
+
CREATED
|
|
3571
|
+
],
|
|
3572
|
+
payment_detail: [
|
|
3573
|
+
{ key: "type", label: "Method type" },
|
|
3574
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3575
|
+
{ key: "is_default", label: "Default method", kind: "boolean" },
|
|
3576
|
+
CREATED
|
|
3577
|
+
],
|
|
3578
|
+
user: [NAME, { key: "email", label: "Email" }, CREATED],
|
|
3579
|
+
invite: [
|
|
3580
|
+
{ key: "email", label: "Email" },
|
|
3581
|
+
{ key: "accepted", label: "Accepted", kind: "boolean" },
|
|
3582
|
+
{ key: "expires_at", label: "Expires", kind: "date" },
|
|
3583
|
+
CREATED
|
|
3584
|
+
],
|
|
3585
|
+
api_key: [
|
|
3586
|
+
{ key: "title", label: "Title" },
|
|
3587
|
+
{ key: "type", label: "Type" },
|
|
3588
|
+
{ key: "redacted", label: "Key (redacted)" },
|
|
3589
|
+
{ key: "revoked_at", label: "Revoked", kind: "date" },
|
|
3590
|
+
CREATED
|
|
3591
|
+
],
|
|
3592
|
+
promotion: [
|
|
3593
|
+
{ key: "code", label: "Promotion code" },
|
|
3594
|
+
{ key: "type", label: "Type" },
|
|
3595
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3596
|
+
{ key: "is_automatic", label: "Automatic", kind: "boolean" },
|
|
3597
|
+
CREATED
|
|
3598
|
+
],
|
|
3599
|
+
fulfillment: [
|
|
3600
|
+
{ key: "provider_id", label: "Provider" },
|
|
3601
|
+
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
3602
|
+
{ key: "shipped_at", label: "Shipped", kind: "date" },
|
|
3603
|
+
{ key: "delivered_at", label: "Delivered", kind: "date" },
|
|
3604
|
+
{ key: "canceled_at", label: "Canceled", kind: "date" },
|
|
3605
|
+
CREATED
|
|
3606
|
+
],
|
|
3607
|
+
inventory_item: [
|
|
3608
|
+
{ key: "sku", label: "SKU" },
|
|
3609
|
+
{ key: "title", label: "Title" },
|
|
3610
|
+
{ key: "requires_shipping", label: "Requires shipping", kind: "boolean" },
|
|
3611
|
+
CREATED
|
|
3612
|
+
],
|
|
3613
|
+
inventory_level: [
|
|
3614
|
+
{ key: "inventory_item_id", label: "Inventory item ID", kind: "id" },
|
|
3615
|
+
{ key: "location_id", label: "Location ID", kind: "id" },
|
|
3616
|
+
{ key: "stocked_quantity", label: "Stocked", kind: "number" },
|
|
3617
|
+
{ key: "reserved_quantity", label: "Reserved", kind: "number" },
|
|
3618
|
+
CREATED
|
|
3619
|
+
],
|
|
3620
|
+
review: [
|
|
3621
|
+
{ key: "title", label: "Title" },
|
|
3622
|
+
{ key: "rating", label: "Rating", kind: "number" },
|
|
3623
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3624
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3625
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3626
|
+
CREATED
|
|
3627
|
+
]
|
|
3628
|
+
};
|
|
3629
|
+
const GENERIC_FIELDS = [
|
|
3630
|
+
{ key: "display_id", label: "Number" },
|
|
3631
|
+
{ key: "title", label: "Title" },
|
|
3632
|
+
{ key: "name", label: "Name" },
|
|
3633
|
+
NAME,
|
|
3634
|
+
{ key: "email", label: "Email" },
|
|
3635
|
+
{ key: "phone", label: "Phone" },
|
|
3636
|
+
{ key: "handle", label: "Handle" },
|
|
3637
|
+
{ key: "sku", label: "SKU" },
|
|
3638
|
+
{ key: "code", label: "Code" },
|
|
3639
|
+
{ key: "status", label: "Status", kind: "status" },
|
|
3640
|
+
{ key: "type", label: "Type" },
|
|
3641
|
+
{ key: "amount", label: "Amount", kind: "money" },
|
|
3642
|
+
{ key: "quantity", label: "Quantity", kind: "number" },
|
|
3643
|
+
{ key: "currency_code", label: "Currency" },
|
|
3644
|
+
{ key: "order_id", label: "Order ID", kind: "id" },
|
|
3645
|
+
{ key: "customer_id", label: "Customer ID", kind: "id" },
|
|
3646
|
+
{ key: "product_id", label: "Product ID", kind: "id" },
|
|
3647
|
+
{ key: "payment_id", label: "Payment ID", kind: "id" },
|
|
3648
|
+
{ key: "provider_id", label: "Provider" },
|
|
3649
|
+
CREATED,
|
|
3650
|
+
{ key: "updated_at", label: "Last updated", kind: "date" }
|
|
3651
|
+
];
|
|
3652
|
+
const MAX_GENERIC_FIELDS = 8;
|
|
3653
|
+
function amountOf(value) {
|
|
3654
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
3655
|
+
if (typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
|
|
3656
|
+
if (value !== null && typeof value === "object" && "value" in value) {
|
|
3657
|
+
return amountOf(value.value);
|
|
3658
|
+
}
|
|
3659
|
+
return null;
|
|
3660
|
+
}
|
|
3661
|
+
function formatValue(raw, kind, row) {
|
|
3662
|
+
if (raw === null || raw === void 0 || raw === "") return null;
|
|
3663
|
+
if (raw === MASKED_VALUE) return { value: MASKED_VALUE, kind: "masked" };
|
|
3664
|
+
switch (kind) {
|
|
3665
|
+
case "money": {
|
|
3666
|
+
const amount = amountOf(raw);
|
|
3667
|
+
if (amount === null) return null;
|
|
3668
|
+
const currency = typeof row.currency_code === "string" ? row.currency_code : null;
|
|
3669
|
+
return { value: formatMoney(amount, currency), kind };
|
|
3670
|
+
}
|
|
3671
|
+
case "date":
|
|
3672
|
+
return typeof raw === "string" || raw instanceof Date ? { value: formatDate(raw), kind } : null;
|
|
3673
|
+
case "boolean":
|
|
3674
|
+
return { value: raw === true || raw === "true" ? "Yes" : "No", kind };
|
|
3675
|
+
case "number": {
|
|
3676
|
+
const n = amountOf(raw);
|
|
3677
|
+
return n === null ? null : { value: formatNumber(n), kind };
|
|
3678
|
+
}
|
|
3679
|
+
case "status":
|
|
3680
|
+
return { value: String(raw).replace(/_/g, " "), kind };
|
|
3681
|
+
default:
|
|
3682
|
+
if (typeof raw === "object") return null;
|
|
3683
|
+
if (typeof raw === "string" && raw.length > 160) return { value: `${raw.slice(0, 157)}…`, kind };
|
|
3684
|
+
return { value: String(raw), kind };
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
function summarizeOldData(tableName, oldData) {
|
|
3688
|
+
if (!oldData) return [];
|
|
3689
|
+
const { value: row } = maskSensitiveData(oldData, tableName);
|
|
3690
|
+
const specific = ENTITY_FIELDS[tableName];
|
|
3691
|
+
const specs = specific ?? GENERIC_FIELDS;
|
|
3692
|
+
const fields = [];
|
|
3693
|
+
const seenLabels = /* @__PURE__ */ new Set();
|
|
3694
|
+
for (const spec of specs) {
|
|
3695
|
+
const raw = spec.derive ? spec.derive(row) : row[spec.key];
|
|
3696
|
+
const formatted = formatValue(raw, spec.kind ?? "text", row);
|
|
3697
|
+
if (!formatted || seenLabels.has(spec.label)) continue;
|
|
3698
|
+
seenLabels.add(spec.label);
|
|
3699
|
+
const value = spec.key === "currency_code" ? formatted.value.toUpperCase() : formatted.value;
|
|
3700
|
+
fields.push({ key: spec.key, label: spec.label, value, kind: formatted.kind });
|
|
3701
|
+
if (!specific && fields.length >= MAX_GENERIC_FIELDS) break;
|
|
3702
|
+
}
|
|
3703
|
+
return fields;
|
|
3704
|
+
}
|
|
3705
|
+
function readLastListSearch() {
|
|
3706
|
+
try {
|
|
3707
|
+
return window.sessionStorage.getItem(LAST_LIST_URL_KEY) ?? "";
|
|
3708
|
+
} catch {
|
|
3709
|
+
return "";
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
const DeletedRecordDetailPage = () => {
|
|
3713
|
+
var _a;
|
|
3714
|
+
const navigate = useNavigate();
|
|
3715
|
+
const location = useLocation();
|
|
3716
|
+
const { id = "" } = useParams();
|
|
3717
|
+
const [state, setState] = useState({ status: "loading" });
|
|
3718
|
+
const [reloadToken, setReloadToken] = useState(0);
|
|
3719
|
+
const cameFromList = ((_a = location.state) == null ? void 0 : _a.fromList) === true;
|
|
3720
|
+
const goBack = () => {
|
|
3721
|
+
if (cameFromList) navigate(-1);
|
|
3722
|
+
else navigate(`/deleted-records-audit${readLastListSearch()}`);
|
|
3723
|
+
};
|
|
3724
|
+
useEffect(() => {
|
|
3725
|
+
const controller = new AbortController();
|
|
3726
|
+
setState({ status: "loading" });
|
|
3727
|
+
fetchAuditDetail(id, controller.signal).then((audit) => setState({ status: "ready", audit })).catch((e) => {
|
|
3728
|
+
if (controller.signal.aborted) return;
|
|
3729
|
+
setState({
|
|
3730
|
+
status: "error",
|
|
3731
|
+
message: e instanceof Error ? e.message : "Unknown error",
|
|
3732
|
+
notFound: e instanceof AuditApiError && e.status === 404
|
|
3733
|
+
});
|
|
3734
|
+
});
|
|
3735
|
+
return () => controller.abort();
|
|
3736
|
+
}, [id, reloadToken]);
|
|
3737
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-3 md:p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 md:p-6", children: [
|
|
3738
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "transparent", size: "small", onClick: goBack, className: "-ml-2", children: [
|
|
3739
|
+
/* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
3740
|
+
"Back to Deleted Records"
|
|
3741
|
+
] }) }),
|
|
3742
|
+
state.status === "loading" ? /* @__PURE__ */ jsx(DetailSkeleton, {}) : state.status === "error" ? /* @__PURE__ */ jsx(
|
|
3743
|
+
DetailError,
|
|
3744
|
+
{
|
|
3745
|
+
notFound: state.notFound,
|
|
3746
|
+
message: state.message,
|
|
3747
|
+
onRetry: () => setReloadToken((t) => t + 1),
|
|
3748
|
+
onBack: goBack
|
|
3749
|
+
}
|
|
3750
|
+
) : /* @__PURE__ */ jsx(DetailContent, { audit: state.audit })
|
|
3751
|
+
] }) });
|
|
3752
|
+
};
|
|
3753
|
+
const DetailContent = ({ audit }) => {
|
|
3754
|
+
const navigate = useNavigate();
|
|
3755
|
+
const entity = getEntityInfo(audit.table_name);
|
|
3756
|
+
const source = describeSource(audit.source);
|
|
3757
|
+
const summary = useMemo(() => summarizeOldData(audit.table_name, audit.old_data), [audit]);
|
|
3758
|
+
const masked = useMemo(() => maskSensitiveData(audit.old_data, audit.table_name), [audit]);
|
|
3759
|
+
const guidance = getNextSteps(entity.category.id);
|
|
3760
|
+
const related = getRelatedLinks(audit.table_name, audit.old_data);
|
|
3761
|
+
const [showRaw, setShowRaw] = useState(false);
|
|
3762
|
+
const copyJson = async () => {
|
|
3763
|
+
try {
|
|
3764
|
+
await navigator.clipboard.writeText(JSON.stringify(masked.value, null, 2));
|
|
3765
|
+
toast.success("Record data copied", {
|
|
3766
|
+
description: masked.maskedCount ? "Sensitive values were left hidden." : void 0
|
|
3767
|
+
});
|
|
3768
|
+
} catch {
|
|
3769
|
+
toast.error("Couldn’t copy to clipboard");
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3773
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
3774
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3775
|
+
/* @__PURE__ */ jsxs(Badge, { size: "small", color: "red", children: [
|
|
3776
|
+
/* @__PURE__ */ jsx(Trash, {}),
|
|
3777
|
+
"Deleted"
|
|
3778
|
+
] }),
|
|
3779
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: entity.category.label })
|
|
3780
|
+
] }),
|
|
3781
|
+
/* @__PURE__ */ jsxs(Heading, { level: "h1", children: [
|
|
3782
|
+
"Deleted ",
|
|
3783
|
+
entity.label
|
|
3784
|
+
] }),
|
|
3785
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3786
|
+
/* @__PURE__ */ jsx(CopyableId, { value: audit.record_id, emptyLabel: "This record type has no ID column", className: "text-sm" }),
|
|
3787
|
+
/* @__PURE__ */ jsxs(Text, { size: "xsmall", className: "text-ui-fg-muted", children: [
|
|
3788
|
+
"Database table: ",
|
|
3789
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono", children: audit.table_name })
|
|
3790
|
+
] })
|
|
3791
|
+
] })
|
|
3792
|
+
] }),
|
|
3793
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-lg border border-ui-tag-orange-border bg-ui-tag-orange-bg px-4 py-3", children: [
|
|
3794
|
+
/* @__PURE__ */ jsx(InformationCircle, { className: "mt-0.5 shrink-0 text-ui-tag-orange-icon" }),
|
|
3795
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-tag-orange-text", children: [
|
|
3796
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "This is a historical snapshot" }),
|
|
3797
|
+
" captured immediately before deletion. The record no longer exists in the database, so changes elsewhere in the admin are not reflected here."
|
|
3798
|
+
] })
|
|
3799
|
+
] }),
|
|
3800
|
+
/* @__PURE__ */ jsx(Section, { title: "Deletion information", children: /* @__PURE__ */ jsxs("dl", { className: "grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2", children: [
|
|
3801
|
+
/* @__PURE__ */ jsx(Field, { label: "Deleted", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
3802
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: formatExactDateTime(audit.occurred_at) }),
|
|
3803
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-ui-fg-muted", children: [
|
|
3804
|
+
/* @__PURE__ */ jsx(ClockSolid, { className: "size-3" }),
|
|
3805
|
+
formatRelativeTime(audit.occurred_at)
|
|
3806
|
+
] })
|
|
3807
|
+
] }) }),
|
|
3808
|
+
/* @__PURE__ */ jsx(Field, { label: "Deleted by", children: audit.deleted_by ? /* @__PURE__ */ jsx("span", { className: "break-all text-sm text-ui-fg-base", children: audit.deleted_by }) : /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Not recorded" }) }),
|
|
3809
|
+
/* @__PURE__ */ jsx(Field, { label: "Source", children: source.kind === "unknown" ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Unknown" }) : /* @__PURE__ */ jsx(Badge, { size: "small", color: sourceBadgeColor(source.kind), children: source.label }) }),
|
|
3810
|
+
/* @__PURE__ */ jsx(Field, { label: "Action", children: /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Permanently deleted" }) })
|
|
3811
|
+
] }) }),
|
|
3812
|
+
/* @__PURE__ */ jsx(
|
|
3813
|
+
Section,
|
|
3814
|
+
{
|
|
3815
|
+
title: "Record summary",
|
|
3816
|
+
description: `Key details of this ${entity.label.toLowerCase()} at the moment it was deleted.`,
|
|
3817
|
+
children: summary.length ? /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2", children: summary.map((field) => /* @__PURE__ */ jsx(Field, { label: field.label, children: field.kind === "id" ? /* @__PURE__ */ jsx(CopyableId, { value: field.value }) : field.kind === "status" ? /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "grey", className: "capitalize", children: field.value }) : field.kind === "masked" ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-muted", children: "Hidden for security" }) : /* @__PURE__ */ jsx("span", { className: "break-words text-sm text-ui-fg-base", children: field.value }) }, field.label)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No key details could be extracted for this record type. See the original record data below." })
|
|
3818
|
+
}
|
|
3819
|
+
),
|
|
3820
|
+
/* @__PURE__ */ jsx(
|
|
3821
|
+
Section,
|
|
3822
|
+
{
|
|
3823
|
+
title: "Original record data",
|
|
3824
|
+
description: "The complete data captured before deletion.",
|
|
3825
|
+
actions: showRaw && audit.old_data ? /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: copyJson, children: [
|
|
3826
|
+
/* @__PURE__ */ jsx(SquareTwoStack, {}),
|
|
3827
|
+
"Copy JSON"
|
|
3828
|
+
] }) : null,
|
|
3829
|
+
children: audit.old_data ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3830
|
+
masked.maskedCount > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3831
|
+
/* @__PURE__ */ jsx(ShieldCheck, { className: "shrink-0 text-ui-fg-muted" }),
|
|
3832
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
3833
|
+
masked.maskedCount,
|
|
3834
|
+
" sensitive ",
|
|
3835
|
+
masked.maskedCount === 1 ? "value is" : "values are",
|
|
3836
|
+
" hidden for security (passwords, tokens, card or account numbers)."
|
|
3837
|
+
] })
|
|
3838
|
+
] }) : null,
|
|
3839
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "small", onClick: () => setShowRaw((s2) => !s2), "aria-expanded": showRaw, children: [
|
|
3840
|
+
showRaw ? /* @__PURE__ */ jsx(ChevronDownMini, {}) : /* @__PURE__ */ jsx(ChevronRightMini, {}),
|
|
3841
|
+
showRaw ? "Hide full record" : "View full record"
|
|
3842
|
+
] }) }),
|
|
3843
|
+
showRaw ? /* @__PURE__ */ jsx(JsonViewer, { data: masked.value }) : null
|
|
3844
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No data was captured for this deletion." })
|
|
3845
|
+
}
|
|
3846
|
+
),
|
|
3847
|
+
/* @__PURE__ */ jsx(Section, { title: "What you can do now", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
3848
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-base", children: [
|
|
3849
|
+
"This record was permanently deleted. ",
|
|
3850
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Automatic restoration is not available" }),
|
|
3851
|
+
" ",
|
|
3852
|
+
"from this screen."
|
|
3853
|
+
] }),
|
|
3854
|
+
/* @__PURE__ */ jsxs("ol", { className: "flex list-decimal flex-col gap-3 pl-5 text-sm text-ui-fg-subtle marker:text-ui-fg-muted", children: [
|
|
3855
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
3856
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Check whether this was expected." }),
|
|
3857
|
+
" ",
|
|
3858
|
+
audit.deleted_by || source.kind !== "unknown" ? "Confirm with the person or system shown above." : `Who deleted it wasn’t recorded—check with your team or integrations active around ${formatExactDateTime(audit.occurred_at)}.`,
|
|
3859
|
+
" ",
|
|
3860
|
+
guidance.headline
|
|
3861
|
+
] }),
|
|
3862
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
3863
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "If it needs to come back:" }),
|
|
3864
|
+
" ",
|
|
3865
|
+
guidance.recreate
|
|
3866
|
+
] }),
|
|
3867
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
3868
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Need the details?" }),
|
|
3869
|
+
" Use “View full record” above to see or copy everything that was stored. Sensitive values stay hidden."
|
|
3870
|
+
] })
|
|
3871
|
+
] }),
|
|
3872
|
+
guidance.adminSection || related.length ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
3873
|
+
guidance.adminSection ? /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: () => navigate(guidance.adminSection.path), children: guidance.adminSection.label }) : null,
|
|
3874
|
+
related.map((link) => /* @__PURE__ */ jsxs(
|
|
3875
|
+
Button,
|
|
3876
|
+
{
|
|
3877
|
+
variant: "transparent",
|
|
3878
|
+
size: "small",
|
|
3879
|
+
onClick: () => navigate(link.path),
|
|
3880
|
+
title: `Opens ${link.label.toLowerCase()} ${link.id} if it still exists`,
|
|
3881
|
+
children: [
|
|
3882
|
+
"Open related ",
|
|
3883
|
+
link.label.toLowerCase(),
|
|
3884
|
+
/* @__PURE__ */ jsx(ChevronRightMini, {})
|
|
3885
|
+
]
|
|
3886
|
+
},
|
|
3887
|
+
link.path
|
|
3888
|
+
))
|
|
3889
|
+
] }) : null,
|
|
3890
|
+
related.length ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted", children: "Related records open only if they haven’t been deleted too." }) : null
|
|
3891
|
+
] }) })
|
|
3892
|
+
] });
|
|
3893
|
+
};
|
|
3894
|
+
const Section = ({
|
|
3895
|
+
title,
|
|
3896
|
+
description,
|
|
3897
|
+
actions,
|
|
3898
|
+
children
|
|
3899
|
+
}) => /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
|
|
3900
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
3901
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
3902
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: title }),
|
|
3903
|
+
description ? /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: description }) : null
|
|
3904
|
+
] }),
|
|
3905
|
+
actions
|
|
3906
|
+
] }),
|
|
3907
|
+
children
|
|
3908
|
+
] });
|
|
3909
|
+
const Field = ({ label, children }) => /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
3910
|
+
/* @__PURE__ */ jsx("dt", { className: "text-xs font-medium uppercase tracking-wide text-ui-fg-muted", children: label }),
|
|
3911
|
+
/* @__PURE__ */ jsx("dd", { className: "min-w-0", children })
|
|
3912
|
+
] });
|
|
3913
|
+
const DetailSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", "aria-busy": "true", children: [
|
|
3914
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3915
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24 rounded-full" }),
|
|
3916
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-64" }),
|
|
3917
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-48" })
|
|
3918
|
+
] }),
|
|
3919
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-full" }),
|
|
3920
|
+
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
|
|
3921
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-40" }),
|
|
3922
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: Array.from({ length: 4 }).map((__, j) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
3923
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-20" }),
|
|
3924
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-36" })
|
|
3925
|
+
] }, j)) })
|
|
3926
|
+
] }, i))
|
|
3927
|
+
] });
|
|
3928
|
+
const DetailError = ({
|
|
3929
|
+
notFound,
|
|
3930
|
+
message,
|
|
3931
|
+
onRetry,
|
|
3932
|
+
onBack
|
|
3933
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-ui-border-base px-6 py-12 text-center", children: [
|
|
3934
|
+
/* @__PURE__ */ jsx(ExclamationCircle, { className: clx(notFound ? "text-ui-fg-muted" : "text-ui-fg-error") }),
|
|
3935
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: notFound ? "Audit entry not found" : "Unable to load this deleted record" }),
|
|
3936
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: notFound ? "This audit entry doesn’t exist. The link may be incorrect." : "We couldn’t retrieve the audit entry right now. Check your connection and try again." }),
|
|
3937
|
+
!notFound ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
|
|
3938
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-2", children: [
|
|
3939
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
|
|
3940
|
+
!notFound ? /* @__PURE__ */ jsx(Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
|
|
3941
|
+
] })
|
|
3942
|
+
] });
|
|
3943
|
+
defineRouteConfig({});
|
|
3944
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
3945
|
+
const s2 = status.toLowerCase();
|
|
3946
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
3947
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
3948
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
3949
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
3950
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
3951
|
+
};
|
|
3952
|
+
const formatAmount = (value) => {
|
|
3953
|
+
return String(value);
|
|
3954
|
+
};
|
|
3955
|
+
const RefundDetailPage = () => {
|
|
3956
|
+
var _a, _b, _c;
|
|
3957
|
+
const navigate = useNavigate();
|
|
3958
|
+
const params = useParams();
|
|
3959
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
3960
|
+
const [detail, setDetail] = useState(null);
|
|
3961
|
+
const [loading, setLoading] = useState(!!id);
|
|
3962
|
+
const [error, setError] = useState(null);
|
|
3963
|
+
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
3964
|
+
useEffect(() => {
|
|
3965
|
+
if (!id) {
|
|
3966
|
+
setLoading(false);
|
|
3967
|
+
return;
|
|
3968
|
+
}
|
|
3969
|
+
let cancelled = false;
|
|
3970
|
+
setLoading(true);
|
|
3971
|
+
setError(null);
|
|
3972
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
3973
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
3974
|
+
return res.json();
|
|
3975
|
+
}).then((data) => {
|
|
3976
|
+
if (!cancelled) setDetail(data);
|
|
3977
|
+
}).catch((e) => {
|
|
3978
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
3979
|
+
}).finally(() => {
|
|
3980
|
+
if (!cancelled) setLoading(false);
|
|
3981
|
+
});
|
|
3982
|
+
return () => {
|
|
3983
|
+
cancelled = true;
|
|
3984
|
+
};
|
|
3985
|
+
}, [id]);
|
|
3986
|
+
const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
|
|
3987
|
+
const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
3988
|
+
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: [
|
|
3989
|
+
/* @__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: [
|
|
3990
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
3991
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
|
|
3992
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
3993
|
+
] }) }),
|
|
3994
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
3995
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
3996
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
3997
|
+
] }) : loading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
3998
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
3999
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
4000
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4001
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4002
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
4003
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
4004
|
+
] }),
|
|
4005
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4006
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
4007
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
4008
|
+
] }),
|
|
4009
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4010
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
4011
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
4012
|
+
] }),
|
|
4013
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4014
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
4015
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
4016
|
+
year: "numeric",
|
|
4017
|
+
month: "short",
|
|
4018
|
+
day: "numeric",
|
|
4019
|
+
hour: "numeric",
|
|
4020
|
+
minute: "2-digit",
|
|
4021
|
+
hour12: true
|
|
4022
|
+
}) })
|
|
4023
|
+
] }),
|
|
4024
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
4025
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
4026
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
4027
|
+
] }) : null
|
|
4028
|
+
] })
|
|
4029
|
+
] }),
|
|
4030
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4031
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
4032
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4033
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4034
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
4035
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
4036
|
+
] }),
|
|
4037
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4038
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
4039
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
4040
|
+
] }),
|
|
4041
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4042
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
4043
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
4044
|
+
] }),
|
|
4045
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4046
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
4047
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
4048
|
+
] }),
|
|
4049
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4050
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
4051
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
4052
|
+
Badge,
|
|
4053
|
+
{
|
|
4054
|
+
size: "2xsmall",
|
|
4055
|
+
className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
|
|
4056
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
4057
|
+
}
|
|
4058
|
+
) })
|
|
4059
|
+
] }),
|
|
4060
|
+
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4061
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4062
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
4063
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
4064
|
+
] }),
|
|
4065
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4066
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
4067
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
4068
|
+
] }),
|
|
4069
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4070
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
4071
|
+
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
4072
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
4073
|
+
"%"
|
|
4074
|
+
] })
|
|
4075
|
+
] })
|
|
4076
|
+
] }) : null
|
|
4077
|
+
] })
|
|
4078
|
+
] }),
|
|
4079
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4080
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
4081
|
+
detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4082
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4083
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
4084
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
4085
|
+
Button,
|
|
4086
|
+
{
|
|
4087
|
+
variant: "transparent",
|
|
4088
|
+
size: "small",
|
|
4089
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
4090
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
4091
|
+
}
|
|
4092
|
+
) })
|
|
4093
|
+
] }),
|
|
4094
|
+
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
4095
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
4096
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
4097
|
+
] }) : null,
|
|
4098
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
4099
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
4100
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
4101
|
+
] }) : null,
|
|
4102
|
+
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
4103
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
4104
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
4105
|
+
] }) : null,
|
|
4106
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
4107
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
4108
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
4109
|
+
] }) : null
|
|
4110
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
4111
|
+
] }),
|
|
4112
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4113
|
+
/* @__PURE__ */ jsxs(
|
|
4114
|
+
"button",
|
|
4115
|
+
{
|
|
4116
|
+
type: "button",
|
|
4117
|
+
className: "flex w-full items-center justify-between text-left",
|
|
4118
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
4119
|
+
"aria-expanded": gatewayExpanded,
|
|
4120
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
4121
|
+
children: [
|
|
4122
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
4123
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
4124
|
+
]
|
|
4125
|
+
}
|
|
4126
|
+
),
|
|
4127
|
+
gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
4128
|
+
] })
|
|
4129
|
+
] }) : null
|
|
4130
|
+
] }) });
|
|
4131
|
+
};
|
|
4132
|
+
const config$3 = defineRouteConfig({
|
|
4133
|
+
label: "Refund details",
|
|
4134
|
+
icon: Receipt
|
|
4135
|
+
});
|
|
4136
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
4137
|
+
const s2 = status.toLowerCase();
|
|
4138
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4139
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4140
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
4141
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4142
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
4143
|
+
};
|
|
4144
|
+
const PaymentDetailPage = () => {
|
|
4145
|
+
var _a;
|
|
4146
|
+
const navigate = useNavigate();
|
|
4147
|
+
const params = useParams();
|
|
4148
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
4149
|
+
const [detail, setDetail] = useState(null);
|
|
4150
|
+
const [loading, setLoading] = useState(!!id);
|
|
4151
|
+
const [error, setError] = useState(null);
|
|
4152
|
+
useEffect(() => {
|
|
4153
|
+
if (!id) {
|
|
4154
|
+
setLoading(false);
|
|
4155
|
+
return;
|
|
4156
|
+
}
|
|
4157
|
+
let cancelled = false;
|
|
4158
|
+
setLoading(true);
|
|
4159
|
+
setError(null);
|
|
4160
|
+
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
4161
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
4162
|
+
return res.json();
|
|
4163
|
+
}).then((data) => {
|
|
4164
|
+
if (!cancelled) setDetail(data);
|
|
4165
|
+
}).catch((e) => {
|
|
4166
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
4167
|
+
}).finally(() => {
|
|
4168
|
+
if (!cancelled) setLoading(false);
|
|
4169
|
+
});
|
|
4170
|
+
return () => {
|
|
4171
|
+
cancelled = true;
|
|
4172
|
+
};
|
|
4173
|
+
}, [id]);
|
|
4174
|
+
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
4175
|
+
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
4176
|
+
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
4177
|
+
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
4178
|
+
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: [
|
|
4179
|
+
/* @__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: [
|
|
4180
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
4181
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
|
|
4182
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
1937
4183
|
] }) }),
|
|
1938
4184
|
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1939
4185
|
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
@@ -1966,7 +4212,7 @@ const PaymentDetailPage = () => {
|
|
|
1966
4212
|
Badge,
|
|
1967
4213
|
{
|
|
1968
4214
|
size: "2xsmall",
|
|
1969
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4215
|
+
className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
|
|
1970
4216
|
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
1971
4217
|
}
|
|
1972
4218
|
) })
|
|
@@ -2002,11 +4248,11 @@ const PaymentDetailPage = () => {
|
|
|
2002
4248
|
] }) : null
|
|
2003
4249
|
] }) });
|
|
2004
4250
|
};
|
|
2005
|
-
const config$
|
|
4251
|
+
const config$2 = defineRouteConfig({
|
|
2006
4252
|
label: "Payment details",
|
|
2007
4253
|
icon: CreditCard
|
|
2008
4254
|
});
|
|
2009
|
-
const getStatusBadgeClass$
|
|
4255
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
2010
4256
|
const statusLower = status.toLowerCase();
|
|
2011
4257
|
if (statusLower === "requested") {
|
|
2012
4258
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2017,104 +4263,109 @@ const getStatusBadgeClass$2 = (status) => {
|
|
|
2017
4263
|
if (statusLower === "rejected") {
|
|
2018
4264
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2019
4265
|
}
|
|
2020
|
-
if (statusLower === "received") {
|
|
2021
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2022
|
-
}
|
|
2023
|
-
if (statusLower === "refunded") {
|
|
2024
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2025
|
-
}
|
|
2026
4266
|
if (statusLower === "completed") {
|
|
2027
4267
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2028
4268
|
}
|
|
2029
|
-
if (statusLower === "cancelled") {
|
|
4269
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2030
4270
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2031
4271
|
}
|
|
4272
|
+
if (statusLower === "pending") {
|
|
4273
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4274
|
+
}
|
|
2032
4275
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2033
4276
|
};
|
|
2034
|
-
const
|
|
4277
|
+
const SwapDetailPage = () => {
|
|
4278
|
+
var _a, _b, _c;
|
|
2035
4279
|
const navigate = useNavigate();
|
|
2036
4280
|
const { id } = useParams();
|
|
2037
|
-
const [
|
|
4281
|
+
const [swap, setSwap] = useState(null);
|
|
4282
|
+
const [order, setOrder] = useState(null);
|
|
2038
4283
|
const [isLoading, setIsLoading] = useState(true);
|
|
2039
|
-
|
|
4284
|
+
useState(false);
|
|
4285
|
+
const [isCancelling, setIsCancelling] = useState(false);
|
|
2040
4286
|
const [error, setError] = useState(null);
|
|
2041
4287
|
const [updateError, setUpdateError] = useState(null);
|
|
2042
4288
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2043
4289
|
useEffect(() => {
|
|
2044
4290
|
if (!id) {
|
|
2045
|
-
navigate("/
|
|
4291
|
+
navigate("/swaps");
|
|
2046
4292
|
return;
|
|
2047
4293
|
}
|
|
2048
|
-
const
|
|
4294
|
+
const loadSwap = async () => {
|
|
2049
4295
|
try {
|
|
2050
4296
|
setIsLoading(true);
|
|
2051
4297
|
setError(null);
|
|
2052
|
-
const response = await fetch(`/admin/
|
|
4298
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2053
4299
|
credentials: "include"
|
|
2054
4300
|
});
|
|
2055
4301
|
if (!response.ok) {
|
|
2056
4302
|
const message = await response.text();
|
|
2057
|
-
throw new Error(message || "Unable to load
|
|
4303
|
+
throw new Error(message || "Unable to load swap");
|
|
2058
4304
|
}
|
|
2059
4305
|
const payload = await response.json();
|
|
2060
|
-
|
|
4306
|
+
setSwap(payload.swap);
|
|
4307
|
+
setOrder(payload.order || null);
|
|
2061
4308
|
} catch (loadError) {
|
|
2062
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
4309
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2063
4310
|
setError(message);
|
|
2064
4311
|
} finally {
|
|
2065
4312
|
setIsLoading(false);
|
|
2066
4313
|
}
|
|
2067
4314
|
};
|
|
2068
|
-
void
|
|
4315
|
+
void loadSwap();
|
|
2069
4316
|
}, [id, navigate]);
|
|
2070
|
-
const
|
|
4317
|
+
const handleCancelExchange = async () => {
|
|
2071
4318
|
if (!id) {
|
|
2072
4319
|
return;
|
|
2073
4320
|
}
|
|
2074
4321
|
try {
|
|
2075
|
-
|
|
4322
|
+
setIsCancelling(true);
|
|
2076
4323
|
setUpdateError(null);
|
|
2077
4324
|
setUpdateSuccess(false);
|
|
2078
|
-
const response = await fetch(`/admin/
|
|
4325
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2079
4326
|
method: "POST",
|
|
2080
4327
|
headers: {
|
|
2081
4328
|
"Content-Type": "application/json"
|
|
2082
4329
|
},
|
|
2083
|
-
credentials: "include"
|
|
2084
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
4330
|
+
credentials: "include"
|
|
2085
4331
|
});
|
|
2086
4332
|
if (!response.ok) {
|
|
2087
4333
|
const message = await response.text();
|
|
2088
|
-
throw new Error(message || "Unable to
|
|
4334
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2089
4335
|
}
|
|
2090
4336
|
const payload = await response.json();
|
|
2091
|
-
|
|
4337
|
+
setSwap(payload.swap);
|
|
2092
4338
|
setUpdateSuccess(true);
|
|
2093
4339
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2094
|
-
const detailResponse = await fetch(`/admin/
|
|
4340
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2095
4341
|
credentials: "include"
|
|
2096
4342
|
});
|
|
2097
4343
|
if (detailResponse.ok) {
|
|
2098
4344
|
const detailPayload = await detailResponse.json();
|
|
2099
|
-
|
|
4345
|
+
setSwap(detailPayload.swap);
|
|
4346
|
+
setOrder(detailPayload.order || null);
|
|
2100
4347
|
}
|
|
2101
|
-
} catch (
|
|
2102
|
-
const message =
|
|
4348
|
+
} catch (cancelErr) {
|
|
4349
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2103
4350
|
setUpdateError(message);
|
|
2104
4351
|
} finally {
|
|
2105
|
-
|
|
4352
|
+
setIsCancelling(false);
|
|
2106
4353
|
}
|
|
2107
4354
|
};
|
|
4355
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
4356
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
4357
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
4358
|
+
);
|
|
2108
4359
|
if (isLoading) {
|
|
2109
|
-
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
|
|
4360
|
+
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..." }) }) }) });
|
|
2110
4361
|
}
|
|
2111
|
-
if (error || !
|
|
4362
|
+
if (error || !swap) {
|
|
2112
4363
|
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__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2113
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2114
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
4364
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
4365
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2115
4366
|
] }) }) });
|
|
2116
4367
|
}
|
|
2117
|
-
const statusHistory =
|
|
4368
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2118
4369
|
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: [
|
|
2119
4370
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2120
4371
|
/* @__PURE__ */ jsxs(
|
|
@@ -2122,7 +4373,7 @@ const ReturnDetailPage = () => {
|
|
|
2122
4373
|
{
|
|
2123
4374
|
variant: "transparent",
|
|
2124
4375
|
size: "small",
|
|
2125
|
-
onClick: () => navigate("/
|
|
4376
|
+
onClick: () => navigate("/swaps"),
|
|
2126
4377
|
className: "w-fit",
|
|
2127
4378
|
children: [
|
|
2128
4379
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2132,82 +4383,67 @@ const ReturnDetailPage = () => {
|
|
|
2132
4383
|
),
|
|
2133
4384
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2134
4385
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2135
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2136
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
4386
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
4387
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2137
4388
|
] }),
|
|
2138
4389
|
/* @__PURE__ */ jsx(
|
|
2139
4390
|
Badge,
|
|
2140
4391
|
{
|
|
2141
4392
|
size: "small",
|
|
2142
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2143
|
-
children:
|
|
4393
|
+
className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
|
|
4394
|
+
children: swap.status.replace(/_/g, " ")
|
|
2144
4395
|
}
|
|
2145
4396
|
)
|
|
2146
4397
|
] })
|
|
2147
4398
|
] }),
|
|
2148
|
-
|
|
4399
|
+
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2149
4400
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2150
|
-
Button,
|
|
2151
|
-
{
|
|
2152
|
-
variant: "danger",
|
|
2153
|
-
onClick:
|
|
2154
|
-
disabled:
|
|
2155
|
-
isLoading:
|
|
2156
|
-
children: "
|
|
2157
|
-
}
|
|
2158
|
-
) }),
|
|
2159
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2160
|
-
] }),
|
|
2161
|
-
returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
|
|
2162
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2163
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2164
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2165
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2166
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2167
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2168
|
-
] }),
|
|
2169
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2170
|
-
Button,
|
|
2171
|
-
{
|
|
2172
|
-
variant: "secondary",
|
|
2173
|
-
onClick: () => {
|
|
2174
|
-
window.open(
|
|
2175
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
2176
|
-
"_blank"
|
|
2177
|
-
);
|
|
2178
|
-
},
|
|
2179
|
-
children: "View order"
|
|
2180
|
-
}
|
|
2181
|
-
) })
|
|
2182
|
-
] })
|
|
4401
|
+
Button,
|
|
4402
|
+
{
|
|
4403
|
+
variant: "danger",
|
|
4404
|
+
onClick: handleCancelExchange,
|
|
4405
|
+
disabled: isCancelling,
|
|
4406
|
+
isLoading: isCancelling,
|
|
4407
|
+
children: "Cancel Exchange"
|
|
4408
|
+
}
|
|
4409
|
+
) }),
|
|
4410
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2183
4411
|
] }),
|
|
2184
4412
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2185
4413
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2186
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
4414
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2187
4415
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2188
4416
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2189
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2190
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4417
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
4418
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
2191
4419
|
] }),
|
|
2192
4420
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2193
4421
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2194
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4422
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
2195
4423
|
] }),
|
|
2196
|
-
|
|
4424
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4425
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
4426
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
4427
|
+
] }),
|
|
4428
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2197
4429
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2198
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4430
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
2199
4431
|
] }),
|
|
2200
|
-
|
|
4432
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2201
4433
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2202
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4434
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
2203
4435
|
] }),
|
|
2204
4436
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2205
4437
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2206
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
4438
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2207
4439
|
] }),
|
|
2208
4440
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2209
4441
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2210
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
4442
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
4443
|
+
] }),
|
|
4444
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
4445
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
4446
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2211
4447
|
] })
|
|
2212
4448
|
] })
|
|
2213
4449
|
] }),
|
|
@@ -2222,7 +4458,7 @@ const ReturnDetailPage = () => {
|
|
|
2222
4458
|
Badge,
|
|
2223
4459
|
{
|
|
2224
4460
|
size: "2xsmall",
|
|
2225
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4461
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
2226
4462
|
children: entry.status.replace(/_/g, " ")
|
|
2227
4463
|
}
|
|
2228
4464
|
) }),
|
|
@@ -2237,247 +4473,63 @@ const ReturnDetailPage = () => {
|
|
|
2237
4473
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2238
4474
|
] })
|
|
2239
4475
|
] }),
|
|
2240
|
-
|
|
4476
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2241
4477
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2242
4478
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2243
4479
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2244
4480
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2245
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4481
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2246
4482
|
] }),
|
|
2247
4483
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2248
4484
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2249
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4485
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2250
4486
|
] }),
|
|
2251
4487
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2252
4488
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2253
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4489
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2254
4490
|
] }),
|
|
2255
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2256
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
|
|
2257
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.order_payment?.label || "—" })
|
|
2258
|
-
] }),
|
|
2259
|
-
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
4491
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2260
4492
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2261
4493
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2262
|
-
|
|
2263
|
-
(Number(
|
|
4494
|
+
order.currency_code || "$",
|
|
4495
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2264
4496
|
] })
|
|
2265
4497
|
] })
|
|
2266
4498
|
] })
|
|
2267
4499
|
] }),
|
|
2268
|
-
|
|
4500
|
+
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2269
4501
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2270
4502
|
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2271
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2272
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2273
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2274
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2275
|
-
] }) }),
|
|
2276
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2277
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2278
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2279
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2280
|
-
] }, item.id || index)) })
|
|
2281
|
-
] }) })
|
|
2282
|
-
] }),
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2297
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2298
|
-
};
|
|
2299
|
-
const formatAmount = (value) => {
|
|
2300
|
-
return String(value);
|
|
2301
|
-
};
|
|
2302
|
-
const RefundDetailPage = () => {
|
|
2303
|
-
const navigate = useNavigate();
|
|
2304
|
-
const params = useParams();
|
|
2305
|
-
const id = params?.id?.trim();
|
|
2306
|
-
const [detail, setDetail] = useState(null);
|
|
2307
|
-
const [loading, setLoading] = useState(!!id);
|
|
2308
|
-
const [error, setError] = useState(null);
|
|
2309
|
-
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
2310
|
-
useEffect(() => {
|
|
2311
|
-
if (!id) {
|
|
2312
|
-
setLoading(false);
|
|
2313
|
-
return;
|
|
2314
|
-
}
|
|
2315
|
-
let cancelled = false;
|
|
2316
|
-
setLoading(true);
|
|
2317
|
-
setError(null);
|
|
2318
|
-
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
2319
|
-
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2320
|
-
return res.json();
|
|
2321
|
-
}).then((data) => {
|
|
2322
|
-
if (!cancelled) setDetail(data);
|
|
2323
|
-
}).catch((e) => {
|
|
2324
|
-
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2325
|
-
}).finally(() => {
|
|
2326
|
-
if (!cancelled) setLoading(false);
|
|
2327
|
-
});
|
|
2328
|
-
return () => {
|
|
2329
|
-
cancelled = true;
|
|
2330
|
-
};
|
|
2331
|
-
}, [id]);
|
|
2332
|
-
const paymentStatus = detail?.payment?.status ?? "—";
|
|
2333
|
-
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
2334
|
-
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: [
|
|
2335
|
-
/* @__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: [
|
|
2336
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
2337
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
|
|
2338
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
2339
|
-
] }) }),
|
|
2340
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2341
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2342
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
2343
|
-
] }) : loading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2344
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2345
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
2346
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2347
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2348
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
2349
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
2350
|
-
] }),
|
|
2351
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2352
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2353
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
2354
|
-
] }),
|
|
2355
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2356
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
2357
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
2358
|
-
] }),
|
|
2359
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2360
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
2361
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
2362
|
-
year: "numeric",
|
|
2363
|
-
month: "short",
|
|
2364
|
-
day: "numeric",
|
|
2365
|
-
hour: "numeric",
|
|
2366
|
-
minute: "2-digit",
|
|
2367
|
-
hour12: true
|
|
2368
|
-
}) })
|
|
2369
|
-
] }),
|
|
2370
|
-
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2371
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
2372
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
2373
|
-
] }) : null
|
|
2374
|
-
] })
|
|
2375
|
-
] }),
|
|
2376
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2377
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
2378
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2379
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2380
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
2381
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
2382
|
-
] }),
|
|
2383
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2384
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
2385
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
2386
|
-
] }),
|
|
2387
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2388
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
2389
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
2390
|
-
] }),
|
|
2391
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2392
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2393
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
2394
|
-
] }),
|
|
2395
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2396
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2397
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2398
|
-
Badge,
|
|
2399
|
-
{
|
|
2400
|
-
size: "2xsmall",
|
|
2401
|
-
className: `uppercase ${getStatusBadgeClass$1(paymentStatus)}`,
|
|
2402
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2403
|
-
}
|
|
2404
|
-
) })
|
|
2405
|
-
] }),
|
|
2406
|
-
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2407
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2408
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
2409
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
2410
|
-
] }),
|
|
2411
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2412
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2413
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2414
|
-
] }),
|
|
2415
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2416
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2417
|
-
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2418
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
2419
|
-
"%"
|
|
2420
|
-
] })
|
|
2421
|
-
] })
|
|
2422
|
-
] }) : null
|
|
2423
|
-
] })
|
|
2424
|
-
] }),
|
|
2425
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2426
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
2427
|
-
detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2428
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2429
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2430
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2431
|
-
Button,
|
|
2432
|
-
{
|
|
2433
|
-
variant: "transparent",
|
|
2434
|
-
size: "small",
|
|
2435
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2436
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
2437
|
-
}
|
|
2438
|
-
) })
|
|
2439
|
-
] }),
|
|
2440
|
-
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2441
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2442
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2443
|
-
] }) : null,
|
|
2444
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2445
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2446
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2447
|
-
] }) : null,
|
|
2448
|
-
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2449
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2450
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2451
|
-
] }) : null,
|
|
2452
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2453
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2454
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2455
|
-
] }) : null
|
|
2456
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2457
|
-
] }),
|
|
2458
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2459
|
-
/* @__PURE__ */ jsxs(
|
|
2460
|
-
"button",
|
|
2461
|
-
{
|
|
2462
|
-
type: "button",
|
|
2463
|
-
className: "flex w-full items-center justify-between text-left",
|
|
2464
|
-
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
2465
|
-
"aria-expanded": gatewayExpanded,
|
|
2466
|
-
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
2467
|
-
children: [
|
|
2468
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
2469
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
2470
|
-
]
|
|
2471
|
-
}
|
|
2472
|
-
),
|
|
2473
|
-
gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
2474
|
-
] })
|
|
2475
|
-
] }) : null
|
|
4503
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4504
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
4505
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
4506
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
4507
|
+
] }) }),
|
|
4508
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
4509
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
4510
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
4511
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
4512
|
+
] }, item.id || index)) })
|
|
4513
|
+
] }) })
|
|
4514
|
+
] }),
|
|
4515
|
+
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
4516
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
4517
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
4518
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4519
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
4520
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
4521
|
+
] }) }),
|
|
4522
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
4523
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
4524
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
4525
|
+
] }, item.variant_id || index)) })
|
|
4526
|
+
] }) })
|
|
4527
|
+
] })
|
|
2476
4528
|
] }) });
|
|
2477
4529
|
};
|
|
2478
4530
|
const config$1 = defineRouteConfig({
|
|
2479
|
-
label: "
|
|
2480
|
-
icon:
|
|
4531
|
+
label: "Swap Details",
|
|
4532
|
+
icon: ArrowPath
|
|
2481
4533
|
});
|
|
2482
4534
|
const getStatusBadgeClass = (status) => {
|
|
2483
4535
|
const statusLower = status.toLowerCase();
|
|
@@ -2490,108 +4542,105 @@ const getStatusBadgeClass = (status) => {
|
|
|
2490
4542
|
if (statusLower === "rejected") {
|
|
2491
4543
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2492
4544
|
}
|
|
4545
|
+
if (statusLower === "received") {
|
|
4546
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4547
|
+
}
|
|
4548
|
+
if (statusLower === "refunded") {
|
|
4549
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4550
|
+
}
|
|
2493
4551
|
if (statusLower === "completed") {
|
|
2494
4552
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2495
4553
|
}
|
|
2496
|
-
if (statusLower === "cancelled"
|
|
4554
|
+
if (statusLower === "cancelled") {
|
|
2497
4555
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2498
4556
|
}
|
|
2499
|
-
if (statusLower === "pending") {
|
|
2500
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2501
|
-
}
|
|
2502
4557
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2503
4558
|
};
|
|
2504
|
-
const
|
|
4559
|
+
const ReturnDetailPage = () => {
|
|
4560
|
+
var _a, _b, _c;
|
|
2505
4561
|
const navigate = useNavigate();
|
|
2506
4562
|
const { id } = useParams();
|
|
2507
|
-
const [
|
|
2508
|
-
const [order, setOrder] = useState(null);
|
|
4563
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
2509
4564
|
const [isLoading, setIsLoading] = useState(true);
|
|
2510
4565
|
const [isRejecting, setIsRejecting] = useState(false);
|
|
2511
|
-
const [isCancelling, setIsCancelling] = useState(false);
|
|
2512
4566
|
const [error, setError] = useState(null);
|
|
2513
4567
|
const [updateError, setUpdateError] = useState(null);
|
|
2514
4568
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2515
4569
|
useEffect(() => {
|
|
2516
4570
|
if (!id) {
|
|
2517
|
-
navigate("/
|
|
4571
|
+
navigate("/returns");
|
|
2518
4572
|
return;
|
|
2519
4573
|
}
|
|
2520
|
-
const
|
|
4574
|
+
const loadReturn = async () => {
|
|
2521
4575
|
try {
|
|
2522
4576
|
setIsLoading(true);
|
|
2523
4577
|
setError(null);
|
|
2524
|
-
const response = await fetch(`/admin/
|
|
4578
|
+
const response = await fetch(`/admin/return/${id}`, {
|
|
2525
4579
|
credentials: "include"
|
|
2526
4580
|
});
|
|
2527
4581
|
if (!response.ok) {
|
|
2528
4582
|
const message = await response.text();
|
|
2529
|
-
throw new Error(message || "Unable to load
|
|
4583
|
+
throw new Error(message || "Unable to load return order");
|
|
2530
4584
|
}
|
|
2531
4585
|
const payload = await response.json();
|
|
2532
|
-
|
|
2533
|
-
setOrder(payload.order || null);
|
|
4586
|
+
setReturnOrder(payload.return);
|
|
2534
4587
|
} catch (loadError) {
|
|
2535
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
4588
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
2536
4589
|
setError(message);
|
|
2537
4590
|
} finally {
|
|
2538
4591
|
setIsLoading(false);
|
|
2539
4592
|
}
|
|
2540
4593
|
};
|
|
2541
|
-
void
|
|
4594
|
+
void loadReturn();
|
|
2542
4595
|
}, [id, navigate]);
|
|
2543
|
-
const
|
|
4596
|
+
const handleReject = async () => {
|
|
2544
4597
|
if (!id) {
|
|
2545
4598
|
return;
|
|
2546
4599
|
}
|
|
2547
4600
|
try {
|
|
2548
|
-
|
|
4601
|
+
setIsRejecting(true);
|
|
2549
4602
|
setUpdateError(null);
|
|
2550
4603
|
setUpdateSuccess(false);
|
|
2551
|
-
const response = await fetch(`/admin/
|
|
4604
|
+
const response = await fetch(`/admin/return/${id}/reject`, {
|
|
2552
4605
|
method: "POST",
|
|
2553
4606
|
headers: {
|
|
2554
4607
|
"Content-Type": "application/json"
|
|
2555
4608
|
},
|
|
2556
|
-
credentials: "include"
|
|
4609
|
+
credentials: "include",
|
|
4610
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2557
4611
|
});
|
|
2558
4612
|
if (!response.ok) {
|
|
2559
4613
|
const message = await response.text();
|
|
2560
|
-
throw new Error(message || "Unable to
|
|
4614
|
+
throw new Error(message || "Unable to reject return");
|
|
2561
4615
|
}
|
|
2562
4616
|
const payload = await response.json();
|
|
2563
|
-
|
|
4617
|
+
setReturnOrder(payload.return);
|
|
2564
4618
|
setUpdateSuccess(true);
|
|
2565
4619
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2566
|
-
const detailResponse = await fetch(`/admin/
|
|
4620
|
+
const detailResponse = await fetch(`/admin/return/${id}`, {
|
|
2567
4621
|
credentials: "include"
|
|
2568
4622
|
});
|
|
2569
4623
|
if (detailResponse.ok) {
|
|
2570
4624
|
const detailPayload = await detailResponse.json();
|
|
2571
|
-
|
|
2572
|
-
setOrder(detailPayload.order || null);
|
|
4625
|
+
setReturnOrder(detailPayload.return);
|
|
2573
4626
|
}
|
|
2574
|
-
} catch (
|
|
2575
|
-
const message =
|
|
4627
|
+
} catch (updateErr) {
|
|
4628
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
2576
4629
|
setUpdateError(message);
|
|
2577
4630
|
} finally {
|
|
2578
|
-
|
|
4631
|
+
setIsRejecting(false);
|
|
2579
4632
|
}
|
|
2580
4633
|
};
|
|
2581
|
-
const isOrderExchange = Boolean(swap?.exchange_id);
|
|
2582
|
-
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2583
|
-
swap.status?.toLowerCase() ?? ""
|
|
2584
|
-
);
|
|
2585
4634
|
if (isLoading) {
|
|
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
|
|
4635
|
+
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 return order..." }) }) }) });
|
|
2587
4636
|
}
|
|
2588
|
-
if (error || !
|
|
4637
|
+
if (error || !returnOrder) {
|
|
2589
4638
|
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__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2590
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2591
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
4639
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
4640
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2592
4641
|
] }) }) });
|
|
2593
4642
|
}
|
|
2594
|
-
const statusHistory =
|
|
4643
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
2595
4644
|
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: [
|
|
2596
4645
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2597
4646
|
/* @__PURE__ */ jsxs(
|
|
@@ -2599,7 +4648,7 @@ const SwapDetailPage = () => {
|
|
|
2599
4648
|
{
|
|
2600
4649
|
variant: "transparent",
|
|
2601
4650
|
size: "small",
|
|
2602
|
-
onClick: () => navigate("/
|
|
4651
|
+
onClick: () => navigate("/returns"),
|
|
2603
4652
|
className: "w-fit",
|
|
2604
4653
|
children: [
|
|
2605
4654
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2609,67 +4658,82 @@ const SwapDetailPage = () => {
|
|
|
2609
4658
|
),
|
|
2610
4659
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2611
4660
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2612
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2613
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
4661
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
4662
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
2614
4663
|
] }),
|
|
2615
4664
|
/* @__PURE__ */ jsx(
|
|
2616
4665
|
Badge,
|
|
2617
4666
|
{
|
|
2618
4667
|
size: "small",
|
|
2619
|
-
className: `uppercase ${getStatusBadgeClass(
|
|
2620
|
-
children:
|
|
4668
|
+
className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
|
|
4669
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2621
4670
|
}
|
|
2622
4671
|
)
|
|
2623
4672
|
] })
|
|
2624
4673
|
] }),
|
|
2625
|
-
|
|
4674
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2626
4675
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2627
4676
|
Button,
|
|
2628
4677
|
{
|
|
2629
4678
|
variant: "danger",
|
|
2630
|
-
onClick:
|
|
2631
|
-
disabled:
|
|
2632
|
-
isLoading:
|
|
2633
|
-
children: "Cancel
|
|
4679
|
+
onClick: handleReject,
|
|
4680
|
+
disabled: isRejecting,
|
|
4681
|
+
isLoading: isRejecting,
|
|
4682
|
+
children: "Reject (Cancel) Return"
|
|
2634
4683
|
}
|
|
2635
4684
|
) }),
|
|
2636
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
4685
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
4686
|
+
] }),
|
|
4687
|
+
returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
|
|
4688
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
4689
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
4690
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
4691
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4692
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
4693
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
4694
|
+
] }),
|
|
4695
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
4696
|
+
Button,
|
|
4697
|
+
{
|
|
4698
|
+
variant: "secondary",
|
|
4699
|
+
onClick: () => {
|
|
4700
|
+
window.open(
|
|
4701
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
4702
|
+
"_blank"
|
|
4703
|
+
);
|
|
4704
|
+
},
|
|
4705
|
+
children: "View order"
|
|
4706
|
+
}
|
|
4707
|
+
) })
|
|
4708
|
+
] })
|
|
2637
4709
|
] }),
|
|
2638
4710
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2639
4711
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2640
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
4712
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2641
4713
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2642
4714
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2643
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2644
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4715
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
4716
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2645
4717
|
] }),
|
|
2646
4718
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2647
4719
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2648
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2649
|
-
] }),
|
|
2650
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2651
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2652
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
4720
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
2653
4721
|
] }),
|
|
2654
|
-
|
|
4722
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2655
4723
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2656
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4724
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
2657
4725
|
] }),
|
|
2658
|
-
|
|
4726
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2659
4727
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2660
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
4728
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
2661
4729
|
] }),
|
|
2662
4730
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2663
4731
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2664
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
4732
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2665
4733
|
] }),
|
|
2666
4734
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2667
4735
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2668
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2669
|
-
] }),
|
|
2670
|
-
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2671
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2672
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
4736
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2673
4737
|
] })
|
|
2674
4738
|
] })
|
|
2675
4739
|
] }),
|
|
@@ -2699,31 +4763,35 @@ const SwapDetailPage = () => {
|
|
|
2699
4763
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2700
4764
|
] })
|
|
2701
4765
|
] }),
|
|
2702
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
4766
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2703
4767
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2704
4768
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2705
4769
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2706
4770
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2707
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
4771
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2708
4772
|
] }),
|
|
2709
4773
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2710
4774
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2711
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
4775
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2712
4776
|
] }),
|
|
2713
4777
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2714
4778
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2715
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.customer
|
|
4779
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2716
4780
|
] }),
|
|
2717
|
-
|
|
4781
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4782
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
|
|
4783
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = returnOrder.order.order_payment) == null ? void 0 : _c.label) || "—" })
|
|
4784
|
+
] }),
|
|
4785
|
+
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2718
4786
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2719
4787
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2720
|
-
order.currency_code || "$",
|
|
2721
|
-
(Number(order.total) / 100).toFixed(2)
|
|
4788
|
+
returnOrder.order.currency_code || "$",
|
|
4789
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2722
4790
|
] })
|
|
2723
4791
|
] })
|
|
2724
4792
|
] })
|
|
2725
4793
|
] }),
|
|
2726
|
-
|
|
4794
|
+
returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2727
4795
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2728
4796
|
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2729
4797
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2731,86 +4799,73 @@ const SwapDetailPage = () => {
|
|
|
2731
4799
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2732
4800
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2733
4801
|
] }) }),
|
|
2734
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
4802
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2735
4803
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2736
4804
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2737
4805
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2738
4806
|
] }, item.id || index)) })
|
|
2739
4807
|
] }) })
|
|
2740
4808
|
] }),
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2744
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2745
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2746
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2747
|
-
] }) }),
|
|
2748
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2749
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2750
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2751
|
-
] }, item.variant_id || index)) })
|
|
2752
|
-
] }) })
|
|
2753
|
-
] })
|
|
4809
|
+
updateError && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: updateError }) }),
|
|
4810
|
+
updateSuccess && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
|
|
2754
4811
|
] }) });
|
|
2755
4812
|
};
|
|
2756
4813
|
const config = defineRouteConfig({
|
|
2757
|
-
label: "
|
|
2758
|
-
icon:
|
|
4814
|
+
label: "Return Order Details",
|
|
4815
|
+
icon: CheckCircle
|
|
2759
4816
|
});
|
|
2760
4817
|
const i18nTranslations0 = {};
|
|
2761
4818
|
const widgetModule = { widgets: [
|
|
2762
4819
|
{
|
|
2763
4820
|
Component: OrderGiftItemsWidget,
|
|
2764
|
-
zone: ["order.details.side.after"]
|
|
2765
|
-
widgetId: "Widget-b753"
|
|
4821
|
+
zone: ["order.details.side.after"]
|
|
2766
4822
|
},
|
|
2767
4823
|
{
|
|
2768
4824
|
Component: OrderRefundContextWidget,
|
|
2769
|
-
zone: ["order.details.after"]
|
|
2770
|
-
widgetId: "Widget-0606"
|
|
4825
|
+
zone: ["order.details.after"]
|
|
2771
4826
|
}
|
|
2772
4827
|
] };
|
|
2773
4828
|
const routeModule = {
|
|
2774
4829
|
routes: [
|
|
2775
4830
|
{
|
|
2776
|
-
Component:
|
|
2777
|
-
path: "/
|
|
2778
|
-
handle: { label: config$7.label, translationNs: config$7.translationNs }
|
|
4831
|
+
Component: DeletedRecordsPage,
|
|
4832
|
+
path: "/deleted-records-audit"
|
|
2779
4833
|
},
|
|
2780
4834
|
{
|
|
2781
4835
|
Component: RefundsPage,
|
|
2782
|
-
path: "/refunds"
|
|
2783
|
-
|
|
4836
|
+
path: "/refunds"
|
|
4837
|
+
},
|
|
4838
|
+
{
|
|
4839
|
+
Component: PaymentsPage,
|
|
4840
|
+
path: "/payments"
|
|
2784
4841
|
},
|
|
2785
4842
|
{
|
|
2786
4843
|
Component: ReturnsPage,
|
|
2787
|
-
path: "/returns"
|
|
2788
|
-
handle: { label: config$5.label, translationNs: config$5.translationNs }
|
|
4844
|
+
path: "/returns"
|
|
2789
4845
|
},
|
|
2790
4846
|
{
|
|
2791
4847
|
Component: SwapsPage,
|
|
2792
|
-
path: "/swaps"
|
|
2793
|
-
handle: { label: config$4.label, translationNs: config$4.translationNs }
|
|
4848
|
+
path: "/swaps"
|
|
2794
4849
|
},
|
|
2795
4850
|
{
|
|
2796
|
-
Component:
|
|
2797
|
-
path: "/
|
|
2798
|
-
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
4851
|
+
Component: DeletedRecordDetailPage,
|
|
4852
|
+
path: "/deleted-records-audit/:id"
|
|
2799
4853
|
},
|
|
2800
4854
|
{
|
|
2801
|
-
Component:
|
|
2802
|
-
path: "/
|
|
2803
|
-
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
4855
|
+
Component: RefundDetailPage,
|
|
4856
|
+
path: "/refunds/:id"
|
|
2804
4857
|
},
|
|
2805
4858
|
{
|
|
2806
|
-
Component:
|
|
2807
|
-
path: "/
|
|
2808
|
-
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
4859
|
+
Component: PaymentDetailPage,
|
|
4860
|
+
path: "/payments/:id"
|
|
2809
4861
|
},
|
|
2810
4862
|
{
|
|
2811
4863
|
Component: SwapDetailPage,
|
|
2812
|
-
path: "/swaps/:id"
|
|
2813
|
-
|
|
4864
|
+
path: "/swaps/:id"
|
|
4865
|
+
},
|
|
4866
|
+
{
|
|
4867
|
+
Component: ReturnDetailPage,
|
|
4868
|
+
path: "/returns/:id"
|
|
2814
4869
|
}
|
|
2815
4870
|
]
|
|
2816
4871
|
};
|
|
@@ -2819,66 +4874,56 @@ const menuItemModule = {
|
|
|
2819
4874
|
{
|
|
2820
4875
|
label: config$6.label,
|
|
2821
4876
|
icon: config$6.icon,
|
|
2822
|
-
path: "/
|
|
2823
|
-
nested: void 0
|
|
2824
|
-
rank: void 0,
|
|
2825
|
-
translationNs: void 0
|
|
4877
|
+
path: "/payments",
|
|
4878
|
+
nested: void 0
|
|
2826
4879
|
},
|
|
2827
4880
|
{
|
|
2828
|
-
label: config$
|
|
2829
|
-
icon: config$
|
|
2830
|
-
path: "/
|
|
2831
|
-
nested: void 0
|
|
2832
|
-
rank: void 0,
|
|
2833
|
-
translationNs: void 0
|
|
4881
|
+
label: config$8.label,
|
|
4882
|
+
icon: config$8.icon,
|
|
4883
|
+
path: "/deleted-records-audit",
|
|
4884
|
+
nested: void 0
|
|
2834
4885
|
},
|
|
2835
4886
|
{
|
|
2836
4887
|
label: config$5.label,
|
|
2837
4888
|
icon: config$5.icon,
|
|
2838
4889
|
path: "/returns",
|
|
2839
|
-
nested: void 0
|
|
2840
|
-
|
|
2841
|
-
|
|
4890
|
+
nested: void 0
|
|
4891
|
+
},
|
|
4892
|
+
{
|
|
4893
|
+
label: config$7.label,
|
|
4894
|
+
icon: config$7.icon,
|
|
4895
|
+
path: "/refunds",
|
|
4896
|
+
nested: void 0
|
|
2842
4897
|
},
|
|
2843
4898
|
{
|
|
2844
4899
|
label: config$4.label,
|
|
2845
4900
|
icon: config$4.icon,
|
|
2846
4901
|
path: "/swaps",
|
|
2847
|
-
nested: void 0
|
|
2848
|
-
rank: void 0,
|
|
2849
|
-
translationNs: void 0
|
|
2850
|
-
},
|
|
2851
|
-
{
|
|
2852
|
-
label: config$1.label,
|
|
2853
|
-
icon: config$1.icon,
|
|
2854
|
-
path: "/refunds/:id",
|
|
2855
|
-
nested: void 0,
|
|
2856
|
-
rank: void 0,
|
|
2857
|
-
translationNs: void 0
|
|
2858
|
-
},
|
|
2859
|
-
{
|
|
2860
|
-
label: config$3.label,
|
|
2861
|
-
icon: config$3.icon,
|
|
2862
|
-
path: "/payments/:id",
|
|
2863
|
-
nested: void 0,
|
|
2864
|
-
rank: void 0,
|
|
2865
|
-
translationNs: void 0
|
|
4902
|
+
nested: void 0
|
|
2866
4903
|
},
|
|
2867
4904
|
{
|
|
2868
4905
|
label: config$2.label,
|
|
2869
4906
|
icon: config$2.icon,
|
|
2870
|
-
path: "/
|
|
2871
|
-
nested: void 0
|
|
2872
|
-
rank: void 0,
|
|
2873
|
-
translationNs: void 0
|
|
4907
|
+
path: "/payments/:id",
|
|
4908
|
+
nested: void 0
|
|
2874
4909
|
},
|
|
2875
4910
|
{
|
|
2876
4911
|
label: config.label,
|
|
2877
4912
|
icon: config.icon,
|
|
4913
|
+
path: "/returns/:id",
|
|
4914
|
+
nested: void 0
|
|
4915
|
+
},
|
|
4916
|
+
{
|
|
4917
|
+
label: config$3.label,
|
|
4918
|
+
icon: config$3.icon,
|
|
4919
|
+
path: "/refunds/:id",
|
|
4920
|
+
nested: void 0
|
|
4921
|
+
},
|
|
4922
|
+
{
|
|
4923
|
+
label: config$1.label,
|
|
4924
|
+
icon: config$1.icon,
|
|
2878
4925
|
path: "/swaps/:id",
|
|
2879
|
-
nested: void 0
|
|
2880
|
-
rank: void 0,
|
|
2881
|
-
translationNs: void 0
|
|
4926
|
+
nested: void 0
|
|
2882
4927
|
}
|
|
2883
4928
|
]
|
|
2884
4929
|
};
|
|
@@ -2887,19 +4932,13 @@ const displayModule = {
|
|
|
2887
4932
|
displays: {}
|
|
2888
4933
|
};
|
|
2889
4934
|
const i18nModule = { resources: i18nTranslations0 };
|
|
2890
|
-
const cellRendererModule = {};
|
|
2891
|
-
const layoutModule = { layouts: [] };
|
|
2892
|
-
const searchEntityModule = {};
|
|
2893
4935
|
const plugin = {
|
|
2894
4936
|
widgetModule,
|
|
2895
4937
|
routeModule,
|
|
2896
4938
|
menuItemModule,
|
|
2897
4939
|
formModule,
|
|
2898
4940
|
displayModule,
|
|
2899
|
-
i18nModule
|
|
2900
|
-
cellRendererModule,
|
|
2901
|
-
layoutModule,
|
|
2902
|
-
searchEntityModule
|
|
4941
|
+
i18nModule
|
|
2903
4942
|
};
|
|
2904
4943
|
export {
|
|
2905
4944
|
plugin as default
|