order-management 0.0.75 → 0.0.76

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,19 +873,27 @@ 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 = () => {
876
+ const RefundsPage = () => {
877
877
  const navigate = reactRouterDom.useNavigate();
878
878
  const [items, setItems] = react.useState([]);
879
- const [statusFilter, setStatusFilter] = react.useState("all");
880
879
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
881
880
  const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
881
+ const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
882
+ const [providerSearch, setProviderSearch] = react.useState("");
883
+ const debouncedProvider = useDebounce$3(providerSearch, 300);
884
+ const [currencySearch, setCurrencySearch] = react.useState("");
885
+ const debouncedCurrency = useDebounce$3(currencySearch, 300);
886
+ const [dateFrom, setDateFrom] = react.useState("");
887
+ const [dateTo, setDateTo] = react.useState("");
888
+ const [amountMin, setAmountMin] = react.useState("");
889
+ const [amountMax, setAmountMax] = react.useState("");
882
890
  const [isLoading, setIsLoading] = react.useState(true);
883
891
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
884
892
  const [error, setError] = react.useState(null);
885
893
  const [offset, setOffset] = react.useState(0);
886
894
  const [count, setCount] = react.useState(0);
887
895
  const limit = 50;
888
- const loadTransactions = react.useCallback(
896
+ const loadRefunds = react.useCallback(
889
897
  async (nextOffset, replace) => {
890
898
  try {
891
899
  if (replace) setIsLoading(true);
@@ -894,18 +902,25 @@ const PaymentsPage = () => {
894
902
  const params = new URLSearchParams();
895
903
  params.set("limit", String(limit));
896
904
  params.set("offset", String(nextOffset));
897
- if (statusFilter !== "all") params.set("status", statusFilter);
898
905
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
899
- const response = await fetch(
900
- `/admin/payment-transactions?${params.toString()}`,
901
- { credentials: "include" }
902
- );
906
+ if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
907
+ if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
908
+ if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
909
+ if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
910
+ if (dateTo.trim()) params.set("date_to", dateTo.trim());
911
+ const min = amountMin.trim() ? Number(amountMin) : void 0;
912
+ const max = amountMax.trim() ? Number(amountMax) : void 0;
913
+ if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
914
+ if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
915
+ const response = await fetch(`/admin/refunds?${params.toString()}`, {
916
+ credentials: "include"
917
+ });
903
918
  if (!response.ok) {
904
919
  const text = await response.text();
905
- throw new Error(text || "Failed to load payment transactions");
920
+ throw new Error(text || "Failed to load refunds");
906
921
  }
907
922
  const payload = await response.json();
908
- const list = payload.transactions ?? [];
923
+ const list = payload.refunds ?? [];
909
924
  setCount(payload.count ?? 0);
910
925
  setOffset(nextOffset + list.length);
911
926
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -916,46 +931,75 @@ const PaymentsPage = () => {
916
931
  setIsFetchingMore(false);
917
932
  }
918
933
  },
919
- [statusFilter, debouncedOrderId]
934
+ [
935
+ debouncedOrderId,
936
+ paymentStatusFilter,
937
+ debouncedProvider,
938
+ debouncedCurrency,
939
+ dateFrom,
940
+ dateTo,
941
+ amountMin,
942
+ amountMax
943
+ ]
920
944
  );
921
945
  react.useEffect(() => {
922
- void loadTransactions(0, true);
923
- }, [loadTransactions]);
946
+ void loadRefunds(0, true);
947
+ }, [loadRefunds]);
924
948
  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 : "—";
949
+ const displayAmount = (r) => {
950
+ const code = (r.currency_code ?? "USD").toUpperCase();
951
+ return `${code} ${Number(r.amount)}`;
928
952
  };
929
- const displayAmount = (t) => {
930
- const code = (t.currency_code ?? "USD").toUpperCase();
931
- return `${code} ${Number(t.amount)}`;
953
+ const displayStatus = (r) => {
954
+ const s2 = r.payment_status ?? "";
955
+ return s2 !== "" ? s2 : "—";
932
956
  };
933
957
  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
958
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
935
959
  /* @__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" })
960
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refunds" }),
961
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund recordsamount, order, payment status" })
938
962
  ] }),
939
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
963
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
940
964
  ] }),
941
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
965
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
942
966
  /* @__PURE__ */ jsxRuntime.jsx(
943
967
  ui.Input,
944
968
  {
945
- placeholder: "Search by Order ID",
969
+ placeholder: "Order ID",
946
970
  value: orderIdSearch,
947
971
  onChange: (e) => setOrderIdSearch(e.target.value),
948
- className: "md:max-w-sm",
949
- "aria-label": "Search by order ID"
972
+ className: "md:max-w-[180px]",
973
+ "aria-label": "Filter by order ID"
950
974
  }
951
975
  ),
952
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
976
+ /* @__PURE__ */ jsxRuntime.jsx(
977
+ ui.Input,
978
+ {
979
+ placeholder: "Provider",
980
+ value: providerSearch,
981
+ onChange: (e) => setProviderSearch(e.target.value),
982
+ className: "md:max-w-[140px]",
983
+ "aria-label": "Filter by provider"
984
+ }
985
+ ),
986
+ /* @__PURE__ */ jsxRuntime.jsx(
987
+ ui.Input,
988
+ {
989
+ placeholder: "Currency",
990
+ value: currencySearch,
991
+ onChange: (e) => setCurrencySearch(e.target.value),
992
+ className: "md:max-w-[100px]",
993
+ "aria-label": "Filter by currency"
994
+ }
995
+ ),
996
+ /* @__PURE__ */ jsxRuntime.jsxs(
953
997
  "select",
954
998
  {
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",
999
+ value: paymentStatusFilter,
1000
+ onChange: (e) => setPaymentStatusFilter(e.target.value),
1001
+ 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-[160px]",
1002
+ "aria-label": "Filter by payment status",
959
1003
  children: [
960
1004
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
961
1005
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
@@ -966,52 +1010,103 @@ const PaymentsPage = () => {
966
1010
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
967
1011
  ]
968
1012
  }
969
- ) })
970
- ] }),
1013
+ ),
1014
+ /* @__PURE__ */ jsxRuntime.jsx(
1015
+ ui.Input,
1016
+ {
1017
+ type: "date",
1018
+ placeholder: "From",
1019
+ value: dateFrom,
1020
+ onChange: (e) => setDateFrom(e.target.value),
1021
+ className: "md:max-w-[140px]",
1022
+ "aria-label": "Date from"
1023
+ }
1024
+ ),
1025
+ /* @__PURE__ */ jsxRuntime.jsx(
1026
+ ui.Input,
1027
+ {
1028
+ type: "date",
1029
+ placeholder: "To",
1030
+ value: dateTo,
1031
+ onChange: (e) => setDateTo(e.target.value),
1032
+ className: "md:max-w-[140px]",
1033
+ "aria-label": "Date to"
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ jsxRuntime.jsx(
1037
+ ui.Input,
1038
+ {
1039
+ placeholder: "Amount min",
1040
+ value: amountMin,
1041
+ onChange: (e) => setAmountMin(e.target.value),
1042
+ type: "number",
1043
+ min: 0,
1044
+ className: "md:max-w-[100px]",
1045
+ "aria-label": "Refund amount minimum"
1046
+ }
1047
+ ),
1048
+ /* @__PURE__ */ jsxRuntime.jsx(
1049
+ ui.Input,
1050
+ {
1051
+ placeholder: "Amount max",
1052
+ value: amountMax,
1053
+ onChange: (e) => setAmountMax(e.target.value),
1054
+ type: "number",
1055
+ min: 0,
1056
+ className: "md:max-w-[100px]",
1057
+ "aria-label": "Refund amount maximum"
1058
+ }
1059
+ )
1060
+ ] }) }),
971
1061
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
972
1062
  /* @__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" }) })
1063
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
974
1064
  ] }) : 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: [
1065
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1066
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
1067
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
1068
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
979
1069
  /* @__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" })
1070
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
1071
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
1072
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
1073
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
1074
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
1075
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
1076
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
1077
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
1078
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1079
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
987
1080
  ] }) }),
988
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
1081
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
989
1082
  "tr",
990
1083
  {
991
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
992
- onClick: () => navigate(`/payments/${t.payment_session_id}`),
1084
+ className: "cursor-pointer hover:bg-ui-bg-subtle/60",
1085
+ onClick: () => navigate(`/refunds/${r.refund_id}`),
993
1086
  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(
1087
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
1088
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
1089
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
1090
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
1091
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
1092
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
1093
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
998
1094
  ui.Badge,
999
1095
  {
1000
1096
  size: "2xsmall",
1001
- className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
1002
- children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
1097
+ className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
1098
+ children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
1003
1099
  }
1004
1100
  ) }),
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",
1101
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "" }),
1102
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
1008
1103
  month: "short",
1009
1104
  day: "numeric",
1010
1105
  hour: "numeric",
1011
1106
  minute: "2-digit",
1012
1107
  hour12: true
1013
1108
  }) }),
1014
- /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
1109
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
1015
1110
  /* @__PURE__ */ jsxRuntime.jsx(
1016
1111
  ui.Button,
1017
1112
  {
@@ -1019,27 +1114,27 @@ const PaymentsPage = () => {
1019
1114
  size: "small",
1020
1115
  onClick: (e) => {
1021
1116
  e.stopPropagation();
1022
- navigate(`/payments/${t.payment_session_id}`);
1117
+ navigate(`/refunds/${r.refund_id}`);
1023
1118
  },
1024
- children: "View details"
1119
+ children: "Details"
1025
1120
  }
1026
1121
  ),
1027
- t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1122
+ r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1028
1123
  ui.Button,
1029
1124
  {
1030
1125
  variant: "transparent",
1031
1126
  size: "small",
1032
1127
  onClick: (e) => {
1033
1128
  e.stopPropagation();
1034
- navigate(`/orders/${t.order_id}`);
1129
+ navigate(`/orders/${r.order_id}`);
1035
1130
  },
1036
1131
  children: "Order"
1037
1132
  }
1038
1133
  ) : null
