order-management 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -866,188 +866,144 @@ const useDebounce$3 = (value, delay) => {
|
|
|
866
866
|
return debouncedValue;
|
|
867
867
|
};
|
|
868
868
|
const getStatusBadgeClass$7 = (status) => {
|
|
869
|
-
const
|
|
870
|
-
if (
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
if (
|
|
874
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
875
|
-
}
|
|
876
|
-
if (statusLower === "rejected") {
|
|
877
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
878
|
-
}
|
|
879
|
-
if (statusLower === "completed") {
|
|
880
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
881
|
-
}
|
|
882
|
-
if (statusLower === "cancelled") {
|
|
883
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
884
|
-
}
|
|
869
|
+
const s2 = status.toLowerCase();
|
|
870
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
871
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
872
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
873
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
885
874
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
886
875
|
};
|
|
887
|
-
const
|
|
876
|
+
const PaymentsPage = () => {
|
|
888
877
|
const navigate = reactRouterDom.useNavigate();
|
|
889
878
|
const [items, setItems] = react.useState([]);
|
|
890
879
|
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
891
|
-
const [
|
|
892
|
-
const
|
|
893
|
-
const debouncedSearchQuery = useDebounce$3(searchQuery, 300);
|
|
880
|
+
const [orderIdSearch, setOrderIdSearch] = react.useState("");
|
|
881
|
+
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
894
882
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
895
883
|
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
896
884
|
const [error, setError] = react.useState(null);
|
|
897
885
|
const [offset, setOffset] = react.useState(0);
|
|
898
886
|
const [count, setCount] = react.useState(0);
|
|
899
887
|
const limit = 50;
|
|
900
|
-
const
|
|
901
|
-
async (nextOffset, replace
|
|
902
|
-
var _a;
|
|
888
|
+
const loadTransactions = react.useCallback(
|
|
889
|
+
async (nextOffset, replace) => {
|
|
903
890
|
try {
|
|
904
|
-
if (replace)
|
|
905
|
-
|
|
906
|
-
} else {
|
|
907
|
-
setIsFetchingMore(true);
|
|
908
|
-
}
|
|
891
|
+
if (replace) setIsLoading(true);
|
|
892
|
+
else setIsFetchingMore(true);
|
|
909
893
|
setError(null);
|
|
910
894
|
const params = new URLSearchParams();
|
|
911
895
|
params.set("limit", String(limit));
|
|
912
896
|
params.set("offset", String(nextOffset));
|
|
913
|
-
if (statusFilter !== "all")
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
if (debouncedSearchQuery.trim()) {
|
|
917
|
-
params.set("order_id", debouncedSearchQuery.trim());
|
|
918
|
-
}
|
|
919
|
-
if (createdByFilter !== "all") {
|
|
920
|
-
params.set("created_by", createdByFilter);
|
|
921
|
-
}
|
|
897
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
898
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
922
899
|
const response = await fetch(
|
|
923
|
-
`/admin/
|
|
900
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
924
901
|
{ credentials: "include" }
|
|
925
902
|
);
|
|
926
903
|
if (!response.ok) {
|
|
927
|
-
const
|
|
928
|
-
throw new Error(
|
|
904
|
+
const text = await response.text();
|
|
905
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
929
906
|
}
|
|
930
907
|
const payload = await response.json();
|
|
908
|
+
const list = payload.transactions ?? [];
|
|
931
909
|
setCount(payload.count ?? 0);
|
|
932
|
-
setOffset(nextOffset +
|
|
933
|
-
setItems(
|
|
934
|
-
|
|
935
|
-
);
|
|
936
|
-
} catch (loadError) {
|
|
937
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
938
|
-
setError(message);
|
|
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");
|
|
939
914
|
} finally {
|
|
940
915
|
setIsLoading(false);
|
|
941
916
|
setIsFetchingMore(false);
|
|
942
917
|
}
|
|
943
918
|
},
|
|
944
|
-
[statusFilter,
|
|
919
|
+
[statusFilter, debouncedOrderId]
|
|
945
920
|
);
|
|
946
921
|
react.useEffect(() => {
|
|
947
|
-
void
|
|
948
|
-
}, [
|
|
922
|
+
void loadTransactions(0, true);
|
|
923
|
+
}, [loadTransactions]);
|
|
949
924
|
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
950
|
-
const
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
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
|
+
};
|
|
955
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: [
|
|
956
934
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
957
935
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
958
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
959
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", 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
938
|
] }),
|
|
961
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () =>
|
|
939
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
962
940
|
] }),
|
|
963
941
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
964
942
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
965
943
|
ui.Input,
|
|
966
944
|
{
|
|
967
|
-
placeholder: "Search by
|
|
968
|
-
value:
|
|
969
|
-
onChange: (
|
|
970
|
-
className: "md:max-w-sm"
|
|
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"
|
|
971
950
|
}
|
|
972
951
|
),
|
|
973
|
-
/* @__PURE__ */ jsxRuntime.
|
|
974
|
-
|
|
975
|
-
"select",
|
|
976
|
-
{
|
|
977
|
-
value: createdByFilter,
|
|
978
|
-
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
979
|
-
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",
|
|
980
|
-
children: [
|
|
981
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
|
|
982
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
|
|
983
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
|
|
984
|
-
]
|
|
985
|
-
}
|
|
986
|
-
),
|
|
987
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
988
|
-
"select",
|
|
989
|
-
{
|
|
990
|
-
value: statusFilter,
|
|
991
|
-
onChange: (event) => setStatusFilter(event.target.value),
|
|
992
|
-
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",
|
|
993
|
-
children: [
|
|
994
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
|
|
995
|
-
availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
996
|
-
]
|
|
997
|
-
}
|
|
998
|
-
)
|
|
999
|
-
] })
|
|
1000
|
-
] }),
|
|
1001
|
-
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1002
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1003
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1004
|
-
ui.Button,
|
|
952
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
953
|
+
"select",
|
|
1005
954
|
{
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
+
]
|
|
1009
968
|
}
|
|
1010
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" }) })
|
|
1011
974
|
] }) : null,
|
|
1012
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading
|
|
1013
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No
|
|
1014
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
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." })
|
|
1015
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: [
|
|
1016
979
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1017
|
-
/* @__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" }),
|
|
1018
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" }),
|
|
1019
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" }),
|
|
1020
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
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" }),
|
|
1021
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" }),
|
|
1022
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" })
|
|
1023
987
|
] }) }),
|
|
1024
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
988
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1025
989
|
"tr",
|
|
1026
990
|
{
|
|
1027
991
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1028
|
-
onClick: () => navigate(`/
|
|
992
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1029
993
|
children: [
|
|
1030
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children:
|
|
1031
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", 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 }),
|
|
1032
997
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1033
998
|
ui.Badge,
|
|
1034
999
|
{
|
|
1035
1000
|
size: "2xsmall",
|
|
1036
|
-
className: `uppercase ${getStatusBadgeClass$7(
|
|
1037
|
-
children:
|
|
1001
|
+
className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
|
|
1002
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1038
1003
|
}
|
|
1039
1004
|
) }),
|
|
1040
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1041
|
-
|
|
1042
|
-
if (amount == null || amount === void 0) {
|
|
1043
|
-
return "—";
|
|
1044
|
-
}
|
|
1045
|
-
const displayAmount = Number(amount) / 100;
|
|
1046
|
-
const currency = swap.currency_code || "$";
|
|
1047
|
-
const sign = displayAmount >= 0 ? "+" : "";
|
|
1048
|
-
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1049
|
-
})() }),
|
|
1050
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
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", {
|
|
1051
1007
|
year: "numeric",
|
|
1052
1008
|
month: "short",
|
|
1053
1009
|
day: "numeric",
|
|
@@ -1055,21 +1011,35 @@ const SwapsPage = () => {
|
|
|
1055
1011
|
minute: "2-digit",
|
|
1056
1012
|
hour12: true
|
|
1057
1013
|
}) }),
|
|
1058
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
e
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
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
|
+
] })
|
|
1070
1040
|
]
|
|
1071
1041
|
},
|
|
1072
|
-
|
|
1042
|
+
t.payment_session_id
|
|
1073
1043
|
)) })
|
|
1074
1044
|
] }) }),
|
|
1075
1045
|
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1077,15 +1047,15 @@ const SwapsPage = () => {
|
|
|
1077
1047
|
{
|
|
1078
1048
|
variant: "secondary",
|
|
1079
1049
|
isLoading: isFetchingMore,
|
|
1080
|
-
onClick: () =>
|
|
1050
|
+
onClick: () => loadTransactions(offset, false),
|
|
1081
1051
|
children: "Load more"
|
|
1082
1052
|
}
|
|
1083
1053
|
) }) : null
|
|
1084
1054
|
] }) });
|
|
1085
1055
|
};
|
|
1086
1056
|
const config$7 = adminSdk.defineRouteConfig({
|
|
1087
|
-
label: "
|
|
1088
|
-
icon: icons.
|
|
1057
|
+
label: "Payments",
|
|
1058
|
+
icon: icons.CreditCard
|
|
1089
1059
|
});
|
|
1090
1060
|
const useDebounce$2 = (value, delay) => {
|
|
1091
1061
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
@@ -1623,144 +1593,188 @@ const useDebounce = (value, delay) => {
|
|
|
1623
1593
|
return debouncedValue;
|
|
1624
1594
|
};
|
|
1625
1595
|
const getStatusBadgeClass$4 = (status) => {
|
|
1626
|
-
const
|
|
1627
|
-
if (
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
if (
|
|
1631
|
-
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1596
|
+
const statusLower = status.toLowerCase();
|
|
1597
|
+
if (statusLower === "requested") {
|
|
1598
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1599
|
+
}
|
|
1600
|
+
if (statusLower === "approved") {
|
|
1601
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1602
|
+
}
|
|
1603
|
+
if (statusLower === "rejected") {
|
|
1604
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1605
|
+
}
|
|
1606
|
+
if (statusLower === "completed") {
|
|
1607
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1608
|
+
}
|
|
1609
|
+
if (statusLower === "cancelled") {
|
|
1610
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1611
|
+
}
|
|
1612
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1613
|
+
};
|
|
1614
|
+
const SwapsPage = () => {
|
|
1615
|
+
const navigate = reactRouterDom.useNavigate();
|
|
1616
|
+
const [items, setItems] = react.useState([]);
|
|
1617
|
+
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
1618
|
+
const [createdByFilter, setCreatedByFilter] = react.useState("all");
|
|
1619
|
+
const [searchQuery, setSearchQuery] = react.useState("");
|
|
1620
|
+
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1621
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
1622
|
+
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
1623
|
+
const [error, setError] = react.useState(null);
|
|
1624
|
+
const [offset, setOffset] = react.useState(0);
|
|
1625
|
+
const [count, setCount] = react.useState(0);
|
|
1626
|
+
const limit = 50;
|
|
1627
|
+
const loadSwaps = react.useCallback(
|
|
1628
|
+
async (nextOffset, replace = false) => {
|
|
1629
|
+
var _a;
|
|
1647
1630
|
try {
|
|
1648
|
-
if (replace)
|
|
1649
|
-
|
|
1631
|
+
if (replace) {
|
|
1632
|
+
setIsLoading(true);
|
|
1633
|
+
} else {
|
|
1634
|
+
setIsFetchingMore(true);
|
|
1635
|
+
}
|
|
1650
1636
|
setError(null);
|
|
1651
1637
|
const params = new URLSearchParams();
|
|
1652
1638
|
params.set("limit", String(limit));
|
|
1653
1639
|
params.set("offset", String(nextOffset));
|
|
1654
|
-
if (statusFilter !== "all")
|
|
1655
|
-
|
|
1640
|
+
if (statusFilter !== "all") {
|
|
1641
|
+
params.set("status", statusFilter);
|
|
1642
|
+
}
|
|
1643
|
+
if (debouncedSearchQuery.trim()) {
|
|
1644
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
1645
|
+
}
|
|
1646
|
+
if (createdByFilter !== "all") {
|
|
1647
|
+
params.set("created_by", createdByFilter);
|
|
1648
|
+
}
|
|
1656
1649
|
const response = await fetch(
|
|
1657
|
-
`/admin/
|
|
1650
|
+
`/admin/swaps?${params.toString()}`,
|
|
1658
1651
|
{ credentials: "include" }
|
|
1659
1652
|
);
|
|
1660
1653
|
if (!response.ok) {
|
|
1661
|
-
const
|
|
1662
|
-
throw new Error(
|
|
1654
|
+
const message = await response.text();
|
|
1655
|
+
throw new Error(message || "Unable to load swaps");
|
|
1663
1656
|
}
|
|
1664
1657
|
const payload = await response.json();
|
|
1665
|
-
const list = payload.transactions ?? [];
|
|
1666
1658
|
setCount(payload.count ?? 0);
|
|
1667
|
-
setOffset(nextOffset +
|
|
1668
|
-
setItems(
|
|
1669
|
-
|
|
1670
|
-
|
|
1659
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1660
|
+
setItems(
|
|
1661
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1662
|
+
);
|
|
1663
|
+
} catch (loadError) {
|
|
1664
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1665
|
+
setError(message);
|
|
1671
1666
|
} finally {
|
|
1672
1667
|
setIsLoading(false);
|
|
1673
1668
|
setIsFetchingMore(false);
|
|
1674
1669
|
}
|
|
1675
1670
|
},
|
|
1676
|
-
[statusFilter,
|
|
1671
|
+
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1677
1672
|
);
|
|
1678
1673
|
react.useEffect(() => {
|
|
1679
|
-
void
|
|
1680
|
-
}, [
|
|
1674
|
+
void loadSwaps(0, true);
|
|
1675
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1681
1676
|
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
1682
|
-
const
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1688
|
-
return `${code} ${Number(t.amount)}`;
|
|
1689
|
-
};
|
|
1677
|
+
const availableStatuses = react.useMemo(() => {
|
|
1678
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
1679
|
+
items.forEach((item) => statuses.add(item.status));
|
|
1680
|
+
return Array.from(statuses).sort();
|
|
1681
|
+
}, [items]);
|
|
1690
1682
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1691
1683
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1692
1684
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1693
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
1694
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1685
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Exchanges" }),
|
|
1686
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1695
1687
|
] }),
|
|
1696
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () =>
|
|
1688
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1697
1689
|
] }),
|
|
1698
1690
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1699
1691
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1700
1692
|
ui.Input,
|
|
1701
1693
|
{
|
|
1702
|
-
placeholder: "Search by
|
|
1703
|
-
value:
|
|
1704
|
-
onChange: (
|
|
1705
|
-
className: "md:max-w-sm"
|
|
1706
|
-
"aria-label": "Search by order ID"
|
|
1694
|
+
placeholder: "Search by swap ID or order ID",
|
|
1695
|
+
value: searchQuery,
|
|
1696
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
1697
|
+
className: "md:max-w-sm"
|
|
1707
1698
|
}
|
|
1708
1699
|
),
|
|
1709
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1700
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
1701
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1702
|
+
"select",
|
|
1703
|
+
{
|
|
1704
|
+
value: createdByFilter,
|
|
1705
|
+
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
1706
|
+
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",
|
|
1707
|
+
children: [
|
|
1708
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
|
|
1710
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
|
|
1711
|
+
]
|
|
1712
|
+
}
|
|
1713
|
+
),
|
|
1714
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1715
|
+
"select",
|
|
1716
|
+
{
|
|
1717
|
+
value: statusFilter,
|
|
1718
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
1719
|
+
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",
|
|
1720
|
+
children: [
|
|
1721
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
|
|
1722
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1723
|
+
]
|
|
1724
|
+
}
|
|
1725
|
+
)
|
|
1726
|
+
] })
|
|
1727
1727
|
] }),
|
|
1728
1728
|
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1729
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(
|
|
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
|
+
) })
|
|
1731
1738
|
] }) : null,
|
|
1732
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading
|
|
1733
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No
|
|
1734
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
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." })
|
|
1735
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: [
|
|
1736
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" }),
|
|
1737
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" }),
|
|
1738
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1739
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1740
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" }),
|
|
1741
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
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" }),
|
|
1742
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" }),
|
|
1743
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" })
|
|
1744
1750
|
] }) }),
|
|
1745
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1751
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1746
1752
|
"tr",
|
|
1747
1753
|
{
|
|
1748
1754
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1749
|
-
onClick: () => navigate(`/
|
|
1755
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1750
1756
|
children: [
|
|
1751
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children:
|
|
1752
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1753
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
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 }),
|
|
1754
1759
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1755
1760
|
ui.Badge,
|
|
1756
1761
|
{
|
|
1757
1762
|
size: "2xsmall",
|
|
1758
|
-
className: `uppercase ${getStatusBadgeClass$4(
|
|
1759
|
-
children:
|
|
1763
|
+
className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
|
|
1764
|
+
children: swap.status.replace(/_/g, " ")
|
|
1760
1765
|
}
|
|
1761
1766
|
) }),
|
|
1762
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1763
|
-
|
|
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", {
|
|
1764
1778
|
year: "numeric",
|
|
1765
1779
|
month: "short",
|
|
1766
1780
|
day: "numeric",
|
|
@@ -1768,35 +1782,21 @@ const PaymentsPage = () => {
|
|
|
1768
1782
|
minute: "2-digit",
|
|
1769
1783
|
hour12: true
|
|
1770
1784
|
}) }),
|
|
1771
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
),
|
|
1784
|
-
t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1785
|
-
ui.Button,
|
|
1786
|
-
{
|
|
1787
|
-
variant: "transparent",
|
|
1788
|
-
size: "small",
|
|
1789
|
-
onClick: (e) => {
|
|
1790
|
-
e.stopPropagation();
|
|
1791
|
-
navigate(`/orders/${t.order_id}`);
|
|
1792
|
-
},
|
|
1793
|
-
children: "Order"
|
|
1794
|
-
}
|
|
1795
|
-
) : null
|
|
1796
|
-
] })
|
|
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
1797
|
]
|
|
1798
1798
|
},
|
|
1799
|
-
|
|
1799
|
+
swap.id
|
|
1800
1800
|
)) })
|
|
1801
1801
|
] }) }),
|
|
1802
1802
|
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1804,294 +1804,134 @@ const PaymentsPage = () => {
|
|
|
1804
1804
|
{
|
|
1805
1805
|
variant: "secondary",
|
|
1806
1806
|
isLoading: isFetchingMore,
|
|
1807
|
-
onClick: () =>
|
|
1807
|
+
onClick: () => loadSwaps(offset, false),
|
|
1808
1808
|
children: "Load more"
|
|
1809
1809
|
}
|
|
1810
1810
|
) }) : null
|
|
1811
1811
|
] }) });
|
|
1812
1812
|
};
|
|
1813
1813
|
const config$4 = adminSdk.defineRouteConfig({
|
|
1814
|
-
label: "
|
|
1815
|
-
icon: icons.
|
|
1814
|
+
label: "Exchanges",
|
|
1815
|
+
icon: icons.ArrowPath
|
|
1816
1816
|
});
|
|
1817
1817
|
const getStatusBadgeClass$3 = (status) => {
|
|
1818
|
-
const
|
|
1819
|
-
if (
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
if (
|
|
1823
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1824
|
-
}
|
|
1825
|
-
if (statusLower === "rejected") {
|
|
1826
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1827
|
-
}
|
|
1828
|
-
if (statusLower === "completed") {
|
|
1829
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1830
|
-
}
|
|
1831
|
-
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
1832
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1833
|
-
}
|
|
1834
|
-
if (statusLower === "pending") {
|
|
1835
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1836
|
-
}
|
|
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";
|
|
1837
1823
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1838
1824
|
};
|
|
1839
|
-
const
|
|
1840
|
-
var _a
|
|
1825
|
+
const PaymentDetailPage = () => {
|
|
1826
|
+
var _a;
|
|
1841
1827
|
const navigate = reactRouterDom.useNavigate();
|
|
1842
|
-
const
|
|
1843
|
-
const
|
|
1844
|
-
const [
|
|
1845
|
-
const [
|
|
1846
|
-
react.useState(false);
|
|
1847
|
-
const [isCancelling, setIsCancelling] = react.useState(false);
|
|
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);
|
|
1848
1832
|
const [error, setError] = react.useState(null);
|
|
1849
|
-
const [updateError, setUpdateError] = react.useState(null);
|
|
1850
|
-
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
1851
1833
|
react.useEffect(() => {
|
|
1852
1834
|
if (!id) {
|
|
1853
|
-
|
|
1835
|
+
setLoading(false);
|
|
1854
1836
|
return;
|
|
1855
1837
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
1872
|
-
setError(message);
|
|
1873
|
-
} finally {
|
|
1874
|
-
setIsLoading(false);
|
|
1875
|
-
}
|
|
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;
|
|
1876
1853
|
};
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
const
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
});
|
|
1905
|
-
if (detailResponse.ok) {
|
|
1906
|
-
const detailPayload = await detailResponse.json();
|
|
1907
|
-
setSwap(detailPayload.swap);
|
|
1908
|
-
setOrder(detailPayload.order || null);
|
|
1909
|
-
}
|
|
1910
|
-
} catch (cancelErr) {
|
|
1911
|
-
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
1912
|
-
setUpdateError(message);
|
|
1913
|
-
} finally {
|
|
1914
|
-
setIsCancelling(false);
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
1918
|
-
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
1919
|
-
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
1920
|
-
);
|
|
1921
|
-
if (isLoading) {
|
|
1922
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
|
|
1923
|
-
}
|
|
1924
|
-
if (error || !swap) {
|
|
1925
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1926
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
1927
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
1928
|
-
] }) }) });
|
|
1929
|
-
}
|
|
1930
|
-
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
1931
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
1932
|
-
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
1933
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1934
|
-
ui.Button,
|
|
1935
|
-
{
|
|
1936
|
-
variant: "transparent",
|
|
1937
|
-
size: "small",
|
|
1938
|
-
onClick: () => navigate("/swaps"),
|
|
1939
|
-
className: "w-fit",
|
|
1940
|
-
children: [
|
|
1941
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
1942
|
-
"Back to list"
|
|
1943
|
-
]
|
|
1944
|
-
}
|
|
1945
|
-
),
|
|
1946
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
1947
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1948
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Exchange Details" }),
|
|
1949
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
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: "—" }) })
|
|
1950
1881
|
] }),
|
|
1951
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1952
|
-
ui.Badge,
|
|
1953
|
-
{
|
|
1954
|
-
size: "small",
|
|
1955
|
-
className: `uppercase ${getStatusBadgeClass$3(swap.status)}`,
|
|
1956
|
-
children: swap.status.replace(/_/g, " ")
|
|
1957
|
-
}
|
|
1958
|
-
)
|
|
1959
|
-
] })
|
|
1960
|
-
] }),
|
|
1961
|
-
canCancelExchange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
1962
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1963
|
-
ui.Button,
|
|
1964
|
-
{
|
|
1965
|
-
variant: "danger",
|
|
1966
|
-
onClick: handleCancelExchange,
|
|
1967
|
-
disabled: isCancelling,
|
|
1968
|
-
isLoading: isCancelling,
|
|
1969
|
-
children: "Cancel Exchange"
|
|
1970
|
-
}
|
|
1971
|
-
) }),
|
|
1972
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
1973
|
-
] }),
|
|
1974
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1975
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1976
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1977
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1978
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1979
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1980
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
1981
|
-
] }),
|
|
1982
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1983
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
1984
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
1985
|
-
] }),
|
|
1986
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1987
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
1988
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
1989
|
-
] }),
|
|
1990
|
-
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1991
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1992
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
1993
|
-
] }),
|
|
1994
|
-
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1995
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1996
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
1997
|
-
] }),
|
|
1998
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1999
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2000
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2001
|
-
] }),
|
|
2002
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2003
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2004
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2005
|
-
] }),
|
|
2006
|
-
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2007
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2008
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
2009
|
-
] })
|
|
2010
|
-
] })
|
|
2011
|
-
] }),
|
|
2012
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2013
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
2014
|
-
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2015
|
-
"div",
|
|
2016
|
-
{
|
|
2017
|
-
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
2018
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2019
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2020
|
-
ui.Badge,
|
|
2021
|
-
{
|
|
2022
|
-
size: "2xsmall",
|
|
2023
|
-
className: `uppercase ${getStatusBadgeClass$3(entry.status)}`,
|
|
2024
|
-
children: entry.status.replace(/_/g, " ")
|
|
2025
|
-
}
|
|
2026
|
-
) }),
|
|
2027
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
2028
|
-
new Date(entry.timestamp).toLocaleString(),
|
|
2029
|
-
entry.admin_id && ` by ${entry.admin_id}`,
|
|
2030
|
-
entry.reason && ` - ${entry.reason}`
|
|
2031
|
-
] })
|
|
2032
|
-
] })
|
|
2033
|
-
},
|
|
2034
|
-
index
|
|
2035
|
-
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2036
|
-
] })
|
|
2037
|
-
] }),
|
|
2038
|
-
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2039
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2040
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2041
1882
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2042
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-
|
|
2043
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "
|
|
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 })
|
|
2044
1885
|
] }),
|
|
2045
1886
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2046
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-
|
|
2047
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "
|
|
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 })
|
|
2048
1889
|
] }),
|
|
2049
1890
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2050
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-
|
|
2051
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
+
) })
|
|
2052
1900
|
] }),
|
|
2053
|
-
|
|
2054
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-
|
|
2055
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2066
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2067
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2083
|
-
] }) }),
|
|
2084
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2085
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2086
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2087
|
-
] }, item.variant_id || index)) })
|
|
2088
|
-
] }) })
|
|
2089
|
-
] })
|
|
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
|
|
2090
1930
|
] }) });
|
|
2091
1931
|
};
|
|
2092
1932
|
const config$3 = adminSdk.defineRouteConfig({
|
|
2093
|
-
label: "
|
|
2094
|
-
icon: icons.
|
|
1933
|
+
label: "Payment details",
|
|
1934
|
+
icon: icons.CreditCard
|
|
2095
1935
|
});
|
|
2096
1936
|
const getStatusBadgeClass$2 = (status) => {
|
|
2097
1937
|
const s2 = status.toLowerCase();
|
|
@@ -2457,36 +2297,304 @@ const ReturnDetailPage = () => {
|
|
|
2457
2297
|
},
|
|
2458
2298
|
children: "View order"
|
|
2459
2299
|
}
|
|
2460
|
-
) })
|
|
2300
|
+
) })
|
|
2301
|
+
] })
|
|
2302
|
+
] }),
|
|
2303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2305
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2306
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2307
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2308
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2309
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
|
|
2310
|
+
] }),
|
|
2311
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2312
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2313
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
|
|
2314
|
+
] }),
|
|
2315
|
+
returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2316
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2317
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
|
|
2318
|
+
] }),
|
|
2319
|
+
returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2320
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2321
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
|
|
2322
|
+
] }),
|
|
2323
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2324
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2325
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2326
|
+
] }),
|
|
2327
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2328
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2329
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2330
|
+
] })
|
|
2331
|
+
] })
|
|
2332
|
+
] }),
|
|
2333
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2334
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
2335
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2336
|
+
"div",
|
|
2337
|
+
{
|
|
2338
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
2339
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2340
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2341
|
+
ui.Badge,
|
|
2342
|
+
{
|
|
2343
|
+
size: "2xsmall",
|
|
2344
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
2345
|
+
children: entry.status.replace(/_/g, " ")
|
|
2346
|
+
}
|
|
2347
|
+
) }),
|
|
2348
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
2349
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
2350
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
2351
|
+
entry.reason && ` - ${entry.reason}`
|
|
2352
|
+
] })
|
|
2353
|
+
] })
|
|
2354
|
+
},
|
|
2355
|
+
index
|
|
2356
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2357
|
+
] })
|
|
2358
|
+
] }),
|
|
2359
|
+
returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2360
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2361
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2362
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2364
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2365
|
+
] }),
|
|
2366
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2368
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2369
|
+
] }),
|
|
2370
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2372
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2373
|
+
] }),
|
|
2374
|
+
returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2375
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2376
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
2377
|
+
returnOrder.order.currency_code || "$",
|
|
2378
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2379
|
+
] })
|
|
2380
|
+
] })
|
|
2381
|
+
] })
|
|
2382
|
+
] }),
|
|
2383
|
+
returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2385
|
+
/* @__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: [
|
|
2386
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2387
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2388
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2389
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2390
|
+
] }) }),
|
|
2391
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2392
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2393
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2394
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2395
|
+
] }, item.id || index)) })
|
|
2396
|
+
] }) })
|
|
2397
|
+
] }),
|
|
2398
|
+
updateError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: updateError }) }),
|
|
2399
|
+
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
|
+
] }) });
|
|
2401
|
+
};
|
|
2402
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
2403
|
+
label: "Return Order Details",
|
|
2404
|
+
icon: icons.CheckCircle
|
|
2405
|
+
});
|
|
2406
|
+
const getStatusBadgeClass = (status) => {
|
|
2407
|
+
const statusLower = status.toLowerCase();
|
|
2408
|
+
if (statusLower === "requested") {
|
|
2409
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2410
|
+
}
|
|
2411
|
+
if (statusLower === "approved") {
|
|
2412
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2413
|
+
}
|
|
2414
|
+
if (statusLower === "rejected") {
|
|
2415
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2416
|
+
}
|
|
2417
|
+
if (statusLower === "completed") {
|
|
2418
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2419
|
+
}
|
|
2420
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2421
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2422
|
+
}
|
|
2423
|
+
if (statusLower === "pending") {
|
|
2424
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2425
|
+
}
|
|
2426
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2427
|
+
};
|
|
2428
|
+
const SwapDetailPage = () => {
|
|
2429
|
+
var _a, _b, _c;
|
|
2430
|
+
const navigate = reactRouterDom.useNavigate();
|
|
2431
|
+
const { id } = reactRouterDom.useParams();
|
|
2432
|
+
const [swap, setSwap] = react.useState(null);
|
|
2433
|
+
const [order, setOrder] = react.useState(null);
|
|
2434
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
2435
|
+
react.useState(false);
|
|
2436
|
+
const [isCancelling, setIsCancelling] = react.useState(false);
|
|
2437
|
+
const [error, setError] = react.useState(null);
|
|
2438
|
+
const [updateError, setUpdateError] = react.useState(null);
|
|
2439
|
+
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
2440
|
+
react.useEffect(() => {
|
|
2441
|
+
if (!id) {
|
|
2442
|
+
navigate("/swaps");
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
const loadSwap = async () => {
|
|
2446
|
+
try {
|
|
2447
|
+
setIsLoading(true);
|
|
2448
|
+
setError(null);
|
|
2449
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2450
|
+
credentials: "include"
|
|
2451
|
+
});
|
|
2452
|
+
if (!response.ok) {
|
|
2453
|
+
const message = await response.text();
|
|
2454
|
+
throw new Error(message || "Unable to load swap");
|
|
2455
|
+
}
|
|
2456
|
+
const payload = await response.json();
|
|
2457
|
+
setSwap(payload.swap);
|
|
2458
|
+
setOrder(payload.order || null);
|
|
2459
|
+
} catch (loadError) {
|
|
2460
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2461
|
+
setError(message);
|
|
2462
|
+
} finally {
|
|
2463
|
+
setIsLoading(false);
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
void loadSwap();
|
|
2467
|
+
}, [id, navigate]);
|
|
2468
|
+
const handleCancelExchange = async () => {
|
|
2469
|
+
if (!id) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
try {
|
|
2473
|
+
setIsCancelling(true);
|
|
2474
|
+
setUpdateError(null);
|
|
2475
|
+
setUpdateSuccess(false);
|
|
2476
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2477
|
+
method: "POST",
|
|
2478
|
+
headers: {
|
|
2479
|
+
"Content-Type": "application/json"
|
|
2480
|
+
},
|
|
2481
|
+
credentials: "include"
|
|
2482
|
+
});
|
|
2483
|
+
if (!response.ok) {
|
|
2484
|
+
const message = await response.text();
|
|
2485
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2486
|
+
}
|
|
2487
|
+
const payload = await response.json();
|
|
2488
|
+
setSwap(payload.swap);
|
|
2489
|
+
setUpdateSuccess(true);
|
|
2490
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2491
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2492
|
+
credentials: "include"
|
|
2493
|
+
});
|
|
2494
|
+
if (detailResponse.ok) {
|
|
2495
|
+
const detailPayload = await detailResponse.json();
|
|
2496
|
+
setSwap(detailPayload.swap);
|
|
2497
|
+
setOrder(detailPayload.order || null);
|
|
2498
|
+
}
|
|
2499
|
+
} catch (cancelErr) {
|
|
2500
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2501
|
+
setUpdateError(message);
|
|
2502
|
+
} finally {
|
|
2503
|
+
setIsCancelling(false);
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2507
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2508
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2509
|
+
);
|
|
2510
|
+
if (isLoading) {
|
|
2511
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
|
|
2512
|
+
}
|
|
2513
|
+
if (error || !swap) {
|
|
2514
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2515
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2517
|
+
] }) }) });
|
|
2518
|
+
}
|
|
2519
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2520
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
2521
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2522
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2523
|
+
ui.Button,
|
|
2524
|
+
{
|
|
2525
|
+
variant: "transparent",
|
|
2526
|
+
size: "small",
|
|
2527
|
+
onClick: () => navigate("/swaps"),
|
|
2528
|
+
className: "w-fit",
|
|
2529
|
+
children: [
|
|
2530
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
2531
|
+
"Back to list"
|
|
2532
|
+
]
|
|
2533
|
+
}
|
|
2534
|
+
),
|
|
2535
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2536
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2537
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Exchange Details" }),
|
|
2538
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2539
|
+
] }),
|
|
2540
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2541
|
+
ui.Badge,
|
|
2542
|
+
{
|
|
2543
|
+
size: "small",
|
|
2544
|
+
className: `uppercase ${getStatusBadgeClass(swap.status)}`,
|
|
2545
|
+
children: swap.status.replace(/_/g, " ")
|
|
2546
|
+
}
|
|
2547
|
+
)
|
|
2461
2548
|
] })
|
|
2462
2549
|
] }),
|
|
2550
|
+
canCancelExchange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2551
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2552
|
+
ui.Button,
|
|
2553
|
+
{
|
|
2554
|
+
variant: "danger",
|
|
2555
|
+
onClick: handleCancelExchange,
|
|
2556
|
+
disabled: isCancelling,
|
|
2557
|
+
isLoading: isCancelling,
|
|
2558
|
+
children: "Cancel Exchange"
|
|
2559
|
+
}
|
|
2560
|
+
) }),
|
|
2561
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2562
|
+
] }),
|
|
2463
2563
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2464
2564
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2465
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
2565
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2466
2566
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2467
2567
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2468
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2469
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2568
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2569
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
2470
2570
|
] }),
|
|
2471
2571
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2472
2572
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2473
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2573
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
2474
2574
|
] }),
|
|
2475
|
-
|
|
2575
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2576
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2577
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2578
|
+
] }),
|
|
2579
|
+
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2476
2580
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2477
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2581
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
2478
2582
|
] }),
|
|
2479
|
-
|
|
2583
|
+
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2480
2584
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2481
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2585
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
2482
2586
|
] }),
|
|
2483
2587
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2484
2588
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2485
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(
|
|
2589
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2486
2590
|
] }),
|
|
2487
2591
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2488
2592
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2489
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(
|
|
2593
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2594
|
+
] }),
|
|
2595
|
+
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2596
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
2490
2598
|
] })
|
|
2491
2599
|
] })
|
|
2492
2600
|
] }),
|
|
@@ -2501,7 +2609,7 @@ const ReturnDetailPage = () => {
|
|
|
2501
2609
|
ui.Badge,
|
|
2502
2610
|
{
|
|
2503
2611
|
size: "2xsmall",
|
|
2504
|
-
className: `uppercase ${getStatusBadgeClass
|
|
2612
|
+
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
2505
2613
|
children: entry.status.replace(/_/g, " ")
|
|
2506
2614
|
}
|
|
2507
2615
|
) }),
|
|
@@ -2516,31 +2624,31 @@ const ReturnDetailPage = () => {
|
|
|
2516
2624
|
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2517
2625
|
] })
|
|
2518
2626
|
] }),
|
|
2519
|
-
|
|
2627
|
+
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2520
2628
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2521
2629
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2522
2630
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2523
2631
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2524
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2632
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
2525
2633
|
] }),
|
|
2526
2634
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2527
2635
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2528
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2636
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
2529
2637
|
] }),
|
|
2530
2638
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2531
2639
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2532
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((
|
|
2640
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2533
2641
|
] }),
|
|
2534
|
-
|
|
2642
|
+
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2535
2643
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2536
2644
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
2537
|
-
|
|
2538
|
-
(Number(
|
|
2645
|
+
order.currency_code || "$",
|
|
2646
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2539
2647
|
] })
|
|
2540
2648
|
] })
|
|
2541
2649
|
] })
|
|
2542
2650
|
] }),
|
|
2543
|
-
|
|
2651
|
+
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2544
2652
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2545
2653
|
/* @__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: [
|
|
2546
2654
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
@@ -2548,139 +2656,31 @@ const ReturnDetailPage = () => {
|
|
|
2548
2656
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2549
2657
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2550
2658
|
] }) }),
|
|
2551
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2659
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2552
2660
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2553
2661
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2554
2662
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2555
2663
|
] }, item.id || index)) })
|
|
2556
2664
|
] }) })
|
|
2557
2665
|
] }),
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
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
|
|
2666
|
+
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2668
|
+
/* @__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: [
|
|
2669
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2670
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2672
|
+
] }) }),
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2676
|
+
] }, item.variant_id || index)) })
|
|
2677
|
+
] }) })
|
|
2678
|
+
] })
|
|
2679
2679
|
] }) });
|
|
2680
2680
|
};
|
|
2681
2681
|
const config = adminSdk.defineRouteConfig({
|
|
2682
|
-
label: "
|
|
2683
|
-
icon: icons.
|
|
2682
|
+
label: "Swap Details",
|
|
2683
|
+
icon: icons.ArrowPath
|
|
2684
2684
|
});
|
|
2685
2685
|
const i18nTranslations0 = {};
|
|
2686
2686
|
const widgetModule = { widgets: [
|
|
@@ -2696,8 +2696,8 @@ const widgetModule = { widgets: [
|
|
|
2696
2696
|
const routeModule = {
|
|
2697
2697
|
routes: [
|
|
2698
2698
|
{
|
|
2699
|
-
Component:
|
|
2700
|
-
path: "/
|
|
2699
|
+
Component: PaymentsPage,
|
|
2700
|
+
path: "/payments"
|
|
2701
2701
|
},
|
|
2702
2702
|
{
|
|
2703
2703
|
Component: RefundsPage,
|
|
@@ -2708,12 +2708,12 @@ const routeModule = {
|
|
|
2708
2708
|
path: "/returns"
|
|
2709
2709
|
},
|
|
2710
2710
|
{
|
|
2711
|
-
Component:
|
|
2712
|
-
path: "/
|
|
2711
|
+
Component: SwapsPage,
|
|
2712
|
+
path: "/swaps"
|
|
2713
2713
|
},
|
|
2714
2714
|
{
|
|
2715
|
-
Component:
|
|
2716
|
-
path: "/
|
|
2715
|
+
Component: PaymentDetailPage,
|
|
2716
|
+
path: "/payments/:id"
|
|
2717
2717
|
},
|
|
2718
2718
|
{
|
|
2719
2719
|
Component: RefundDetailPage,
|
|
@@ -2724,17 +2724,17 @@ const routeModule = {
|
|
|
2724
2724
|
path: "/returns/:id"
|
|
2725
2725
|
},
|
|
2726
2726
|
{
|
|
2727
|
-
Component:
|
|
2728
|
-
path: "/
|
|
2727
|
+
Component: SwapDetailPage,
|
|
2728
|
+
path: "/swaps/:id"
|
|
2729
2729
|
}
|
|
2730
2730
|
]
|
|
2731
2731
|
};
|
|
2732
2732
|
const menuItemModule = {
|
|
2733
2733
|
menuItems: [
|
|
2734
2734
|
{
|
|
2735
|
-
label: config$
|
|
2736
|
-
icon: config$
|
|
2737
|
-
path: "/
|
|
2735
|
+
label: config$7.label,
|
|
2736
|
+
icon: config$7.icon,
|
|
2737
|
+
path: "/payments",
|
|
2738
2738
|
nested: void 0
|
|
2739
2739
|
},
|
|
2740
2740
|
{
|
|
@@ -2744,26 +2744,20 @@ const menuItemModule = {
|
|
|
2744
2744
|
nested: void 0
|
|
2745
2745
|
},
|
|
2746
2746
|
{
|
|
2747
|
-
label: config$
|
|
2748
|
-
icon: config$
|
|
2749
|
-
path: "/
|
|
2747
|
+
label: config$5.label,
|
|
2748
|
+
icon: config$5.icon,
|
|
2749
|
+
path: "/returns",
|
|
2750
2750
|
nested: void 0
|
|
2751
2751
|
},
|
|
2752
2752
|
{
|
|
2753
|
-
label: config$
|
|
2754
|
-
icon: config$
|
|
2753
|
+
label: config$4.label,
|
|
2754
|
+
icon: config$4.icon,
|
|
2755
2755
|
path: "/swaps",
|
|
2756
2756
|
nested: void 0
|
|
2757
2757
|
},
|
|
2758
2758
|
{
|
|
2759
|
-
label: config$
|
|
2760
|
-
icon: config$
|
|
2761
|
-
path: "/returns/:id",
|
|
2762
|
-
nested: void 0
|
|
2763
|
-
},
|
|
2764
|
-
{
|
|
2765
|
-
label: config.label,
|
|
2766
|
-
icon: config.icon,
|
|
2759
|
+
label: config$3.label,
|
|
2760
|
+
icon: config$3.icon,
|
|
2767
2761
|
path: "/payments/:id",
|
|
2768
2762
|
nested: void 0
|
|
2769
2763
|
},
|
|
@@ -2774,8 +2768,14 @@ const menuItemModule = {
|
|
|
2774
2768
|
nested: void 0
|
|
2775
2769
|
},
|
|
2776
2770
|
{
|
|
2777
|
-
label: config$
|
|
2778
|
-
icon: config$
|
|
2771
|
+
label: config$1.label,
|
|
2772
|
+
icon: config$1.icon,
|
|
2773
|
+
path: "/returns/:id",
|
|
2774
|
+
nested: void 0
|
|
2775
|
+
},
|
|
2776
|
+
{
|
|
2777
|
+
label: config.label,
|
|
2778
|
+
icon: config.icon,
|
|
2779
2779
|
path: "/swaps/:id",
|
|
2780
2780
|
nested: void 0
|
|
2781
2781
|
}
|