order-management 0.0.85 → 0.0.87
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 +501 -501
- package/.medusa/server/src/admin/index.mjs +502 -502
- package/.medusa/server/src/api/store/payment-details/[id]/make-default/route.js +18 -7
- package/.medusa/server/src/api/store/payment-details/[id]/route.js +11 -3
- package/.medusa/server/src/modules/payment-detail/service.js +62 -33
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
3
|
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
4
4
|
import { Container, Text, Heading, Badge, Button, Label, Select, Textarea, Input } from "@medusajs/ui";
|
|
5
|
-
import { CashSolid, PencilSquareSolid, Trash,
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, ArrowPath, Receipt, CreditCard, ArrowLeft, CheckCircle } from "@medusajs/icons";
|
|
6
6
|
import { useNavigate, useParams } from "react-router-dom";
|
|
7
7
|
function roundRectPath(ctx, x, y, w, h, r) {
|
|
8
8
|
ctx.beginPath();
|
|
@@ -865,206 +865,6 @@ const useDebounce$3 = (value, delay) => {
|
|
|
865
865
|
return debouncedValue;
|
|
866
866
|
};
|
|
867
867
|
const getStatusBadgeClass$7 = (status) => {
|
|
868
|
-
const s2 = status.toLowerCase();
|
|
869
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
870
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
871
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
872
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
873
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
874
|
-
};
|
|
875
|
-
const PaymentsPage = () => {
|
|
876
|
-
const navigate = useNavigate();
|
|
877
|
-
const [items, setItems] = useState([]);
|
|
878
|
-
const [statusFilter, setStatusFilter] = useState("all");
|
|
879
|
-
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
880
|
-
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
881
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
882
|
-
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
883
|
-
const [error, setError] = useState(null);
|
|
884
|
-
const [offset, setOffset] = useState(0);
|
|
885
|
-
const [count, setCount] = useState(0);
|
|
886
|
-
const limit = 50;
|
|
887
|
-
const loadTransactions = useCallback(
|
|
888
|
-
async (nextOffset, replace) => {
|
|
889
|
-
try {
|
|
890
|
-
if (replace) setIsLoading(true);
|
|
891
|
-
else setIsFetchingMore(true);
|
|
892
|
-
setError(null);
|
|
893
|
-
const params = new URLSearchParams();
|
|
894
|
-
params.set("limit", String(limit));
|
|
895
|
-
params.set("offset", String(nextOffset));
|
|
896
|
-
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
897
|
-
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
898
|
-
const response = await fetch(
|
|
899
|
-
`/admin/payment-transactions?${params.toString()}`,
|
|
900
|
-
{ credentials: "include" }
|
|
901
|
-
);
|
|
902
|
-
if (!response.ok) {
|
|
903
|
-
const text = await response.text();
|
|
904
|
-
throw new Error(text || "Failed to load payment transactions");
|
|
905
|
-
}
|
|
906
|
-
const payload = await response.json();
|
|
907
|
-
const list = payload.transactions ?? [];
|
|
908
|
-
setCount(payload.count ?? 0);
|
|
909
|
-
setOffset(nextOffset + list.length);
|
|
910
|
-
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
911
|
-
} catch (e) {
|
|
912
|
-
setError(e instanceof Error ? e.message : "Failed to load");
|
|
913
|
-
} finally {
|
|
914
|
-
setIsLoading(false);
|
|
915
|
-
setIsFetchingMore(false);
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
[statusFilter, debouncedOrderId]
|
|
919
|
-
);
|
|
920
|
-
useEffect(() => {
|
|
921
|
-
void loadTransactions(0, true);
|
|
922
|
-
}, [loadTransactions]);
|
|
923
|
-
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
924
|
-
const displayStatus = (t) => {
|
|
925
|
-
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
926
|
-
return s2 !== "" ? s2 : "—";
|
|
927
|
-
};
|
|
928
|
-
const displayAmount = (t) => {
|
|
929
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
930
|
-
return `${code} ${Number(t.amount)}`;
|
|
931
|
-
};
|
|
932
|
-
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: [
|
|
933
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
934
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
935
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
936
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
937
|
-
] }),
|
|
938
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
939
|
-
] }),
|
|
940
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
941
|
-
/* @__PURE__ */ jsx(
|
|
942
|
-
Input,
|
|
943
|
-
{
|
|
944
|
-
placeholder: "Search by Order ID",
|
|
945
|
-
value: orderIdSearch,
|
|
946
|
-
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
947
|
-
className: "md:max-w-sm",
|
|
948
|
-
"aria-label": "Search by order ID"
|
|
949
|
-
}
|
|
950
|
-
),
|
|
951
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
952
|
-
"select",
|
|
953
|
-
{
|
|
954
|
-
value: statusFilter,
|
|
955
|
-
onChange: (e) => setStatusFilter(e.target.value),
|
|
956
|
-
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",
|
|
957
|
-
"aria-label": "Filter by status",
|
|
958
|
-
children: [
|
|
959
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
960
|
-
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
961
|
-
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
962
|
-
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
963
|
-
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
964
|
-
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
965
|
-
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
966
|
-
]
|
|
967
|
-
}
|
|
968
|
-
) })
|
|
969
|
-
] }),
|
|
970
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
971
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
972
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
973
|
-
] }) : null,
|
|
974
|
-
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: [
|
|
975
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
976
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
977
|
-
] }) : /* @__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: [
|
|
978
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
979
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
980
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
981
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
982
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
983
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
984
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
985
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
986
|
-
] }) }),
|
|
987
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
988
|
-
"tr",
|
|
989
|
-
{
|
|
990
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
991
|
-
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
992
|
-
children: [
|
|
993
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
994
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
995
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
996
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
997
|
-
Badge,
|
|
998
|
-
{
|
|
999
|
-
size: "2xsmall",
|
|
1000
|
-
className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
|
|
1001
|
-
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1002
|
-
}
|
|
1003
|
-
) }),
|
|
1004
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1005
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1006
|
-
year: "numeric",
|
|
1007
|
-
month: "short",
|
|
1008
|
-
day: "numeric",
|
|
1009
|
-
hour: "numeric",
|
|
1010
|
-
minute: "2-digit",
|
|
1011
|
-
hour12: true
|
|
1012
|
-
}) }),
|
|
1013
|
-
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
1014
|
-
/* @__PURE__ */ jsx(
|
|
1015
|
-
Button,
|
|
1016
|
-
{
|
|
1017
|
-
variant: "transparent",
|
|
1018
|
-
size: "small",
|
|
1019
|
-
onClick: (e) => {
|
|
1020
|
-
e.stopPropagation();
|
|
1021
|
-
navigate(`/payments/${t.payment_session_id}`);
|
|
1022
|
-
},
|
|
1023
|
-
children: "View details"
|
|
1024
|
-
}
|
|
1025
|
-
),
|
|
1026
|
-
t.order_id ? /* @__PURE__ */ jsx(
|
|
1027
|
-
Button,
|
|
1028
|
-
{
|
|
1029
|
-
variant: "transparent",
|
|
1030
|
-
size: "small",
|
|
1031
|
-
onClick: (e) => {
|
|
1032
|
-
e.stopPropagation();
|
|
1033
|
-
navigate(`/orders/${t.order_id}`);
|
|
1034
|
-
},
|
|
1035
|
-
children: "Order"
|
|
1036
|
-
}
|
|
1037
|
-
) : null
|
|
1038
|
-
] })
|
|
1039
|
-
]
|
|
1040
|
-
},
|
|
1041
|
-
t.payment_session_id
|
|
1042
|
-
)) })
|
|
1043
|
-
] }) }),
|
|
1044
|
-
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1045
|
-
Button,
|
|
1046
|
-
{
|
|
1047
|
-
variant: "secondary",
|
|
1048
|
-
isLoading: isFetchingMore,
|
|
1049
|
-
onClick: () => loadTransactions(offset, false),
|
|
1050
|
-
children: "Load more"
|
|
1051
|
-
}
|
|
1052
|
-
) }) : null
|
|
1053
|
-
] }) });
|
|
1054
|
-
};
|
|
1055
|
-
const config$7 = defineRouteConfig({
|
|
1056
|
-
label: "Payments",
|
|
1057
|
-
icon: CreditCard
|
|
1058
|
-
});
|
|
1059
|
-
const useDebounce$2 = (value, delay) => {
|
|
1060
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1061
|
-
useEffect(() => {
|
|
1062
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1063
|
-
return () => clearTimeout(handler);
|
|
1064
|
-
}, [value, delay]);
|
|
1065
|
-
return debouncedValue;
|
|
1066
|
-
};
|
|
1067
|
-
const getStatusBadgeClass$6 = (status) => {
|
|
1068
868
|
const statusLower = status.toLowerCase();
|
|
1069
869
|
if (statusLower === "requested") {
|
|
1070
870
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -1089,7 +889,7 @@ const SwapsPage = () => {
|
|
|
1089
889
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1090
890
|
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1091
891
|
const [searchQuery, setSearchQuery] = useState("");
|
|
1092
|
-
const debouncedSearchQuery = useDebounce$
|
|
892
|
+
const debouncedSearchQuery = useDebounce$3(searchQuery, 300);
|
|
1093
893
|
const [isLoading, setIsLoading] = useState(true);
|
|
1094
894
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1095
895
|
const [error, setError] = useState(null);
|
|
@@ -1232,7 +1032,7 @@ const SwapsPage = () => {
|
|
|
1232
1032
|
Badge,
|
|
1233
1033
|
{
|
|
1234
1034
|
size: "2xsmall",
|
|
1235
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1035
|
+
className: `uppercase ${getStatusBadgeClass$7(swap.status)}`,
|
|
1236
1036
|
children: swap.status.replace(/_/g, " ")
|
|
1237
1037
|
}
|
|
1238
1038
|
) }),
|
|
@@ -1282,11 +1082,11 @@ const SwapsPage = () => {
|
|
|
1282
1082
|
) }) : null
|
|
1283
1083
|
] }) });
|
|
1284
1084
|
};
|
|
1285
|
-
const config$
|
|
1085
|
+
const config$7 = defineRouteConfig({
|
|
1286
1086
|
label: "Exchanges",
|
|
1287
1087
|
icon: ArrowPath
|
|
1288
1088
|
});
|
|
1289
|
-
const useDebounce$
|
|
1089
|
+
const useDebounce$2 = (value, delay) => {
|
|
1290
1090
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1291
1091
|
useEffect(() => {
|
|
1292
1092
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1294,7 +1094,7 @@ const useDebounce$1 = (value, delay) => {
|
|
|
1294
1094
|
}, [value, delay]);
|
|
1295
1095
|
return debouncedValue;
|
|
1296
1096
|
};
|
|
1297
|
-
const getStatusBadgeClass$
|
|
1097
|
+
const getStatusBadgeClass$6 = (status) => {
|
|
1298
1098
|
const s2 = status.toLowerCase();
|
|
1299
1099
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1300
1100
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -1306,12 +1106,12 @@ const RefundsPage = () => {
|
|
|
1306
1106
|
const navigate = useNavigate();
|
|
1307
1107
|
const [items, setItems] = useState([]);
|
|
1308
1108
|
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1309
|
-
const debouncedOrderId = useDebounce$
|
|
1109
|
+
const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
|
|
1310
1110
|
const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
|
|
1311
1111
|
const [providerSearch, setProviderSearch] = useState("");
|
|
1312
|
-
const debouncedProvider = useDebounce$
|
|
1112
|
+
const debouncedProvider = useDebounce$2(providerSearch, 300);
|
|
1313
1113
|
const [currencySearch, setCurrencySearch] = useState("");
|
|
1314
|
-
const debouncedCurrency = useDebounce$
|
|
1114
|
+
const debouncedCurrency = useDebounce$2(currencySearch, 300);
|
|
1315
1115
|
const [dateFrom, setDateFrom] = useState("");
|
|
1316
1116
|
const [dateTo, setDateTo] = useState("");
|
|
1317
1117
|
const [amountMin, setAmountMin] = useState("");
|
|
@@ -1523,7 +1323,7 @@ const RefundsPage = () => {
|
|
|
1523
1323
|
Badge,
|
|
1524
1324
|
{
|
|
1525
1325
|
size: "2xsmall",
|
|
1526
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1326
|
+
className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
|
|
1527
1327
|
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
1528
1328
|
}
|
|
1529
1329
|
) }),
|
|
@@ -1577,11 +1377,11 @@ const RefundsPage = () => {
|
|
|
1577
1377
|
) }) : null
|
|
1578
1378
|
] }) });
|
|
1579
1379
|
};
|
|
1580
|
-
const config$
|
|
1380
|
+
const config$6 = defineRouteConfig({
|
|
1581
1381
|
label: "Refunds",
|
|
1582
1382
|
icon: Receipt
|
|
1583
1383
|
});
|
|
1584
|
-
const useDebounce = (value, delay) => {
|
|
1384
|
+
const useDebounce$1 = (value, delay) => {
|
|
1585
1385
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1586
1386
|
useEffect(() => {
|
|
1587
1387
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1589,7 +1389,7 @@ const useDebounce = (value, delay) => {
|
|
|
1589
1389
|
}, [value, delay]);
|
|
1590
1390
|
return debouncedValue;
|
|
1591
1391
|
};
|
|
1592
|
-
const getStatusBadgeClass$
|
|
1392
|
+
const getStatusBadgeClass$5 = (status) => {
|
|
1593
1393
|
const statusLower = status.toLowerCase();
|
|
1594
1394
|
if (statusLower === "requested") {
|
|
1595
1395
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -1614,7 +1414,7 @@ const ReturnsPage = () => {
|
|
|
1614
1414
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1615
1415
|
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1616
1416
|
const [searchQuery, setSearchQuery] = useState("");
|
|
1617
|
-
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1417
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
1618
1418
|
const [isLoading, setIsLoading] = useState(true);
|
|
1619
1419
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1620
1420
|
const [error, setError] = useState(null);
|
|
@@ -1760,7 +1560,7 @@ const ReturnsPage = () => {
|
|
|
1760
1560
|
Badge,
|
|
1761
1561
|
{
|
|
1762
1562
|
size: "2xsmall",
|
|
1763
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1563
|
+
className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
|
|
1764
1564
|
children: returnOrder.status.replace(/_/g, " ")
|
|
1765
1565
|
}
|
|
1766
1566
|
) }),
|
|
@@ -1809,11 +1609,19 @@ const ReturnsPage = () => {
|
|
|
1809
1609
|
) }) : null
|
|
1810
1610
|
] }) });
|
|
1811
1611
|
};
|
|
1812
|
-
const config$
|
|
1612
|
+
const config$5 = defineRouteConfig({
|
|
1813
1613
|
label: "Return Orders",
|
|
1814
1614
|
icon: ArrowPath
|
|
1815
1615
|
});
|
|
1816
|
-
const
|
|
1616
|
+
const useDebounce = (value, delay) => {
|
|
1617
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1618
|
+
useEffect(() => {
|
|
1619
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1620
|
+
return () => clearTimeout(handler);
|
|
1621
|
+
}, [value, delay]);
|
|
1622
|
+
return debouncedValue;
|
|
1623
|
+
};
|
|
1624
|
+
const getStatusBadgeClass$4 = (status) => {
|
|
1817
1625
|
const s2 = status.toLowerCase();
|
|
1818
1626
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1819
1627
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -1821,118 +1629,191 @@ const getStatusBadgeClass$3 = (status) => {
|
|
|
1821
1629
|
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1822
1630
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1823
1631
|
};
|
|
1824
|
-
const
|
|
1825
|
-
var _a;
|
|
1632
|
+
const PaymentsPage = () => {
|
|
1826
1633
|
const navigate = useNavigate();
|
|
1827
|
-
const
|
|
1828
|
-
const
|
|
1829
|
-
const [
|
|
1830
|
-
const
|
|
1634
|
+
const [items, setItems] = useState([]);
|
|
1635
|
+
const [statusFilter, setStatusFilter] = useState("all");
|
|
1636
|
+
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1637
|
+
const debouncedOrderId = useDebounce(orderIdSearch, 300);
|
|
1638
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1639
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1831
1640
|
const [error, setError] = useState(null);
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1641
|
+
const [offset, setOffset] = useState(0);
|
|
1642
|
+
const [count, setCount] = useState(0);
|
|
1643
|
+
const limit = 50;
|
|
1644
|
+
const loadTransactions = useCallback(
|
|
1645
|
+
async (nextOffset, replace) => {
|
|
1646
|
+
try {
|
|
1647
|
+
if (replace) setIsLoading(true);
|
|
1648
|
+
else setIsFetchingMore(true);
|
|
1649
|
+
setError(null);
|
|
1650
|
+
const params = new URLSearchParams();
|
|
1651
|
+
params.set("limit", String(limit));
|
|
1652
|
+
params.set("offset", String(nextOffset));
|
|
1653
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
1654
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
1655
|
+
const response = await fetch(
|
|
1656
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
1657
|
+
{ credentials: "include" }
|
|
1658
|
+
);
|
|
1659
|
+
if (!response.ok) {
|
|
1660
|
+
const text = await response.text();
|
|
1661
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
1662
|
+
}
|
|
1663
|
+
const payload = await response.json();
|
|
1664
|
+
const list = payload.transactions ?? [];
|
|
1665
|
+
setCount(payload.count ?? 0);
|
|
1666
|
+
setOffset(nextOffset + list.length);
|
|
1667
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
1668
|
+
} catch (e) {
|
|
1669
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
1670
|
+
} finally {
|
|
1671
|
+
setIsLoading(false);
|
|
1672
|
+
setIsFetchingMore(false);
|
|
1673
|
+
}
|
|
1674
|
+
},
|
|
1675
|
+
[statusFilter, debouncedOrderId]
|
|
1676
|
+
);
|
|
1677
|
+
useEffect(() => {
|
|
1678
|
+
void loadTransactions(0, true);
|
|
1679
|
+
}, [loadTransactions]);
|
|
1680
|
+
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1681
|
+
const displayStatus = (t) => {
|
|
1682
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
1683
|
+
return s2 !== "" ? s2 : "—";
|
|
1684
|
+
};
|
|
1685
|
+
const displayAmount = (t) => {
|
|
1686
|
+
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1687
|
+
return `${code} ${Number(t.amount)}`;
|
|
1688
|
+
};
|
|
1689
|
+
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: [
|
|
1690
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1691
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1692
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
1693
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
1694
|
+
] }),
|
|
1695
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
1696
|
+
] }),
|
|
1697
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1698
|
+
/* @__PURE__ */ jsx(
|
|
1699
|
+
Input,
|
|
1700
|
+
{
|
|
1701
|
+
placeholder: "Search by Order ID",
|
|
1702
|
+
value: orderIdSearch,
|
|
1703
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
1704
|
+
className: "md:max-w-sm",
|
|
1705
|
+
"aria-label": "Search by order ID"
|
|
1706
|
+
}
|
|
1707
|
+
),
|
|
1708
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
1709
|
+
"select",
|
|
1710
|
+
{
|
|
1711
|
+
value: statusFilter,
|
|
1712
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
1713
|
+
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",
|
|
1714
|
+
"aria-label": "Filter by status",
|
|
1715
|
+
children: [
|
|
1716
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1717
|
+
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1718
|
+
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1719
|
+
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1720
|
+
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1721
|
+
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1722
|
+
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1723
|
+
]
|
|
1724
|
+
}
|
|
1725
|
+
) })
|
|
1726
|
+
] }),
|
|
1864
1727
|
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1865
1728
|
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1866
|
-
/* @__PURE__ */ jsx(
|
|
1867
|
-
] }) :
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
] }),
|
|
1881
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1882
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
1883
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: displayAmount })
|
|
1884
|
-
] }),
|
|
1885
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1886
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
1887
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.provider_id })
|
|
1888
|
-
] }),
|
|
1889
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1890
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
1891
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
1892
|
-
Badge,
|
|
1893
|
-
{
|
|
1894
|
-
size: "2xsmall",
|
|
1895
|
-
className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
|
|
1896
|
-
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
1897
|
-
}
|
|
1898
|
-
) })
|
|
1899
|
-
] }),
|
|
1900
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1901
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
1902
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
1903
|
-
] }),
|
|
1904
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1905
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
1906
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
1907
|
-
] }),
|
|
1908
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1909
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
1910
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
1911
|
-
] }),
|
|
1912
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1913
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
1914
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
1915
|
-
year: "numeric",
|
|
1916
|
-
month: "short",
|
|
1917
|
-
day: "numeric",
|
|
1918
|
-
hour: "numeric",
|
|
1919
|
-
minute: "2-digit",
|
|
1920
|
-
hour12: true
|
|
1921
|
-
}) })
|
|
1922
|
-
] })
|
|
1729
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
1730
|
+
] }) : null,
|
|
1731
|
+
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: [
|
|
1732
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
1733
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
1734
|
+
] }) : /* @__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: [
|
|
1735
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1736
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1737
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1738
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1739
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1740
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
1741
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1742
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1923
1743
|
] }) }),
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1744
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
1745
|
+
"tr",
|
|
1746
|
+
{
|
|
1747
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1748
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1749
|
+
children: [
|
|
1750
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
1751
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
1752
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1753
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1754
|
+
Badge,
|
|
1755
|
+
{
|
|
1756
|
+
size: "2xsmall",
|
|
1757
|
+
className: `uppercase ${getStatusBadgeClass$4(displayStatus(t))}`,
|
|
1758
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1759
|
+
}
|
|
1760
|
+
) }),
|
|
1761
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1762
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1763
|
+
year: "numeric",
|
|
1764
|
+
month: "short",
|
|
1765
|
+
day: "numeric",
|
|
1766
|
+
hour: "numeric",
|
|
1767
|
+
minute: "2-digit",
|
|
1768
|
+
hour12: true
|
|
1769
|
+
}) }),
|
|
1770
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
1771
|
+
/* @__PURE__ */ jsx(
|
|
1772
|
+
Button,
|
|
1773
|
+
{
|
|
1774
|
+
variant: "transparent",
|
|
1775
|
+
size: "small",
|
|
1776
|
+
onClick: (e) => {
|
|
1777
|
+
e.stopPropagation();
|
|
1778
|
+
navigate(`/payments/${t.payment_session_id}`);
|
|
1779
|
+
},
|
|
1780
|
+
children: "View details"
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
t.order_id ? /* @__PURE__ */ jsx(
|
|
1784
|
+
Button,
|
|
1785
|
+
{
|
|
1786
|
+
variant: "transparent",
|
|
1787
|
+
size: "small",
|
|
1788
|
+
onClick: (e) => {
|
|
1789
|
+
e.stopPropagation();
|
|
1790
|
+
navigate(`/orders/${t.order_id}`);
|
|
1791
|
+
},
|
|
1792
|
+
children: "Order"
|
|
1793
|
+
}
|
|
1794
|
+
) : null
|
|
1795
|
+
] })
|
|
1796
|
+
]
|
|
1797
|
+
},
|
|
1798
|
+
t.payment_session_id
|
|
1799
|
+
)) })
|
|
1800
|
+
] }) }),
|
|
1801
|
+
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1802
|
+
Button,
|
|
1803
|
+
{
|
|
1804
|
+
variant: "secondary",
|
|
1805
|
+
isLoading: isFetchingMore,
|
|
1806
|
+
onClick: () => loadTransactions(offset, false),
|
|
1807
|
+
children: "Load more"
|
|
1808
|
+
}
|
|
1809
|
+
) }) : null
|
|
1929
1810
|
] }) });
|
|
1930
1811
|
};
|
|
1931
|
-
const config$
|
|
1932
|
-
label: "
|
|
1812
|
+
const config$4 = defineRouteConfig({
|
|
1813
|
+
label: "Payments",
|
|
1933
1814
|
icon: CreditCard
|
|
1934
1815
|
});
|
|
1935
|
-
const getStatusBadgeClass$
|
|
1816
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
1936
1817
|
const statusLower = status.toLowerCase();
|
|
1937
1818
|
if (statusLower === "requested") {
|
|
1938
1819
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2070,7 +1951,7 @@ const SwapDetailPage = () => {
|
|
|
2070
1951
|
Badge,
|
|
2071
1952
|
{
|
|
2072
1953
|
size: "small",
|
|
2073
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1954
|
+
className: `uppercase ${getStatusBadgeClass$3(swap.status)}`,
|
|
2074
1955
|
children: swap.status.replace(/_/g, " ")
|
|
2075
1956
|
}
|
|
2076
1957
|
)
|
|
@@ -2138,7 +2019,7 @@ const SwapDetailPage = () => {
|
|
|
2138
2019
|
Badge,
|
|
2139
2020
|
{
|
|
2140
2021
|
size: "2xsmall",
|
|
2141
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2022
|
+
className: `uppercase ${getStatusBadgeClass$3(entry.status)}`,
|
|
2142
2023
|
children: entry.status.replace(/_/g, " ")
|
|
2143
2024
|
}
|
|
2144
2025
|
) }),
|
|
@@ -2207,22 +2088,214 @@ const SwapDetailPage = () => {
|
|
|
2207
2088
|
] })
|
|
2208
2089
|
] }) });
|
|
2209
2090
|
};
|
|
2210
|
-
const config$
|
|
2091
|
+
const config$3 = defineRouteConfig({
|
|
2211
2092
|
label: "Swap Details",
|
|
2212
2093
|
icon: ArrowPath
|
|
2213
2094
|
});
|
|
2214
|
-
const getStatusBadgeClass$
|
|
2215
|
-
const
|
|
2216
|
-
if (
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
if (
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2095
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
2096
|
+
const s2 = status.toLowerCase();
|
|
2097
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2098
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2099
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2100
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2101
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2102
|
+
};
|
|
2103
|
+
const formatAmount = (value) => {
|
|
2104
|
+
return String(value);
|
|
2105
|
+
};
|
|
2106
|
+
const RefundDetailPage = () => {
|
|
2107
|
+
var _a, _b, _c;
|
|
2108
|
+
const navigate = useNavigate();
|
|
2109
|
+
const params = useParams();
|
|
2110
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2111
|
+
const [detail, setDetail] = useState(null);
|
|
2112
|
+
const [loading, setLoading] = useState(!!id);
|
|
2113
|
+
const [error, setError] = useState(null);
|
|
2114
|
+
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
2115
|
+
useEffect(() => {
|
|
2116
|
+
if (!id) {
|
|
2117
|
+
setLoading(false);
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
let cancelled = false;
|
|
2121
|
+
setLoading(true);
|
|
2122
|
+
setError(null);
|
|
2123
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
2124
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2125
|
+
return res.json();
|
|
2126
|
+
}).then((data) => {
|
|
2127
|
+
if (!cancelled) setDetail(data);
|
|
2128
|
+
}).catch((e) => {
|
|
2129
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2130
|
+
}).finally(() => {
|
|
2131
|
+
if (!cancelled) setLoading(false);
|
|
2132
|
+
});
|
|
2133
|
+
return () => {
|
|
2134
|
+
cancelled = true;
|
|
2135
|
+
};
|
|
2136
|
+
}, [id]);
|
|
2137
|
+
const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
|
|
2138
|
+
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;
|
|
2139
|
+
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: [
|
|
2140
|
+
/* @__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: [
|
|
2141
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
2142
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
|
|
2143
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
2144
|
+
] }) }),
|
|
2145
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2146
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2147
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
2148
|
+
] }) : 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: [
|
|
2149
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2150
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
2151
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2152
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2153
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
2154
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
2155
|
+
] }),
|
|
2156
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2157
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2158
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
2159
|
+
] }),
|
|
2160
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2161
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
2162
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
2163
|
+
] }),
|
|
2164
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2165
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
2166
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
2167
|
+
year: "numeric",
|
|
2168
|
+
month: "short",
|
|
2169
|
+
day: "numeric",
|
|
2170
|
+
hour: "numeric",
|
|
2171
|
+
minute: "2-digit",
|
|
2172
|
+
hour12: true
|
|
2173
|
+
}) })
|
|
2174
|
+
] }),
|
|
2175
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2176
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
2177
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
2178
|
+
] }) : null
|
|
2179
|
+
] })
|
|
2180
|
+
] }),
|
|
2181
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2182
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
2183
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2184
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2185
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
2186
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
2187
|
+
] }),
|
|
2188
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2189
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
2190
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
2191
|
+
] }),
|
|
2192
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2193
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
2194
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
2195
|
+
] }),
|
|
2196
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2197
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2198
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
2199
|
+
] }),
|
|
2200
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2201
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2202
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2203
|
+
Badge,
|
|
2204
|
+
{
|
|
2205
|
+
size: "2xsmall",
|
|
2206
|
+
className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
|
|
2207
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2208
|
+
}
|
|
2209
|
+
) })
|
|
2210
|
+
] }),
|
|
2211
|
+
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2212
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2213
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
2214
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
2215
|
+
] }),
|
|
2216
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2217
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2218
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2219
|
+
] }),
|
|
2220
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2221
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2222
|
+
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2223
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
2224
|
+
"%"
|
|
2225
|
+
] })
|
|
2226
|
+
] })
|
|
2227
|
+
] }) : null
|
|
2228
|
+
] })
|
|
2229
|
+
] }),
|
|
2230
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2231
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
2232
|
+
detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2233
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2234
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2235
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2236
|
+
Button,
|
|
2237
|
+
{
|
|
2238
|
+
variant: "transparent",
|
|
2239
|
+
size: "small",
|
|
2240
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2241
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
2242
|
+
}
|
|
2243
|
+
) })
|
|
2244
|
+
] }),
|
|
2245
|
+
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2246
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2247
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2248
|
+
] }) : null,
|
|
2249
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2250
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2251
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2252
|
+
] }) : null,
|
|
2253
|
+
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2254
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2255
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2256
|
+
] }) : null,
|
|
2257
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2258
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2259
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2260
|
+
] }) : null
|
|
2261
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2262
|
+
] }),
|
|
2263
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2264
|
+
/* @__PURE__ */ jsxs(
|
|
2265
|
+
"button",
|
|
2266
|
+
{
|
|
2267
|
+
type: "button",
|
|
2268
|
+
className: "flex w-full items-center justify-between text-left",
|
|
2269
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
2270
|
+
"aria-expanded": gatewayExpanded,
|
|
2271
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
2272
|
+
children: [
|
|
2273
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
2274
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
2275
|
+
]
|
|
2276
|
+
}
|
|
2277
|
+
),
|
|
2278
|
+
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." }) })
|
|
2279
|
+
] })
|
|
2280
|
+
] }) : null
|
|
2281
|
+
] }) });
|
|
2282
|
+
};
|
|
2283
|
+
const config$2 = defineRouteConfig({
|
|
2284
|
+
label: "Refund details",
|
|
2285
|
+
icon: Receipt
|
|
2286
|
+
});
|
|
2287
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
2288
|
+
const statusLower = status.toLowerCase();
|
|
2289
|
+
if (statusLower === "requested") {
|
|
2290
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2291
|
+
}
|
|
2292
|
+
if (statusLower === "approved") {
|
|
2293
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2294
|
+
}
|
|
2295
|
+
if (statusLower === "rejected") {
|
|
2296
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2297
|
+
}
|
|
2298
|
+
if (statusLower === "received") {
|
|
2226
2299
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2227
2300
|
}
|
|
2228
2301
|
if (statusLower === "refunded") {
|
|
@@ -2497,18 +2570,14 @@ const getStatusBadgeClass = (status) => {
|
|
|
2497
2570
|
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2498
2571
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2499
2572
|
};
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2502
|
-
};
|
|
2503
|
-
const RefundDetailPage = () => {
|
|
2504
|
-
var _a, _b, _c;
|
|
2573
|
+
const PaymentDetailPage = () => {
|
|
2574
|
+
var _a;
|
|
2505
2575
|
const navigate = useNavigate();
|
|
2506
2576
|
const params = useParams();
|
|
2507
2577
|
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2508
2578
|
const [detail, setDetail] = useState(null);
|
|
2509
2579
|
const [loading, setLoading] = useState(!!id);
|
|
2510
2580
|
const [error, setError] = useState(null);
|
|
2511
|
-
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
2512
2581
|
useEffect(() => {
|
|
2513
2582
|
if (!id) {
|
|
2514
2583
|
setLoading(false);
|
|
@@ -2517,7 +2586,7 @@ const RefundDetailPage = () => {
|
|
|
2517
2586
|
let cancelled = false;
|
|
2518
2587
|
setLoading(true);
|
|
2519
2588
|
setError(null);
|
|
2520
|
-
fetch(`/admin/
|
|
2589
|
+
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
2521
2590
|
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2522
2591
|
return res.json();
|
|
2523
2592
|
}).then((data) => {
|
|
@@ -2531,155 +2600,86 @@ const RefundDetailPage = () => {
|
|
|
2531
2600
|
cancelled = true;
|
|
2532
2601
|
};
|
|
2533
2602
|
}, [id]);
|
|
2534
|
-
const
|
|
2535
|
-
const
|
|
2603
|
+
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
2604
|
+
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
2605
|
+
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
2606
|
+
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
2536
2607
|
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: [
|
|
2537
2608
|
/* @__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: [
|
|
2538
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/
|
|
2539
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2540
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle
|
|
2609
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
2610
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
|
|
2611
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
2541
2612
|
] }) }),
|
|
2542
2613
|
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2543
2614
|
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2544
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/
|
|
2615
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
|
|
2545
2616
|
] }) : 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: [
|
|
2546
|
-
/* @__PURE__ */
|
|
2547
|
-
/* @__PURE__ */
|
|
2548
|
-
|
|
2549
|
-
/* @__PURE__ */
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
/* @__PURE__ */
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
/* @__PURE__ */
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
Badge,
|
|
2601
|
-
{
|
|
2602
|
-
size: "2xsmall",
|
|
2603
|
-
className: `uppercase ${getStatusBadgeClass(paymentStatus)}`,
|
|
2604
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2605
|
-
}
|
|
2606
|
-
) })
|
|
2607
|
-
] }),
|
|
2608
|
-
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2609
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2610
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
2611
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
2612
|
-
] }),
|
|
2613
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2614
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2615
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2616
|
-
] }),
|
|
2617
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2618
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2619
|
-
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2620
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
2621
|
-
"%"
|
|
2622
|
-
] })
|
|
2623
|
-
] })
|
|
2624
|
-
] }) : null
|
|
2617
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2618
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2619
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
|
|
2620
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsx(
|
|
2621
|
+
Button,
|
|
2622
|
+
{
|
|
2623
|
+
variant: "transparent",
|
|
2624
|
+
size: "small",
|
|
2625
|
+
onClick: () => navigate(`/orders/${detail.order_id}`),
|
|
2626
|
+
children: detail.order_id
|
|
2627
|
+
}
|
|
2628
|
+
) : /* @__PURE__ */ jsx(Text, { children: "—" }) })
|
|
2629
|
+
] }),
|
|
2630
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2631
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2632
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: displayAmount })
|
|
2633
|
+
] }),
|
|
2634
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2635
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2636
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.provider_id })
|
|
2637
|
+
] }),
|
|
2638
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2639
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2640
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2641
|
+
Badge,
|
|
2642
|
+
{
|
|
2643
|
+
size: "2xsmall",
|
|
2644
|
+
className: `uppercase ${getStatusBadgeClass(displayStatus)}`,
|
|
2645
|
+
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
2646
|
+
}
|
|
2647
|
+
) })
|
|
2648
|
+
] }),
|
|
2649
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2650
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
2651
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
2652
|
+
] }),
|
|
2653
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2654
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
2655
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
2656
|
+
] }),
|
|
2657
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2658
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
2659
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
2660
|
+
] }),
|
|
2661
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2662
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
2663
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
2664
|
+
year: "numeric",
|
|
2665
|
+
month: "short",
|
|
2666
|
+
day: "numeric",
|
|
2667
|
+
hour: "numeric",
|
|
2668
|
+
minute: "2-digit",
|
|
2669
|
+
hour12: true
|
|
2670
|
+
}) })
|
|
2625
2671
|
] })
|
|
2626
|
-
] }),
|
|
2627
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2628
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2632
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2633
|
-
Button,
|
|
2634
|
-
{
|
|
2635
|
-
variant: "transparent",
|
|
2636
|
-
size: "small",
|
|
2637
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2638
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
2639
|
-
}
|
|
2640
|
-
) })
|
|
2641
|
-
] }),
|
|
2642
|
-
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2643
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2644
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2645
|
-
] }) : null,
|
|
2646
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2647
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2648
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2649
|
-
] }) : null,
|
|
2650
|
-
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2651
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2652
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2653
|
-
] }) : null,
|
|
2654
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2655
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2656
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2657
|
-
] }) : null
|
|
2658
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2659
|
-
] }),
|
|
2660
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2661
|
-
/* @__PURE__ */ jsxs(
|
|
2662
|
-
"button",
|
|
2663
|
-
{
|
|
2664
|
-
type: "button",
|
|
2665
|
-
className: "flex w-full items-center justify-between text-left",
|
|
2666
|
-
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
2667
|
-
"aria-expanded": gatewayExpanded,
|
|
2668
|
-
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
2669
|
-
children: [
|
|
2670
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
2671
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
2672
|
-
]
|
|
2673
|
-
}
|
|
2674
|
-
),
|
|
2675
|
-
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." }) })
|
|
2676
|
-
] })
|
|
2672
|
+
] }) }),
|
|
2673
|
+
Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2674
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
|
|
2675
|
+
/* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
|
|
2676
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
|
|
2677
2677
|
] }) : null
|
|
2678
2678
|
] }) });
|
|
2679
2679
|
};
|
|
2680
2680
|
const config = defineRouteConfig({
|
|
2681
|
-
label: "
|
|
2682
|
-
icon:
|
|
2681
|
+
label: "Payment details",
|
|
2682
|
+
icon: CreditCard
|
|
2683
2683
|
});
|
|
2684
2684
|
const i18nTranslations0 = {};
|
|
2685
2685
|
const widgetModule = { widgets: [
|
|
@@ -2694,10 +2694,6 @@ const widgetModule = { widgets: [
|
|
|
2694
2694
|
] };
|
|
2695
2695
|
const routeModule = {
|
|
2696
2696
|
routes: [
|
|
2697
|
-
{
|
|
2698
|
-
Component: PaymentsPage,
|
|
2699
|
-
path: "/payments"
|
|
2700
|
-
},
|
|
2701
2697
|
{
|
|
2702
2698
|
Component: SwapsPage,
|
|
2703
2699
|
path: "/swaps"
|
|
@@ -2711,46 +2707,50 @@ const routeModule = {
|
|
|
2711
2707
|
path: "/returns"
|
|
2712
2708
|
},
|
|
2713
2709
|
{
|
|
2714
|
-
Component:
|
|
2715
|
-
path: "/payments
|
|
2710
|
+
Component: PaymentsPage,
|
|
2711
|
+
path: "/payments"
|
|
2716
2712
|
},
|
|
2717
2713
|
{
|
|
2718
2714
|
Component: SwapDetailPage,
|
|
2719
2715
|
path: "/swaps/:id"
|
|
2720
2716
|
},
|
|
2717
|
+
{
|
|
2718
|
+
Component: RefundDetailPage,
|
|
2719
|
+
path: "/refunds/:id"
|
|
2720
|
+
},
|
|
2721
2721
|
{
|
|
2722
2722
|
Component: ReturnDetailPage,
|
|
2723
2723
|
path: "/returns/:id"
|
|
2724
2724
|
},
|
|
2725
2725
|
{
|
|
2726
|
-
Component:
|
|
2727
|
-
path: "/
|
|
2726
|
+
Component: PaymentDetailPage,
|
|
2727
|
+
path: "/payments/:id"
|
|
2728
2728
|
}
|
|
2729
2729
|
]
|
|
2730
2730
|
};
|
|
2731
2731
|
const menuItemModule = {
|
|
2732
2732
|
menuItems: [
|
|
2733
2733
|
{
|
|
2734
|
-
label: config$
|
|
2735
|
-
icon: config$
|
|
2734
|
+
label: config$5.label,
|
|
2735
|
+
icon: config$5.icon,
|
|
2736
2736
|
path: "/returns",
|
|
2737
2737
|
nested: void 0
|
|
2738
2738
|
},
|
|
2739
2739
|
{
|
|
2740
|
-
label: config$
|
|
2741
|
-
icon: config$
|
|
2740
|
+
label: config$6.label,
|
|
2741
|
+
icon: config$6.icon,
|
|
2742
2742
|
path: "/refunds",
|
|
2743
2743
|
nested: void 0
|
|
2744
2744
|
},
|
|
2745
2745
|
{
|
|
2746
|
-
label: config$
|
|
2747
|
-
icon: config$
|
|
2746
|
+
label: config$4.label,
|
|
2747
|
+
icon: config$4.icon,
|
|
2748
2748
|
path: "/payments",
|
|
2749
2749
|
nested: void 0
|
|
2750
2750
|
},
|
|
2751
2751
|
{
|
|
2752
|
-
label: config$
|
|
2753
|
-
icon: config$
|
|
2752
|
+
label: config$7.label,
|
|
2753
|
+
icon: config$7.icon,
|
|
2754
2754
|
path: "/swaps",
|
|
2755
2755
|
nested: void 0
|
|
2756
2756
|
},
|
|
@@ -2763,18 +2763,18 @@ const menuItemModule = {
|
|
|
2763
2763
|
{
|
|
2764
2764
|
label: config.label,
|
|
2765
2765
|
icon: config.icon,
|
|
2766
|
-
path: "/refunds/:id",
|
|
2767
|
-
nested: void 0
|
|
2768
|
-
},
|
|
2769
|
-
{
|
|
2770
|
-
label: config$3.label,
|
|
2771
|
-
icon: config$3.icon,
|
|
2772
2766
|
path: "/payments/:id",
|
|
2773
2767
|
nested: void 0
|
|
2774
2768
|
},
|
|
2775
2769
|
{
|
|
2776
2770
|
label: config$2.label,
|
|
2777
2771
|
icon: config$2.icon,
|
|
2772
|
+
path: "/refunds/:id",
|
|
2773
|
+
nested: void 0
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
label: config$3.label,
|
|
2777
|
+
icon: config$3.icon,
|
|
2778
2778
|
path: "/swaps/:id",
|
|
2779
2779
|
nested: void 0
|
|
2780
2780
|
}
|