1039
- ] })
1134
+ ] }) })
1040
1135
  ]
1041
1136
  },
1042
- t.payment_session_id
1137
+ r.refund_id
1043
1138
  )) })
1044
1139
  ] }) }),
1045
1140
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1047,15 +1142,15 @@ const PaymentsPage = () => {
1047
1142
  {
1048
1143
  variant: "secondary",
1049
1144
  isLoading: isFetchingMore,
1050
- onClick: () => loadTransactions(offset, false),
1145
+ onClick: () => loadRefunds(offset, false),
1051
1146
  children: "Load more"
1052
1147
  }
1053
1148
  ) }) : null
1054
1149
  ] }) });
1055
1150
  };
1056
1151
  const config$7 = adminSdk.defineRouteConfig({
1057
- label: "Payments",
1058
- icon: icons.CreditCard
1152
+ label: "Refunds",
1153
+ icon: icons.Receipt
1059
1154
  });
1060
1155
  const useDebounce$2 = (value, delay) => {
1061
1156
  const [debouncedValue, setDebouncedValue] = react.useState(value);
@@ -1073,27 +1168,19 @@ const getStatusBadgeClass$6 = (status) => {
1073
1168
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1074
1169
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1075
1170
  };
1076
- const RefundsPage = () => {
1171
+ const PaymentsPage = () => {
1077
1172
  const navigate = reactRouterDom.useNavigate();
1078
1173
  const [items, setItems] = react.useState([]);
1174
+ const [statusFilter, setStatusFilter] = react.useState("all");
1079
1175
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
1080
1176
  const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
1081
- const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
1082
- const [providerSearch, setProviderSearch] = react.useState("");
1083
- const debouncedProvider = useDebounce$2(providerSearch, 300);
1084
- const [currencySearch, setCurrencySearch] = react.useState("");
1085
- const debouncedCurrency = useDebounce$2(currencySearch, 300);
1086
- const [dateFrom, setDateFrom] = react.useState("");
1087
- const [dateTo, setDateTo] = react.useState("");
1088
- const [amountMin, setAmountMin] = react.useState("");
1089
- const [amountMax, setAmountMax] = react.useState("");
1090
1177
  const [isLoading, setIsLoading] = react.useState(true);
1091
1178
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1092
1179
  const [error, setError] = react.useState(null);
1093
1180
  const [offset, setOffset] = react.useState(0);
1094
1181
  const [count, setCount] = react.useState(0);
1095
1182
  const limit = 50;
1096
- const loadRefunds = react.useCallback(
1183
+ const loadTransactions = react.useCallback(
1097
1184
  async (nextOffset, replace) => {
1098
1185
  try {
1099
1186
  if (replace) setIsLoading(true);
@@ -1102,25 +1189,18 @@ const RefundsPage = () => {
1102
1189
  const params = new URLSearchParams();
1103
1190
  params.set("limit", String(limit));
1104
1191
  params.set("offset", String(nextOffset));
1192
+ if (statusFilter !== "all") params.set("status", statusFilter);
1105
1193
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
1106
- if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
1107
- if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
1108
- if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
1109
- if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
1110
- if (dateTo.trim()) params.set("date_to", dateTo.trim());
1111
- const min = amountMin.trim() ? Number(amountMin) : void 0;
1112
- const max = amountMax.trim() ? Number(amountMax) : void 0;
1113
- if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
1114
- if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
1115
- const response = await fetch(`/admin/refunds?${params.toString()}`, {
1116
- credentials: "include"
1117
- });
1194
+ const response = await fetch(
1195
+ `/admin/payment-transactions?${params.toString()}`,
1196
+ { credentials: "include" }
1197
+ );
1118
1198
  if (!response.ok) {
1119
1199
  const text = await response.text();
1120
- throw new Error(text || "Failed to load refunds");
1200
+ throw new Error(text || "Failed to load payment transactions");
1121
1201
  }
1122
1202
  const payload = await response.json();
1123
- const list = payload.refunds ?? [];
1203
+ const list = payload.transactions ?? [];
1124
1204
  setCount(payload.count ?? 0);
1125
1205
  setOffset(nextOffset + list.length);
1126
1206
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -1131,75 +1211,46 @@ const RefundsPage = () => {
1131
1211
  setIsFetchingMore(false);
1132
1212
  }
1133
1213
  },
1134
- [
1135
- debouncedOrderId,
1136
- paymentStatusFilter,
1137
- debouncedProvider,
1138
- debouncedCurrency,
1139
- dateFrom,
1140
- dateTo,
1141
- amountMin,
1142
- amountMax
1143
- ]
1214
+ [statusFilter, debouncedOrderId]
1144
1215
  );
1145
1216
  react.useEffect(() => {
1146
- void loadRefunds(0, true);
1147
- }, [loadRefunds]);
1217
+ void loadTransactions(0, true);
1218
+ }, [loadTransactions]);
1148
1219
  const hasMore = react.useMemo(() => offset < count, [offset, count]);
1149
- const displayAmount = (r) => {
1150
- const code = (r.currency_code ?? "USD").toUpperCase();
1151
- return `${code} ${Number(r.amount)}`;
1152
- };
1153
- const displayStatus = (r) => {
1154
- const s2 = r.payment_status ?? "";
1220
+ const displayStatus = (t) => {
1221
+ const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
1155
1222
  return s2 !== "" ? s2 : "—";
1156
1223
  };
1224
+ const displayAmount = (t) => {
1225
+ const code = (t.currency_code ?? "USD").toUpperCase();
1226
+ return `${code} ${Number(t.amount)}`;
1227
+ };
1157
1228
  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: [
1158
1229
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1159
1230
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1160
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refunds" }),
1161
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund recordsamount, order, payment status" })
1231
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
1232
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts completed, pending, failed, requires action" })
1162
1233
  ] }),
1163
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
1234
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
1164
1235
  ] }),
