order-management 0.0.89 → 0.0.90

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.
@@ -873,216 +873,16 @@ const getStatusBadgeClass$7 = (status) => {
873
873
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
874
874
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
875
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
- const s2 = status.toLowerCase();
1070
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1071
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1072
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1073
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1074
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1075
- };
1076
876
  const RefundsPage = () => {
1077
877
  const navigate = reactRouterDom.useNavigate();
1078
878
  const [items, setItems] = react.useState([]);
1079
879
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
1080
- const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
880
+ const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
1081
881
  const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
1082
882
  const [providerSearch, setProviderSearch] = react.useState("");
1083
- const debouncedProvider = useDebounce$2(providerSearch, 300);
883
+ const debouncedProvider = useDebounce$3(providerSearch, 300);
1084
884
  const [currencySearch, setCurrencySearch] = react.useState("");
1085
- const debouncedCurrency = useDebounce$2(currencySearch, 300);
885
+ const debouncedCurrency = useDebounce$3(currencySearch, 300);
1086
886
  const [dateFrom, setDateFrom] = react.useState("");
1087
887
  const [dateTo, setDateTo] = react.useState("");
1088
888
  const [amountMin, setAmountMin] = react.useState("");
@@ -1294,7 +1094,7 @@ const RefundsPage = () => {
1294
1094
  ui.Badge,
1295
1095
  {
1296
1096
  size: "2xsmall",
1297
- className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
1097
+ className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
1298
1098
  children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
1299
1099
  }
1300
1100
  ) }),
@@ -1348,11 +1148,11 @@ const RefundsPage = () => {
1348
1148
  ) }) : null
1349
1149
  ] }) });
1350
1150
  };
1351
- const config$6 = adminSdk.defineRouteConfig({
1151
+ const config$7 = adminSdk.defineRouteConfig({
1352
1152
  label: "Refunds",
1353
1153
  icon: icons.Receipt
1354
1154
  });
1355
- const useDebounce$1 = (value, delay) => {
1155
+ const useDebounce$2 = (value, delay) => {
1356
1156
  const [debouncedValue, setDebouncedValue] = react.useState(value);
1357
1157
  react.useEffect(() => {
1358
1158
  const handler = setTimeout(() => setDebouncedValue(value), delay);
@@ -1360,7 +1160,7 @@ const useDebounce$1 = (value, delay) => {
1360
1160
  }, [value, delay]);
1361
1161
  return debouncedValue;
1362
1162
  };
1363
- const getStatusBadgeClass$5 = (status) => {
1163
+ const getStatusBadgeClass$6 = (status) => {
1364
1164
  const statusLower = status.toLowerCase();
1365
1165
  if (statusLower === "requested") {
1366
1166
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -1385,7 +1185,7 @@ const ReturnsPage = () => {
1385
1185
  const [statusFilter, setStatusFilter] = react.useState("all");
1386
1186
  const [createdByFilter, setCreatedByFilter] = react.useState("all");
1387
1187
  const [searchQuery, setSearchQuery] = react.useState("");
1388
- const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
1188
+ const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
1389
1189
  const [isLoading, setIsLoading] = react.useState(true);
1390
1190
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1391
1191
  const [error, setError] = react.useState(null);
@@ -1531,7 +1331,7 @@ const ReturnsPage = () => {
1531
1331
  ui.Badge,
1532
1332
  {
1533
1333
  size: "2xsmall",
1534
- className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
1334
+ className: `uppercase ${getStatusBadgeClass$6(returnOrder.status)}`,
1535
1335
  children: returnOrder.status.replace(/_/g, " ")
1536
1336
  }
1537
1337
  ) }),
@@ -1580,11 +1380,11 @@ const ReturnsPage = () => {
1580
1380
  ) }) : null
1581
1381
  ] }) });
1582
1382
  };
