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