1165
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
1236
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1166
1237
  /* @__PURE__ */ jsxRuntime.jsx(
1167
1238
  ui.Input,
1168
1239
  {
1169
- placeholder: "Order ID",
1240
+ placeholder: "Search by Order ID",
1170
1241
  value: orderIdSearch,
1171
1242
  onChange: (e) => setOrderIdSearch(e.target.value),
1172
- className: "md:max-w-[180px]",
1173
- "aria-label": "Filter by order ID"
1174
- }
1175
- ),
1176
- /* @__PURE__ */ jsxRuntime.jsx(
1177
- ui.Input,
1178
- {
1179
- placeholder: "Provider",
1180
- value: providerSearch,
1181
- onChange: (e) => setProviderSearch(e.target.value),
1182
- className: "md:max-w-[140px]",
1183
- "aria-label": "Filter by provider"
1184
- }
1185
- ),
1186
- /* @__PURE__ */ jsxRuntime.jsx(
1187
- ui.Input,
1188
- {
1189
- placeholder: "Currency",
1190
- value: currencySearch,
1191
- onChange: (e) => setCurrencySearch(e.target.value),
1192
- className: "md:max-w-[100px]",
1193
- "aria-label": "Filter by currency"
1243
+ className: "md:max-w-sm",
1244
+ "aria-label": "Search by order ID"
1194
1245
  }
1195
1246
  ),