1583
- const config$5 = adminSdk.defineRouteConfig({
1383
+ const config$6 = adminSdk.defineRouteConfig({
1584
1384
  label: "Return Orders",
1585
1385
  icon: icons.ArrowPath
1586
1386
  });
1587
- const useDebounce = (value, delay) => {
1387
+ const useDebounce$1 = (value, delay) => {
1588
1388
  const [debouncedValue, setDebouncedValue] = react.useState(value);
1589
1389
  react.useEffect(() => {
1590
1390
  const handler = setTimeout(() => setDebouncedValue(value), delay);
@@ -1592,7 +1392,7 @@ const useDebounce = (value, delay) => {
1592
1392
  }, [value, delay]);
1593
1393
  return debouncedValue;
1594
1394
  };
1595
- const getStatusBadgeClass$4 = (status) => {
1395
+ const getStatusBadgeClass$5 = (status) => {
1596
1396
  const statusLower = status.toLowerCase();
1597
1397
  if (statusLower === "requested") {
1598
1398
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -1617,7 +1417,7 @@ const SwapsPage = () => {
1617
1417
  const [statusFilter, setStatusFilter] = react.useState("all");
1618
1418
  const [createdByFilter, setCreatedByFilter] = react.useState("all");
1619
1419
  const [searchQuery, setSearchQuery] = react.useState("");
1620
- const debouncedSearchQuery = useDebounce(searchQuery, 300);
1420
+ const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
1621
1421
  const [isLoading, setIsLoading] = react.useState(true);
1622
1422
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1623
1423
  const [error, setError] = react.useState(null);
@@ -1760,7 +1560,7 @@ const SwapsPage = () => {
1760
1560
  ui.Badge,
1761
1561
  {
1762
1562
  size: "2xsmall",
1763
- className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
1563
+ className: `uppercase ${getStatusBadgeClass$5(swap.status)}`,
1764
1564
  children: swap.status.replace(/_/g, " ")
1765
1565
  }
1766
1566
  ) }),
@@ -1810,11 +1610,11 @@ const SwapsPage = () => {
1810
1610
  ) }) : null
1811
1611
  ] }) });
1812
1612
  };