1196
- /* @__PURE__ */ jsxRuntime.jsxs(
1247
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
1197
1248
  "select",
1198
1249
  {
1199
- value: paymentStatusFilter,
1200
- onChange: (e) => setPaymentStatusFilter(e.target.value),
1201
- 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-[160px]",
1202
- "aria-label": "Filter by payment status",
1250
+ value: statusFilter,
1251
+ onChange: (e) => setStatusFilter(e.target.value),
1252
+ 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",
1253
+ "aria-label": "Filter by status",
1203
1254
  children: [
1204
1255
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
1205
1256
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
@@ -1210,103 +1261,52 @@ const RefundsPage = () => {
1210
1261
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
1211
1262
  ]
1212
1263
  }
1213
- ),
1214
- /* @__PURE__ */ jsxRuntime.jsx(
1215
- ui.Input,
1216
- {
1217
- type: "date",
1218
- placeholder: "From",
1219
- value: dateFrom,
1220
- onChange: (e) => setDateFrom(e.target.value),
1221
- className: "md:max-w-[140px]",
1222
- "aria-label": "Date from"
1223
- }
1224
- ),
1225
- /* @__PURE__ */ jsxRuntime.jsx(
1226
- ui.Input,
1227
- {
1228
- type: "date",
1229
- placeholder: "To",
1230
- value: dateTo,
1231
- onChange: (e) => setDateTo(e.target.value),
1232
- className: "md:max-w-[140px]",
1233
- "aria-label": "Date to"
1234
- }
1235
- ),
1236
- /* @__PURE__ */ jsxRuntime.jsx(
1237
- ui.Input,
1238
- {
1239
- placeholder: "Amount min",
1240
- value: amountMin,
1241
- onChange: (e) => setAmountMin(e.target.value),
1242
- type: "number",
1243
- min: 0,
1244
- className: "md:max-w-[100px]",
1245
- "aria-label": "Refund amount minimum"
1246
- }
1247
- ),
1248
- /* @__PURE__ */ jsxRuntime.jsx(
1249
- ui.Input,
1250
- {
1251
- placeholder: "Amount max",
1252
- value: amountMax,
1253
- onChange: (e) => setAmountMax(e.target.value),
1254
- type: "number",
1255
- min: 0,
1256
- className: "md:max-w-[100px]",
1257
- "aria-label": "Refund amount maximum"
1258
- }
1259
- )
1260
- ] }) }),
1264
+ ) })
1265
+ ] }),
1261
1266
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1262
1267
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1263
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
1268
+ /* @__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" }) })
1264
1269
  ] }) : null,
1265
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1266
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
1267
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
1268
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
1270
+ 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: [
1271
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
1272
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
1273
+ ] }) : /* @__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: [
1269
1274
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1270
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
1271
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
1272
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
1273
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
1274
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
1275
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
1276
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
1277
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
1278
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1279
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1275
+ /* @__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" }),
1276
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
1277
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
1278
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1279
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
1280
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1281
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1280
1282
  ] }) }),
1281
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
1283
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
1282
1284
  "tr",
1283
1285
  {
1284
- className: "cursor-pointer hover:bg-ui-bg-subtle/60",
1285
- onClick: () => navigate(`/refunds/${r.refund_id}`),
1286
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1287
+ onClick: () => navigate(`/payments/${t.payment_session_id}`),
1286
1288
  children: [
1287
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
1288
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
1289
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
1290
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
1291
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
1292
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
1293
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
1289
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
1290
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
1291
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
1292
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1294
1293
  ui.Badge,
1295
1294
  {
1296
1295
  size: "2xsmall",
1297
- className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
1298
- children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
1296
+ className: `uppercase ${getStatusBadgeClass$6(displayStatus(t))}`,
1297
+ children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
1299
1298
  }
1300
1299
  ) }),
1301
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "" }),
1302
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
1300
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
1301
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
1302
+ year: "numeric",
1303
1303
  month: "short",
1304
1304
  day: "numeric",
1305
1305
  hour: "numeric",
1306
1306
  minute: "2-digit",
1307
1307
  hour12: true
1308
1308
  }) }),
1309
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
1309
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
1310
1310
  /* @__PURE__ */ jsxRuntime.jsx(
1311
1311
  ui.Button,
1312
1312
  {
@@ -1314,27 +1314,27 @@ const RefundsPage = () => {
1314
1314
  size: "small",
1315
1315
  onClick: (e) => {
1316
1316
  e.stopPropagation();
1317
- navigate(`/refunds/${r.refund_id}`);
1317
+ navigate(`/payments/${t.payment_session_id}`);
1318
1318
  },
1319
- children: "Details"
1319
+ children: "View details"
1320
1320
  }
1321
1321
  ),
1322
- r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1322
+ t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1323
1323
  ui.Button,
1324
1324
  {
1325
1325
  variant: "transparent",
1326
1326
  size: "small",
1327
1327
  onClick: (e) => {
1328
1328
  e.stopPropagation();
1329
- navigate(`/orders/${r.order_id}`);
1329
+ navigate(`/orders/${t.order_id}`);
1330
1330
  },
1331
1331
  children: "Order"
1332
1332
  }
1333
1333
  ) : null
1334
- ] }) })
1334
+ ] })
1335
1335
  ]
1336
1336
  },
1337
- r.refund_id
1337
+ t.payment_session_id
1338
1338
  )) })
1339
1339
  ] }) }),
1340
1340
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1342,15 +1342,15 @@ const RefundsPage = () => {
1342
1342
  {
1343
1343
  variant: "secondary",
1344
1344
  isLoading: isFetchingMore,
1345
- onClick: () => loadRefunds(offset, false),
1345
+ onClick: () => loadTransactions(offset, false),
1346
1346
  children: "Load more"
1347
1347
  }
1348
1348
  ) }) : null
1349
1349
  ] }) });
1350
1350
  };
1351
1351
  const config$6 = adminSdk.defineRouteConfig({
1352
- label: "Refunds",
1353
- icon: icons.Receipt
1352
+ label: "Payments",
1353
+ icon: icons.CreditCard
1354
1354
  });
1355
1355
  const useDebounce$1 = (value, delay) => {
1356
1356
  const [debouncedValue, setDebouncedValue] = react.useState(value);
@@ -1726,214 +1726,95 @@ const SwapsPage = () => {
1726
1726
  ] })
1727
1727
  ] }),
1728
1728
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1729
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1730
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1731
- ui.Button,
1732
- {
1733
- variant: "secondary",
1734
- onClick: () => loadSwaps(0, true),
1735
- children: "Try again"
1736
- }
1737
- ) })
1738
- ] }) : null,
1739
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1740
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
1741
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
1742
- ] }) : /* @__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: [
1743
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1744
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
1745
- /* @__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" }),
1746
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1747
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
1748
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1749
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1750
- ] }) }),
1751
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
1752
- "tr",
1753
- {
1754
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1755
- onClick: () => navigate(`/swaps/${swap.id}`),
1756
- children: [
1757
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: swap.id }) }) }),
1758
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
1759
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1760
- ui.Badge,
1761
- {
1762
- size: "2xsmall",
1763
- className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
1764
- children: swap.status.replace(/_/g, " ")
1765
- }
1766
- ) }),
1767
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
1768
- const amount = swap.difference_due;
1769
- if (amount == null || amount === void 0) {
1770
- return "—";
1771
- }
1772
- const displayAmount = Number(amount) / 100;
1773
- const currency = swap.currency_code || "$";
1774
- const sign = displayAmount >= 0 ? "+" : "";
1775
- return `${sign}${currency}${displayAmount.toFixed(2)}`;
1776
- })() }),
1777
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
1778
- year: "numeric",
1779
- month: "short",
1780
- day: "numeric",
1781
- hour: "numeric",
1782
- minute: "2-digit",
1783
- hour12: true
1784
- }) }),
1785
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1786
- ui.Button,
1787
- {
1788
- variant: "transparent",
1789
- size: "small",
1790
- onClick: (e) => {
1791
- e.stopPropagation();
1792
- navigate(`/app/orders/${swap.order_id}`);
1793
- },
1794
- children: "Go to order"
1795
- }
1796
- ) })
1797
- ]
1798
- },
1799
- swap.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: () => loadSwaps(offset, false),
1808
- children: "Load more"
1809
- }
1810
- ) }) : null
1811
- ] }) });
1812
- };
1813
- const config$4 = adminSdk.defineRouteConfig({
1814
- label: "Exchanges",
1815
- icon: icons.ArrowPath
1816
- });
1817
- const getStatusBadgeClass$3 = (status) => {
1818
- const s2 = status.toLowerCase();
1819
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1820
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1821
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1822
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1823
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1824
- };
1825
- const PaymentDetailPage = () => {
1826
- var _a;
1827
- 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);
1832
- 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
- ] }) }),
1865
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1866
- /* @__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
- ] })
1729
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1730
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1731
+ ui.Button,
1732
+ {
1733
+ variant: "secondary",
1734
+ onClick: () => loadSwaps(0, true),
1735
+ children: "Try again"
1736
+ }
1737
+ ) })
1738
+ ] }) : null,
1739
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1740
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
1741
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
1742
+ ] }) : /* @__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: [
1743
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1744
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
1745
+ /* @__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" }),
1746
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1747
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
1748
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1749
+ /* @__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
1750
  ] }) }),
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
1751
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
1752
+ "tr",
1753
+ {
1754
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1755
+ onClick: () => navigate(`/swaps/${swap.id}`),
1756
+ children: [
1757
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: swap.id }) }) }),
1758
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
1759
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1760
+ ui.Badge,
1761
+ {
1762
+ size: "2xsmall",
1763
+ className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
1764
+ children: swap.status.replace(/_/g, " ")
1765
+ }
1766
+ ) }),
1767
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
1768
+ const amount = swap.difference_due;
1769
+ if (amount == null || amount === void 0) {
1770
+ return "—";
1771
+ }
1772
+ const displayAmount = Number(amount) / 100;
1773
+ const currency = swap.currency_code || "$";
1774
+ const sign = displayAmount >= 0 ? "+" : "";
1775
+ return `${sign}${currency}${displayAmount.toFixed(2)}`;
1776
+ })() }),
1777
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
1778
+ year: "numeric",
1779
+ month: "short",
1780
+ day: "numeric",
1781
+ hour: "numeric",
1782
+ minute: "2-digit",
1783
+ hour12: true
1784
+ }) }),
1785
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1786
+ ui.Button,
1787
+ {
1788
+ variant: "transparent",
1789
+ size: "small",
1790
+ onClick: (e) => {
1791
+ e.stopPropagation();
1792
+ navigate(`/app/orders/${swap.order_id}`);
1793
+ },
1794
+ children: "Go to order"
1795
+ }
1796
+ ) })
1797
+ ]
1798
+ },
1799
+ swap.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: () => loadSwaps(offset, false),
1808
+ children: "Load more"
1809
+ }
1810
+ ) }) : null
1930
1811
  ] }) });
1931
1812
  };
1932
- const config$3 = adminSdk.defineRouteConfig({
1933
- label: "Payment details",
1934
- icon: icons.CreditCard
1813
+ const config$4 = adminSdk.defineRouteConfig({
1814
+ label: "Exchanges",
1815
+ icon: icons.ArrowPath
1935
1816
  });
1936
- const getStatusBadgeClass$2 = (status) => {
1817
+ const getStatusBadgeClass$3 = (status) => {
1937
1818
  const s2 = status.toLowerCase();
1938
1819
  if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1939
1820
  if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
@@ -2044,7 +1925,7 @@ const RefundDetailPage = () => {
2044
1925
  ui.Badge,
2045
1926
  {
2046
1927
  size: "2xsmall",
2047
- className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
1928
+ className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
2048
1929
  children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
2049
1930
  }
2050
1931
  ) })
@@ -2121,10 +2002,129 @@ const RefundDetailPage = () => {
2121
2002
  ] }) : null
2122
2003
  ] }) });
2123
2004
  };
2124
- const config$2 = adminSdk.defineRouteConfig({
2005
+ const config$3 = adminSdk.defineRouteConfig({
2125
2006
  label: "Refund details",
2126
2007
  icon: icons.Receipt
2127
2008
  });
2009
+ const getStatusBadgeClass$2 = (status) => {
2010
+ const s2 = status.toLowerCase();
2011
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2012
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2013
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2014
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2015
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2016
+ };
2017
+ const PaymentDetailPage = () => {
2018
+ var _a;
2019
+ const navigate = reactRouterDom.useNavigate();
2020
+ const params = reactRouterDom.useParams();
2021
+ const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
2022
+ const [detail, setDetail] = react.useState(null);
2023
+ const [loading, setLoading] = react.useState(!!id);
2024
+ const [error, setError] = react.useState(null);
2025
+ react.useEffect(() => {
2026
+ if (!id) {
2027
+ setLoading(false);
2028
+ return;
2029
+ }
2030
+ let cancelled = false;
2031
+ setLoading(true);
2032
+ setError(null);
2033
+ fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
2034
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
2035
+ return res.json();
2036
+ }).then((data) => {
2037
+ if (!cancelled) setDetail(data);
2038
+ }).catch((e) => {
2039
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
2040
+ }).finally(() => {
2041
+ if (!cancelled) setLoading(false);
2042
+ });
2043
+ return () => {
2044
+ cancelled = true;
2045
+ };
2046
+ }, [id]);
2047
+ const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
2048
+ const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
2049
+ const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
2050
+ const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
2051
+ 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: [
2052
+ /* @__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: [
2053
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
2054
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payment session" }),
2055
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
2056
+ ] }) }),
2057
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2058
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2059
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
2060
+ ] }) : 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: [
2061
+ /* @__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: [
2062
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2063
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
2064
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2065
+ ui.Button,
2066
+ {
2067
+ variant: "transparent",
2068
+ size: "small",
2069
+ onClick: () => navigate(`/orders/${detail.order_id}`),
2070
+ children: detail.order_id
2071
+ }
2072
+ ) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
2073
+ ] }),
2074
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2075
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
2076
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
2077
+ ] }),
2078
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2079
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
2080
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
2081
+ ] }),
2082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2083
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
2084
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2085
+ ui.Badge,
2086
+ {
2087
+ size: "2xsmall",
2088
+ className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
2089
+ children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
2090
+ }
2091
+ ) })
2092
+ ] }),
2093
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2094
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
2095
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
2096
+ ] }),
2097
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2098
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
2099
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
2100
+ ] }),
2101
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2102
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
2103
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
2104
+ ] }),
2105
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2106
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
2107
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
2108
+ year: "numeric",
2109
+ month: "short",
2110
+ day: "numeric",
2111
+ hour: "numeric",
2112
+ minute: "2-digit",
2113
+ hour12: true
2114
+ }) })
2115
+ ] })
2116
+ ] }) }),
2117
+ Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2118
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
2119
+ /* @__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) })
2120
+ ] }) : /* @__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." }) })
2121
+ ] }) : null
2122
+ ] }) });
2123
+ };
2124
+ const config$2 = adminSdk.defineRouteConfig({
2125
+ label: "Payment details",
2126
+ icon: icons.CreditCard
2127
+ });
2128
2128
  const getStatusBadgeClass$1 = (status) => {
2129
2129
  const statusLower = status.toLowerCase();
2130
2130
  if (statusLower === "requested") {
@@ -2695,14 +2695,14 @@ 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"
2705
2701
  },
2702
+ {
2703
+ Component: PaymentsPage,
2704
+ path: "/payments"
2705
+ },
2706
2706
  {
2707
2707
  Component: ReturnsPage,
2708
2708
  path: "/returns"
@@ -2711,14 +2711,14 @@ const routeModule = {
2711
2711
  Component: SwapsPage,
2712
2712
  path: "/swaps"
2713
2713
  },
2714
- {
2715
- Component: PaymentDetailPage,
2716
- path: "/payments/:id"
2717
- },
2718
2714
  {
2719
2715
  Component: RefundDetailPage,
2720
2716
  path: "/refunds/:id"
2721
2717
  },
2718
+ {
2719
+ Component: PaymentDetailPage,
2720
+ path: "/payments/:id"
2721
+ },
2722
2722
  {
2723
2723
  Component: ReturnDetailPage,
2724
2724
  path: "/returns/:id"
@@ -2734,6 +2734,12 @@ const menuItemModule = {
2734
2734
  {
2735
2735
  label: config$6.label,
2736
2736
  icon: config$6.icon,
2737
+ path: "/payments",
2738
+ nested: void 0
2739
+ },
2740
+ {
2741
+ label: config$7.label,
2742
+ icon: config$7.icon,
2737
2743
  path: "/refunds",
2738
2744
  nested: void 0
2739
2745
  },
@@ -2750,21 +2756,15 @@ const menuItemModule = {
2750
2756
  nested: void 0
2751
2757
  },
2752
2758
  {
2753
- label: config$7.label,
2754
- icon: config$7.icon,
2755
- path: "/payments",
2759
+ label: config$3.label,
2760
+ icon: config$3.icon,
2761
+ path: "/refunds/:id",
2756
2762
  nested: void 0
2757
2763
  },
2758
2764
  {
2759
2765
  label: config$2.label,
2760
2766
  icon: config$2.icon,
2761
- path: "/refunds/:id",
2762
- nested: void 0
2763
- },
2764
- {
2765
- label: config$1.label,
2766
- icon: config$1.icon,
2767
- path: "/returns/:id",
2767
+ path: "/payments/:id",
2768
2768
  nested: void 0
2769
2769
  },
2770
2770
  {
@@ -2774,9 +2774,9 @@ const menuItemModule = {
2774
2774
  nested: void 0
2775
2775
  },
2776
2776
  {
2777
- label: config$3.label,
2778
- icon: config$3.icon,
2779
- path: "/payments/:id",
2777
+ label: config$1.label,
2778
+ icon: config$1.icon,
2779
+ path: "/returns/:id",
2780
2780
  nested: void 0
2781
2781
  }
2782
2782
  ]