1813
- const config$4 = adminSdk.defineRouteConfig({
1613
+ const config$5 = adminSdk.defineRouteConfig({
1814
1614
  label: "Exchanges",
1815
1615
  icon: icons.ArrowPath
1816
1616
  });
1817
- const getStatusBadgeClass$3 = (status) => {
1617
+ const getStatusBadgeClass$4 = (status) => {
1818
1618
  const s2 = status.toLowerCase();
1819
1619
  if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1820
1620
  if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
@@ -1822,14 +1622,18 @@ const getStatusBadgeClass$3 = (status) => {
1822
1622
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1823
1623
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1824
1624
  };
1825
- const PaymentDetailPage = () => {
1826
- var _a;
1625
+ const formatAmount = (value) => {
1626
+ return String(value);
1627
+ };
1628
+ const RefundDetailPage = () => {
1629
+ var _a, _b, _c;
1827
1630
  const navigate = reactRouterDom.useNavigate();
1828
1631
  const params = reactRouterDom.useParams();
1829
1632
  const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
1830
1633
  const [detail, setDetail] = react.useState(null);
1831
1634
  const [loading, setLoading] = react.useState(!!id);
1832
1635
  const [error, setError] = react.useState(null);
1636
+ const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
1833
1637
  react.useEffect(() => {
1834
1638
  if (!id) {
1835
1639
  setLoading(false);
@@ -1838,7 +1642,7 @@ const PaymentDetailPage = () => {
1838
1642
  let cancelled = false;
1839
1643
  setLoading(true);
1840
1644
  setError(null);
1841
- fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
1645
+ fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
1842
1646
  if (!res.ok) throw new Error(res.statusText || "Failed to load");
1843
1647
  return res.json();
1844
1648
  }).then((data) => {
@@ -1852,140 +1656,17 @@ const PaymentDetailPage = () => {
1852
1656
  cancelled = true;
1853
1657
  };
1854
1658
  }, [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)}` : "";
1659
+ const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
1660
+ 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;
1859
1661
  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
1662
  /* @__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 ?? "—" })
1663
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
1664
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
1665
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
1864
1666
  ] }) }),
1865
1667
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1866
1668
  /* @__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
- ] })
1924
- ] }) }),
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
1930
- ] }) });
1931
- };
1932
- const config$3 = adminSdk.defineRouteConfig({
1933
- label: "Payment details",
1934
- icon: icons.CreditCard
1935
- });
1936
- const getStatusBadgeClass$2 = (status) => {
1937
- const s2 = status.toLowerCase();
1938
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1939
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1940
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1941
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1942
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1943
- };
1944
- const formatAmount = (value) => {
1945
- return String(value);
1946
- };
1947
- const RefundDetailPage = () => {
1948
- var _a, _b, _c;
1949
- const navigate = reactRouterDom.useNavigate();
1950
- const params = reactRouterDom.useParams();
1951
- const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
1952
- const [detail, setDetail] = react.useState(null);
1953
- const [loading, setLoading] = react.useState(!!id);
1954
- const [error, setError] = react.useState(null);
1955
- const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
1956
- react.useEffect(() => {
1957
- if (!id) {
1958
- setLoading(false);
1959
- return;
1960
- }
1961
- let cancelled = false;
1962
- setLoading(true);
1963
- setError(null);
1964
- fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
1965
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
1966
- return res.json();
1967
- }).then((data) => {
1968
- if (!cancelled) setDetail(data);
1969
- }).catch((e) => {
1970
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
1971
- }).finally(() => {
1972
- if (!cancelled) setLoading(false);
1973
- });
1974
- return () => {
1975
- cancelled = true;
1976
- };
1977
- }, [id]);
1978
- const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
1979
- 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;
1980
- 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: [
1981
- /* @__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: [
1982
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
1983
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
1984
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
1985
- ] }) }),
1986
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1987
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1988
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
1669
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
1989
1670
  ] }) : 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: [
1990
1671
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
1991
1672
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
@@ -2044,7 +1725,7 @@ const RefundDetailPage = () => {
2044
1725
  ui.Badge,
2045
1726
  {
2046
1727
  size: "2xsmall",
2047
- className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
1728
+ className: `uppercase ${getStatusBadgeClass$4(paymentStatus)}`,
2048
1729
  children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
2049
1730
  }
2050
1731
  ) })
@@ -2121,11 +1802,11 @@ const RefundDetailPage = () => {
2121
1802
  ] }) : null
2122
1803
  ] }) });
2123
1804
  };
2124
- const config$2 = adminSdk.defineRouteConfig({
1805
+ const config$4 = adminSdk.defineRouteConfig({
2125
1806
  label: "Refund details",
2126
1807
  icon: icons.Receipt
2127
1808
  });
2128
- const getStatusBadgeClass$1 = (status) => {
1809
+ const getStatusBadgeClass$3 = (status) => {
2129
1810
  const statusLower = status.toLowerCase();
2130
1811
  if (statusLower === "requested") {
2131
1812
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -2259,7 +1940,7 @@ const ReturnDetailPage = () => {
2259
1940
  ui.Badge,
2260
1941
  {
2261
1942
  size: "small",
2262
- className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
1943
+ className: `uppercase ${getStatusBadgeClass$3(returnOrder.status)}`,
2263
1944
  children: returnOrder.status.replace(/_/g, " ")
2264
1945
  }
2265
1946
  )
@@ -2341,7 +2022,7 @@ const ReturnDetailPage = () => {
2341
2022
  ui.Badge,
2342
2023
  {
2343
2024
  size: "2xsmall",
2344
- className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
2025
+ className: `uppercase ${getStatusBadgeClass$3(entry.status)}`,
2345
2026
  children: entry.status.replace(/_/g, " ")
2346
2027
  }
2347
2028
  ) }),
@@ -2399,11 +2080,11 @@ const ReturnDetailPage = () => {
2399
2080
  updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
2400
2081
  ] }) });
2401
2082
  };
2402
- const config$1 = adminSdk.defineRouteConfig({
2083
+ const config$3 = adminSdk.defineRouteConfig({
2403
2084
  label: "Return Order Details",
2404
2085
  icon: icons.CheckCircle
2405
2086
  });
2406
- const getStatusBadgeClass = (status) => {
2087
+ const getStatusBadgeClass$2 = (status) => {
2407
2088
  const statusLower = status.toLowerCase();
2408
2089
  if (statusLower === "requested") {
2409
2090
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -2541,7 +2222,7 @@ const SwapDetailPage = () => {
2541
2222
  ui.Badge,
2542
2223
  {
2543
2224
  size: "small",
2544
- className: `uppercase ${getStatusBadgeClass(swap.status)}`,
2225
+ className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
2545
2226
  children: swap.status.replace(/_/g, " ")
2546
2227
  }
2547
2228
  )
@@ -2609,7 +2290,7 @@ const SwapDetailPage = () => {
2609
2290
  ui.Badge,
2610
2291
  {
2611
2292
  size: "2xsmall",
2612
- className: `uppercase ${getStatusBadgeClass(entry.status)}`,
2293
+ className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
2613
2294
  children: entry.status.replace(/_/g, " ")
2614
2295
  }
2615
2296
  ) }),
@@ -2678,10 +2359,329 @@ const SwapDetailPage = () => {
2678
2359
  ] })
2679
2360
  ] }) });
2680
2361
  };
2681
- const config = adminSdk.defineRouteConfig({
2362
+ const config$2 = adminSdk.defineRouteConfig({
2682
2363
  label: "Swap Details",
2683
2364
  icon: icons.ArrowPath
2684
2365
  });
2366
+ const useDebounce = (value, delay) => {
2367
+ const [debouncedValue, setDebouncedValue] = react.useState(value);
2368
+ react.useEffect(() => {
2369
+ const handler = setTimeout(() => setDebouncedValue(value), delay);
2370
+ return () => clearTimeout(handler);
2371
+ }, [value, delay]);
2372
+ return debouncedValue;
2373
+ };
2374
+ const getStatusBadgeClass$1 = (status) => {
2375
+ const s2 = status.toLowerCase();
2376
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2377
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2378
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2379
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2380
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2381
+ };
2382
+ const PaymentsPage = () => {
2383
+ const navigate = reactRouterDom.useNavigate();
2384
+ const [items, setItems] = react.useState([]);
2385
+ const [statusFilter, setStatusFilter] = react.useState("all");
2386
+ const [orderIdSearch, setOrderIdSearch] = react.useState("");
2387
+ const debouncedOrderId = useDebounce(orderIdSearch, 300);
2388
+ const [isLoading, setIsLoading] = react.useState(true);
2389
+ const [isFetchingMore, setIsFetchingMore] = react.useState(false);
2390
+ const [error, setError] = react.useState(null);
2391
+ const [offset, setOffset] = react.useState(0);
2392
+ const [count, setCount] = react.useState(0);
2393
+ const limit = 50;
2394
+ const loadTransactions = react.useCallback(
2395
+ async (nextOffset, replace) => {
2396
+ try {
2397
+ if (replace) setIsLoading(true);
2398
+ else setIsFetchingMore(true);
2399
+ setError(null);
2400
+ const params = new URLSearchParams();
2401
+ params.set("limit", String(limit));
2402
+ params.set("offset", String(nextOffset));
2403
+ if (statusFilter !== "all") params.set("status", statusFilter);
2404
+ if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2405
+ const response = await fetch(
2406
+ `/admin/payment-transactions?${params.toString()}`,
2407
+ { credentials: "include" }
2408
+ );
2409
+ if (!response.ok) {
2410
+ const text = await response.text();
2411
+ throw new Error(text || "Failed to load payment transactions");
2412
+ }
2413
+ const payload = await response.json();
2414
+ const list = payload.transactions ?? [];
2415
+ setCount(payload.count ?? 0);
2416
+ setOffset(nextOffset + list.length);
2417
+ setItems((prev) => replace ? list : [...prev, ...list]);
2418
+ } catch (e) {
2419
+ setError(e instanceof Error ? e.message : "Failed to load");
2420
+ } finally {
2421
+ setIsLoading(false);
2422
+ setIsFetchingMore(false);
2423
+ }
2424
+ },
2425
+ [statusFilter, debouncedOrderId]
2426
+ );
2427
+ react.useEffect(() => {
2428
+ void loadTransactions(0, true);
2429
+ }, [loadTransactions]);
2430
+ const hasMore = react.useMemo(() => offset < count, [offset, count]);
2431
+ const displayStatus = (t) => {
2432
+ const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2433
+ return s2 !== "" ? s2 : "—";
2434
+ };
2435
+ const displayAmount = (t) => {
2436
+ const code = (t.currency_code ?? "USD").toUpperCase();
2437
+ return `${code} ${Number(t.amount)}`;
2438
+ };
2439
+ 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: [
2440
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2441
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
2442
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
2443
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2444
+ ] }),
2445
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2446
+ ] }),
2447
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2448
+ /* @__PURE__ */ jsxRuntime.jsx(
2449
+ ui.Input,
2450
+ {
2451
+ placeholder: "Search by Order ID",
2452
+ value: orderIdSearch,
2453
+ onChange: (e) => setOrderIdSearch(e.target.value),
2454
+ className: "md:max-w-sm",
2455
+ "aria-label": "Search by order ID"
2456
+ }
2457
+ ),
2458
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
2459
+ "select",
2460
+ {
2461
+ value: statusFilter,
2462
+ onChange: (e) => setStatusFilter(e.target.value),
2463
+ 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",
2464
+ "aria-label": "Filter by status",
2465
+ children: [
2466
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
2467
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
2468
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
2469
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
2470
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
2471
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
2472
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
2473
+ ]
2474
+ }
2475
+ ) })
2476
+ ] }),
2477
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2478
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2479
+ /* @__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" }) })
2480
+ ] }) : null,
2481
+ 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: [
2482
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2483
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2484
+ ] }) : /* @__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: [
2485
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
2486
+ /* @__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" }),
2487
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2488
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2489
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2490
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2491
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2492
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2493
+ ] }) }),
2494
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
2495
+ "tr",
2496
+ {
2497
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2498
+ onClick: () => navigate(`/payments/${t.payment_session_id}`),
2499
+ children: [
2500
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2501
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2502
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2503
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
2504
+ ui.Badge,
2505
+ {
2506
+ size: "2xsmall",
2507
+ className: `uppercase ${getStatusBadgeClass$1(displayStatus(t))}`,
2508
+ children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2509
+ }
2510
+ ) }),
2511
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2512
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2513
+ year: "numeric",
2514
+ month: "short",
2515
+ day: "numeric",
2516
+ hour: "numeric",
2517
+ minute: "2-digit",
2518
+ hour12: true
2519
+ }) }),
2520
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
2521
+ /* @__PURE__ */ jsxRuntime.jsx(
2522
+ ui.Button,
2523
+ {
2524
+ variant: "transparent",
2525
+ size: "small",
2526
+ onClick: (e) => {
2527
+ e.stopPropagation();
2528
+ navigate(`/payments/${t.payment_session_id}`);
2529
+ },
2530
+ children: "View details"
2531
+ }
2532
+ ),
2533
+ t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2534
+ ui.Button,
2535
+ {
2536
+ variant: "transparent",
2537
+ size: "small",
2538
+ onClick: (e) => {
2539
+ e.stopPropagation();
2540
+ navigate(`/orders/${t.order_id}`);
2541
+ },
2542
+ children: "Order"
2543
+ }
2544
+ ) : null
2545
+ ] })
2546
+ ]
2547
+ },
2548
+ t.payment_session_id
2549
+ )) })
2550
+ ] }) }),
2551
+ hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
2552
+ ui.Button,
2553
+ {
2554
+ variant: "secondary",
2555
+ isLoading: isFetchingMore,
2556
+ onClick: () => loadTransactions(offset, false),
2557
+ children: "Load more"
2558
+ }
2559
+ ) }) : null
2560
+ ] }) });
2561
+ };
2562
+ const config$1 = adminSdk.defineRouteConfig({
2563
+ label: "Payments",
2564
+ icon: icons.CreditCard
2565
+ });
2566
+ const getStatusBadgeClass = (status) => {
2567
+ const s2 = status.toLowerCase();
2568
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2569
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2570
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2571
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2572
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2573
+ };
2574
+ const PaymentDetailPage = () => {
2575
+ var _a;
2576
+ const navigate = reactRouterDom.useNavigate();
2577
+ const params = reactRouterDom.useParams();
2578
+ const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
2579
+ const [detail, setDetail] = react.useState(null);
2580
+ const [loading, setLoading] = react.useState(!!id);
2581
+ const [error, setError] = react.useState(null);
2582
+ react.useEffect(() => {
2583
+ if (!id) {
2584
+ setLoading(false);
2585
+ return;
2586
+ }
2587
+ let cancelled = false;
2588
+ setLoading(true);
2589
+ setError(null);
2590
+ fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
2591
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
2592
+ return res.json();
2593
+ }).then((data) => {
2594
+ if (!cancelled) setDetail(data);
2595
+ }).catch((e) => {
2596
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
2597
+ }).finally(() => {
2598
+ if (!cancelled) setLoading(false);
2599
+ });
2600
+ return () => {
2601
+ cancelled = true;
2602
+ };
2603
+ }, [id]);
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)}` : "";
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: [
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: [
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 ?? "—" })
2613
+ ] }) }),
2614
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2615
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2616
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
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: [
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
+ }) })
2672
+ ] })
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
+ ] }) : null
2679
+ ] }) });
2680
+ };
2681
+ const config = adminSdk.defineRouteConfig({
2682
+ label: "Payment details",
2683
+ icon: icons.CreditCard
2684
+ });
2685
2685
  const i18nTranslations0 = {};
2686
2686
  const widgetModule = { widgets: [
2687
2687
  {
@@ -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: RefundsPage,
2704
2700
  path: "/refunds"
@@ -2711,10 +2707,6 @@ const routeModule = {
2711
2707
  Component: SwapsPage,
2712
2708
  path: "/swaps"
2713
2709
  },
2714
- {
2715
- Component: PaymentDetailPage,
2716
- path: "/payments/:id"
2717
- },
2718
2710
  {
2719
2711
  Component: RefundDetailPage,
2720
2712
  path: "/refunds/:id"
@@ -2726,56 +2718,64 @@ const routeModule = {
2726
2718
  {
2727
2719
  Component: SwapDetailPage,
2728
2720
  path: "/swaps/:id"
2721
+ },
2722
+ {
2723
+ Component: PaymentsPage,
2724
+ path: "/payments"
2725
+ },
2726
+ {
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$7.label,
2736
- icon: config$7.icon,
2735
+ label: config$6.label,
2736
+ icon: config$6.icon,
2737
+ path: "/returns",
2738
+ nested: void 0
2739
+ },
2740
+ {
2741
+ label: config$1.label,
2742
+ icon: config$1.icon,
2737
2743
  path: "/payments",
2738
2744
  nested: void 0
2739
2745
  },
2740
2746
  {
2741
- label: config$6.label,
2742
- icon: config$6.icon,
2747
+ label: config$7.label,
2748
+ icon: config$7.icon,
2743
2749
  path: "/refunds",
2744
2750
  nested: void 0
2745
2751
  },
2746
2752
  {
2747
2753
  label: config$5.label,
2748
2754
  icon: config$5.icon,
2749
- path: "/returns",
2750
- nested: void 0
2751
- },
2752
- {
2753
- label: config$4.label,
2754
- icon: config$4.icon,
2755
2755
  path: "/swaps",
2756
2756
  nested: void 0
2757
2757
  },
2758
2758
  {
2759
2759
  label: config$3.label,
2760
2760
  icon: config$3.icon,
2761
- path: "/payments/:id",
2761
+ path: "/returns/:id",
2762
2762
  nested: void 0
2763
2763
  },
2764
2764
  {
2765
- label: config$2.label,
2766
- icon: config$2.icon,
2765
+ label: config$4.label,
2766
+ icon: config$4.icon,
2767
2767
  path: "/refunds/:id",
2768
2768
  nested: void 0
2769
2769
  },
2770
2770
  {
2771
- label: config$1.label,
2772
- icon: config$1.icon,
2773
- path: "/returns/:id",
2771
+ label: config.label,
2772
+ icon: config.icon,
2773
+ path: "/payments/:id",
2774
2774
  nested: void 0
2775
2775
  },
2776
2776
  {
2777
- label: config.label,
2778
- icon: config.icon,
2777
+ label: config$2.label,
2778
+ icon: config$2.icon,
2779
2779
  path: "/swaps/:id",
2780
2780
  nested: void 0
2781
2781
  }