order-management 0.0.77 → 0.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -873,216 +873,16 @@ const getStatusBadgeClass$7 = (status) => {
|
|
|
873
873
|
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
874
874
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
875
875
|
};
|
|
876
|
-
const PaymentsPage = () => {
|
|
877
|
-
const navigate = reactRouterDom.useNavigate();
|
|
878
|
-
const [items, setItems] = react.useState([]);
|
|
879
|
-
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
880
|
-
const [orderIdSearch, setOrderIdSearch] = react.useState("");
|
|
881
|
-
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
882
|
-
const [isLoading, setIsLoading] = react.useState(true);
|
|
883
|
-
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
884
|
-
const [error, setError] = react.useState(null);
|
|
885
|
-
const [offset, setOffset] = react.useState(0);
|
|
886
|
-
const [count, setCount] = react.useState(0);
|
|
887
|
-
const limit = 50;
|
|
888
|
-
const loadTransactions = react.useCallback(
|
|
889
|
-
async (nextOffset, replace) => {
|
|
890
|
-
try {
|
|
891
|
-
if (replace) setIsLoading(true);
|
|
892
|
-
else setIsFetchingMore(true);
|
|
893
|
-
setError(null);
|
|
894
|
-
const params = new URLSearchParams();
|
|
895
|
-
params.set("limit", String(limit));
|
|
896
|
-
params.set("offset", String(nextOffset));
|
|
897
|
-
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
898
|
-
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
899
|
-
const response = await fetch(
|
|
900
|
-
`/admin/payment-transactions?${params.toString()}`,
|
|
901
|
-
{ credentials: "include" }
|
|
902
|
-
);
|
|
903
|
-
if (!response.ok) {
|
|
904
|
-
const text = await response.text();
|
|
905
|
-
throw new Error(text || "Failed to load payment transactions");
|
|
906
|
-
}
|
|
907
|
-
const payload = await response.json();
|
|
908
|
-
const list = payload.transactions ?? [];
|
|
909
|
-
setCount(payload.count ?? 0);
|
|
910
|
-
setOffset(nextOffset + list.length);
|
|
911
|
-
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
912
|
-
} catch (e) {
|
|
913
|
-
setError(e instanceof Error ? e.message : "Failed to load");
|
|
914
|
-
} finally {
|
|
915
|
-
setIsLoading(false);
|
|
916
|
-
setIsFetchingMore(false);
|
|
917
|
-
}
|
|
918
|
-
},
|
|
919
|
-
[statusFilter, debouncedOrderId]
|
|
920
|
-
);
|
|
921
|
-
react.useEffect(() => {
|
|
922
|
-
void loadTransactions(0, true);
|
|
923
|
-
}, [loadTransactions]);
|
|
924
|
-
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
925
|
-
const displayStatus = (t) => {
|
|
926
|
-
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
927
|
-
return s2 !== "" ? s2 : "—";
|
|
928
|
-
};
|
|
929
|
-
const displayAmount = (t) => {
|
|
930
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
931
|
-
return `${code} ${Number(t.amount)}`;
|
|
932
|
-
};
|
|
933
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
934
|
-
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
935
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
936
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
|
|
937
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
938
|
-
] }),
|
|
939
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
940
|
-
] }),
|
|
941
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
942
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
943
|
-
ui.Input,
|
|
944
|
-
{
|
|
945
|
-
placeholder: "Search by Order ID",
|
|
946
|
-
value: orderIdSearch,
|
|
947
|
-
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
948
|
-
className: "md:max-w-sm",
|
|
949
|
-
"aria-label": "Search by order ID"
|
|
950
|
-
}
|
|
951
|
-
),
|
|
952
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
953
|
-
"select",
|
|
954
|
-
{
|
|
955
|
-
value: statusFilter,
|
|
956
|
-
onChange: (e) => setStatusFilter(e.target.value),
|
|
957
|
-
className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
|
|
958
|
-
"aria-label": "Filter by status",
|
|
959
|
-
children: [
|
|
960
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
|
|
961
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
|
|
962
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
963
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
|
|
964
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
|
|
965
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
|
|
966
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
|
|
967
|
-
]
|
|
968
|
-
}
|
|
969
|
-
) })
|
|
970
|
-
] }),
|
|
971
|
-
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
972
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
973
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
974
|
-
] }) : null,
|
|
975
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
976
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
977
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
978
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
979
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
980
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
981
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
982
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
983
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
984
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
985
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
986
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
987
|
-
] }) }),
|
|
988
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
989
|
-
"tr",
|
|
990
|
-
{
|
|
991
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
992
|
-
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
993
|
-
children: [
|
|
994
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
995
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
996
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
997
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
998
|
-
ui.Badge,
|
|
999
|
-
{
|
|
1000
|
-
size: "2xsmall",
|
|
1001
|
-
className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
|
|
1002
|
-
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1003
|
-
}
|
|
1004
|
-
) }),
|
|
1005
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1006
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1007
|
-
year: "numeric",
|
|
1008
|
-
month: "short",
|
|
1009
|
-
day: "numeric",
|
|
1010
|
-
hour: "numeric",
|
|
1011
|
-
minute: "2-digit",
|
|
1012
|
-
hour12: true
|
|
1013
|
-
}) }),
|
|
1014
|
-
/* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
|
|
1015
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1016
|
-
ui.Button,
|
|
1017
|
-
{
|
|
1018
|
-
variant: "transparent",
|
|
1019
|
-
size: "small",
|
|
1020
|
-
onClick: (e) => {
|
|
1021
|
-
e.stopPropagation();
|
|
1022
|
-
navigate(`/payments/${t.payment_session_id}`);
|
|
1023
|
-
},
|
|
1024
|
-
children: "View details"
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1028
|
-
ui.Button,
|
|
1029
|
-
{
|
|
1030
|
-
variant: "transparent",
|
|
1031
|
-
size: "small",
|
|
1032
|
-
onClick: (e) => {
|
|
1033
|
-
e.stopPropagation();
|
|
1034
|
-
navigate(`/orders/${t.order_id}`);
|
|
1035
|
-
},
|
|
1036
|
-
children: "Order"
|
|
1037
|
-
}
|
|
1038
|
-
) : null
|
|
1039
|
-
] })
|
|
1040
|
-
]
|
|
1041
|
-
},
|
|
1042
|
-
t.payment_session_id
|
|
1043
|
-
)) })
|
|
1044
|
-
] }) }),
|
|
1045
|
-
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1046
|
-
ui.Button,
|
|
1047
|
-
{
|
|
1048
|
-
variant: "secondary",
|
|
1049
|
-
isLoading: isFetchingMore,
|
|
1050
|
-
onClick: () => loadTransactions(offset, false),
|
|
1051
|
-
children: "Load more"
|
|
1052
|
-
}
|
|
1053
|
-
) }) : null
|
|
1054
|
-
] }) });
|
|
1055
|
-
};
|
|
1056
|
-
const config$7 = adminSdk.defineRouteConfig({
|
|
1057
|
-
label: "Payments",
|
|
1058
|
-
icon: icons.CreditCard
|
|
1059
|
-
});
|
|
1060
|
-
const useDebounce$2 = (value, delay) => {
|
|
1061
|
-
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
1062
|
-
react.useEffect(() => {
|
|
1063
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1064
|
-
return () => clearTimeout(handler);
|
|
1065
|
-
}, [value, delay]);
|
|
1066
|
-
return debouncedValue;
|
|
1067
|
-
};
|
|
1068
|
-
const getStatusBadgeClass$6 = (status) => {
|
|
1069
|
-
const s2 = status.toLowerCase();
|
|
1070
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1071
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1072
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1073
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1074
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1075
|
-
};
|
|
1076
876
|
const RefundsPage = () => {
|
|
1077
877
|
const navigate = reactRouterDom.useNavigate();
|
|
1078
878
|
const [items, setItems] = react.useState([]);
|
|
1079
879
|
const [orderIdSearch, setOrderIdSearch] = react.useState("");
|
|
1080
|
-
const debouncedOrderId = useDebounce$
|
|
880
|
+
const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
|
|
1081
881
|
const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
|
|
1082
882
|
const [providerSearch, setProviderSearch] = react.useState("");
|
|
1083
|
-
const debouncedProvider = useDebounce$
|
|
883
|
+
const debouncedProvider = useDebounce$3(providerSearch, 300);
|
|
1084
884
|
const [currencySearch, setCurrencySearch] = react.useState("");
|
|
1085
|
-
const debouncedCurrency = useDebounce$
|
|
885
|
+
const debouncedCurrency = useDebounce$3(currencySearch, 300);
|
|
1086
886
|
const [dateFrom, setDateFrom] = react.useState("");
|
|
1087
887
|
const [dateTo, setDateTo] = react.useState("");
|
|
1088
888
|
const [amountMin, setAmountMin] = react.useState("");
|
|
@@ -1294,7 +1094,7 @@ const RefundsPage = () => {
|
|
|
1294
1094
|
ui.Badge,
|
|
1295
1095
|
{
|
|
1296
1096
|
size: "2xsmall",
|
|
1297
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1097
|
+
className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
|
|
1298
1098
|
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
1299
1099
|
}
|
|
1300
1100
|
) }),
|
|
@@ -1348,11 +1148,11 @@ const RefundsPage = () => {
|
|
|
1348
1148
|
) }) : null
|
|
1349
1149
|
] }) });
|
|
1350
1150
|
};
|
|
1351
|
-
const config$
|
|
1151
|
+
const config$7 = adminSdk.defineRouteConfig({
|
|
1352
1152
|
label: "Refunds",
|
|
1353
1153
|
icon: icons.Receipt
|
|
1354
1154
|
});
|
|
1355
|
-
const useDebounce$
|
|
1155
|
+
const useDebounce$2 = (value, delay) => {
|
|
1356
1156
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
1357
1157
|
react.useEffect(() => {
|
|
1358
1158
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1360,39 +1160,39 @@ const useDebounce$1 = (value, delay) => {
|
|
|
1360
1160
|
}, [value, delay]);
|
|
1361
1161
|
return debouncedValue;
|
|
1362
1162
|
};
|
|
1363
|
-
const getStatusBadgeClass$
|
|
1163
|
+
const getStatusBadgeClass$6 = (status) => {
|
|
1364
1164
|
const statusLower = status.toLowerCase();
|
|
1365
1165
|
if (statusLower === "requested") {
|
|
1366
1166
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1367
1167
|
}
|
|
1368
|
-
if (statusLower === "
|
|
1168
|
+
if (statusLower === "approved") {
|
|
1369
1169
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1370
1170
|
}
|
|
1371
|
-
if (statusLower === "
|
|
1171
|
+
if (statusLower === "rejected") {
|
|
1372
1172
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1373
1173
|
}
|
|
1374
1174
|
if (statusLower === "completed") {
|
|
1375
1175
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1376
1176
|
}
|
|
1377
|
-
if (statusLower === "
|
|
1177
|
+
if (statusLower === "cancelled") {
|
|
1378
1178
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1379
1179
|
}
|
|
1380
1180
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1381
1181
|
};
|
|
1382
|
-
const
|
|
1182
|
+
const SwapsPage = () => {
|
|
1383
1183
|
const navigate = reactRouterDom.useNavigate();
|
|
1384
1184
|
const [items, setItems] = react.useState([]);
|
|
1385
1185
|
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
1386
1186
|
const [createdByFilter, setCreatedByFilter] = react.useState("all");
|
|
1387
1187
|
const [searchQuery, setSearchQuery] = react.useState("");
|
|
1388
|
-
const debouncedSearchQuery = useDebounce$
|
|
1188
|
+
const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
|
|
1389
1189
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
1390
1190
|
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
1391
1191
|
const [error, setError] = react.useState(null);
|
|
1392
1192
|
const [offset, setOffset] = react.useState(0);
|
|
1393
1193
|
const [count, setCount] = react.useState(0);
|
|
1394
1194
|
const limit = 50;
|
|
1395
|
-
const
|
|
1195
|
+
const loadSwaps = react.useCallback(
|
|
1396
1196
|
async (nextOffset, replace = false) => {
|
|
1397
1197
|
var _a;
|
|
1398
1198
|
try {
|
|
@@ -1409,28 +1209,27 @@ const ReturnsPage = () => {
|
|
|
1409
1209
|
params.set("status", statusFilter);
|
|
1410
1210
|
}
|
|
1411
1211
|
if (debouncedSearchQuery.trim()) {
|
|
1412
|
-
params.set("
|
|
1212
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
1413
1213
|
}
|
|
1414
1214
|
if (createdByFilter !== "all") {
|
|
1415
1215
|
params.set("created_by", createdByFilter);
|
|
1416
1216
|
}
|
|
1417
|
-
params.set("order", "created_at");
|
|
1418
1217
|
const response = await fetch(
|
|
1419
|
-
`/admin/
|
|
1218
|
+
`/admin/swaps?${params.toString()}`,
|
|
1420
1219
|
{ credentials: "include" }
|
|
1421
1220
|
);
|
|
1422
1221
|
if (!response.ok) {
|
|
1423
1222
|
const message = await response.text();
|
|
1424
|
-
throw new Error(message || "Unable to load
|
|
1223
|
+
throw new Error(message || "Unable to load swaps");
|
|
1425
1224
|
}
|
|
1426
1225
|
const payload = await response.json();
|
|
1427
1226
|
setCount(payload.count ?? 0);
|
|
1428
|
-
setOffset(nextOffset + (((_a = payload.
|
|
1227
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1429
1228
|
setItems(
|
|
1430
|
-
(prev) => replace ? payload.
|
|
1229
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1431
1230
|
);
|
|
1432
1231
|
} catch (loadError) {
|
|
1433
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
1232
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1434
1233
|
setError(message);
|
|
1435
1234
|
} finally {
|
|
1436
1235
|
setIsLoading(false);
|
|
@@ -1440,8 +1239,8 @@ const ReturnsPage = () => {
|
|
|
1440
1239
|
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1441
1240
|
);
|
|
1442
1241
|
react.useEffect(() => {
|
|
1443
|
-
void
|
|
1444
|
-
}, [statusFilter, createdByFilter, debouncedSearchQuery,
|
|
1242
|
+
void loadSwaps(0, true);
|
|
1243
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1445
1244
|
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
1446
1245
|
const availableStatuses = react.useMemo(() => {
|
|
1447
1246
|
const statuses = /* @__PURE__ */ new Set();
|
|
@@ -1451,16 +1250,16 @@ const ReturnsPage = () => {
|
|
|
1451
1250
|
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: [
|
|
1452
1251
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1453
1252
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1454
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
1455
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer
|
|
1253
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Exchanges" }),
|
|
1254
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1456
1255
|
] }),
|
|
1457
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () =>
|
|
1256
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1458
1257
|
] }),
|
|
1459
1258
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1460
1259
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1461
1260
|
ui.Input,
|
|
1462
1261
|
{
|
|
1463
|
-
placeholder: "Search by
|
|
1262
|
+
placeholder: "Search by swap ID or order ID",
|
|
1464
1263
|
value: searchQuery,
|
|
1465
1264
|
onChange: (event) => setSearchQuery(event.target.value),
|
|
1466
1265
|
className: "md:max-w-sm"
|
|
@@ -1500,51 +1299,50 @@ const ReturnsPage = () => {
|
|
|
1500
1299
|
ui.Button,
|
|
1501
1300
|
{
|
|
1502
1301
|
variant: "secondary",
|
|
1503
|
-
onClick: () =>
|
|
1302
|
+
onClick: () => loadSwaps(0, true),
|
|
1504
1303
|
children: "Try again"
|
|
1505
1304
|
}
|
|
1506
1305
|
) })
|
|
1507
1306
|
] }) : null,
|
|
1508
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading
|
|
1509
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No
|
|
1510
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
1307
|
+
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: [
|
|
1308
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1309
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1511
1310
|
] }) : /* @__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: [
|
|
1512
1311
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1513
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
1312
|
+
/* @__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" }),
|
|
1514
1313
|
/* @__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" }),
|
|
1515
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
|
|
1516
1314
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1517
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
1315
|
+
/* @__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" }),
|
|
1518
1316
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1519
1317
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1520
1318
|
] }) }),
|
|
1521
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1319
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1522
1320
|
"tr",
|
|
1523
1321
|
{
|
|
1524
1322
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1525
|
-
onClick: () => navigate(`/
|
|
1323
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1526
1324
|
children: [
|
|
1527
|
-
/* @__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:
|
|
1528
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1529
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
|
|
1325
|
+
/* @__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 }) }) }),
|
|
1326
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
1530
1327
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1531
1328
|
ui.Badge,
|
|
1532
1329
|
{
|
|
1533
1330
|
size: "2xsmall",
|
|
1534
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1535
|
-
children:
|
|
1331
|
+
className: `uppercase ${getStatusBadgeClass$6(swap.status)}`,
|
|
1332
|
+
children: swap.status.replace(/_/g, " ")
|
|
1536
1333
|
}
|
|
1537
1334
|
) }),
|
|
1538
1335
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1539
|
-
const amount =
|
|
1336
|
+
const amount = swap.difference_due;
|
|
1540
1337
|
if (amount == null || amount === void 0) {
|
|
1541
1338
|
return "—";
|
|
1542
1339
|
}
|
|
1543
1340
|
const displayAmount = Number(amount) / 100;
|
|
1544
|
-
const currency =
|
|
1545
|
-
|
|
1341
|
+
const currency = swap.currency_code || "$";
|
|
1342
|
+
const sign = displayAmount >= 0 ? "+" : "";
|
|
1343
|
+
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1546
1344
|
})() }),
|
|
1547
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(
|
|
1345
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
1548
1346
|
year: "numeric",
|
|
1549
1347
|
month: "short",
|
|
1550
1348
|
day: "numeric",
|
|
@@ -1559,14 +1357,14 @@ const ReturnsPage = () => {
|
|
|
1559
1357
|
size: "small",
|
|
1560
1358
|
onClick: (e) => {
|
|
1561
1359
|
e.stopPropagation();
|
|
1562
|
-
navigate(`/app/orders/${
|
|
1360
|
+
navigate(`/app/orders/${swap.order_id}`);
|
|
1563
1361
|
},
|
|
1564
1362
|
children: "Go to order"
|
|
1565
1363
|
}
|
|
1566
1364
|
) })
|
|
1567
1365
|
]
|
|
1568
1366
|
},
|
|
1569
|
-
|
|
1367
|
+
swap.id
|
|
1570
1368
|
)) })
|
|
1571
1369
|
] }) }),
|
|
1572
1370
|
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1574,17 +1372,17 @@ const ReturnsPage = () => {
|
|
|
1574
1372
|
{
|
|
1575
1373
|
variant: "secondary",
|
|
1576
1374
|
isLoading: isFetchingMore,
|
|
1577
|
-
onClick: () =>
|
|
1375
|
+
onClick: () => loadSwaps(offset, false),
|
|
1578
1376
|
children: "Load more"
|
|
1579
1377
|
}
|
|
1580
1378
|
) }) : null
|
|
1581
1379
|
] }) });
|
|
1582
1380
|
};
|
|
1583
|
-
const config$
|
|
1584
|
-
label: "
|
|
1381
|
+
const config$6 = adminSdk.defineRouteConfig({
|
|
1382
|
+
label: "Exchanges",
|
|
1585
1383
|
icon: icons.ArrowPath
|
|
1586
1384
|
});
|
|
1587
|
-
const useDebounce = (value, delay) => {
|
|
1385
|
+
const useDebounce$1 = (value, delay) => {
|
|
1588
1386
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
1589
1387
|
react.useEffect(() => {
|
|
1590
1388
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1592,39 +1390,39 @@ const useDebounce = (value, delay) => {
|
|
|
1592
1390
|
}, [value, delay]);
|
|
1593
1391
|
return debouncedValue;
|
|
1594
1392
|
};
|
|
1595
|
-
const getStatusBadgeClass$
|
|
1393
|
+
const getStatusBadgeClass$5 = (status) => {
|
|
1596
1394
|
const statusLower = status.toLowerCase();
|
|
1597
1395
|
if (statusLower === "requested") {
|
|
1598
1396
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1599
1397
|
}
|
|
1600
|
-
if (statusLower === "
|
|
1398
|
+
if (statusLower === "received") {
|
|
1601
1399
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1602
1400
|
}
|
|
1603
|
-
if (statusLower === "
|
|
1401
|
+
if (statusLower === "requires_action") {
|
|
1604
1402
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1605
1403
|
}
|
|
1606
1404
|
if (statusLower === "completed") {
|
|
1607
1405
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1608
1406
|
}
|
|
1609
|
-
if (statusLower === "
|
|
1407
|
+
if (statusLower === "canceled") {
|
|
1610
1408
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1611
1409
|
}
|
|
1612
1410
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1613
1411
|
};
|
|
1614
|
-
const
|
|
1412
|
+
const ReturnsPage = () => {
|
|
1615
1413
|
const navigate = reactRouterDom.useNavigate();
|
|
1616
1414
|
const [items, setItems] = react.useState([]);
|
|
1617
1415
|
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
1618
1416
|
const [createdByFilter, setCreatedByFilter] = react.useState("all");
|
|
1619
1417
|
const [searchQuery, setSearchQuery] = react.useState("");
|
|
1620
|
-
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1418
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
1621
1419
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
1622
1420
|
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
1623
1421
|
const [error, setError] = react.useState(null);
|
|
1624
1422
|
const [offset, setOffset] = react.useState(0);
|
|
1625
1423
|
const [count, setCount] = react.useState(0);
|
|
1626
1424
|
const limit = 50;
|
|
1627
|
-
const
|
|
1425
|
+
const loadReturns = react.useCallback(
|
|
1628
1426
|
async (nextOffset, replace = false) => {
|
|
1629
1427
|
var _a;
|
|
1630
1428
|
try {
|
|
@@ -1641,27 +1439,28 @@ const SwapsPage = () => {
|
|
|
1641
1439
|
params.set("status", statusFilter);
|
|
1642
1440
|
}
|
|
1643
1441
|
if (debouncedSearchQuery.trim()) {
|
|
1644
|
-
params.set("
|
|
1442
|
+
params.set("q", debouncedSearchQuery.trim());
|
|
1645
1443
|
}
|
|
1646
1444
|
if (createdByFilter !== "all") {
|
|
1647
1445
|
params.set("created_by", createdByFilter);
|
|
1648
1446
|
}
|
|
1447
|
+
params.set("order", "created_at");
|
|
1649
1448
|
const response = await fetch(
|
|
1650
|
-
`/admin/
|
|
1449
|
+
`/admin/return?${params.toString()}`,
|
|
1651
1450
|
{ credentials: "include" }
|
|
1652
1451
|
);
|
|
1653
1452
|
if (!response.ok) {
|
|
1654
1453
|
const message = await response.text();
|
|
1655
|
-
throw new Error(message || "Unable to load
|
|
1454
|
+
throw new Error(message || "Unable to load return orders");
|
|
1656
1455
|
}
|
|
1657
1456
|
const payload = await response.json();
|
|
1658
1457
|
setCount(payload.count ?? 0);
|
|
1659
|
-
setOffset(nextOffset + (((_a = payload.
|
|
1458
|
+
setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
|
|
1660
1459
|
setItems(
|
|
1661
|
-
(prev) => replace ? payload.
|
|
1460
|
+
(prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
|
|
1662
1461
|
);
|
|
1663
1462
|
} catch (loadError) {
|
|
1664
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
1463
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
|
|
1665
1464
|
setError(message);
|
|
1666
1465
|
} finally {
|
|
1667
1466
|
setIsLoading(false);
|
|
@@ -1671,8 +1470,8 @@ const SwapsPage = () => {
|
|
|
1671
1470
|
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1672
1471
|
);
|
|
1673
1472
|
react.useEffect(() => {
|
|
1674
|
-
void
|
|
1675
|
-
}, [statusFilter, createdByFilter, debouncedSearchQuery,
|
|
1473
|
+
void loadReturns(0, true);
|
|
1474
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadReturns]);
|
|
1676
1475
|
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
1677
1476
|
const availableStatuses = react.useMemo(() => {
|
|
1678
1477
|
const statuses = /* @__PURE__ */ new Set();
|
|
@@ -1682,16 +1481,16 @@ const SwapsPage = () => {
|
|
|
1682
1481
|
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: [
|
|
1683
1482
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1684
1483
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1685
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
1686
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer
|
|
1484
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
|
|
1485
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
|
|
1687
1486
|
] }),
|
|
1688
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () =>
|
|
1487
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
|
|
1689
1488
|
] }),
|
|
1690
1489
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1691
1490
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1692
1491
|
ui.Input,
|
|
1693
1492
|
{
|
|
1694
|
-
placeholder: "Search by
|
|
1493
|
+
placeholder: "Search by return ID, order ID, or customer email",
|
|
1695
1494
|
value: searchQuery,
|
|
1696
1495
|
onChange: (event) => setSearchQuery(event.target.value),
|
|
1697
1496
|
className: "md:max-w-sm"
|
|
@@ -1731,50 +1530,51 @@ const SwapsPage = () => {
|
|
|
1731
1530
|
ui.Button,
|
|
1732
1531
|
{
|
|
1733
1532
|
variant: "secondary",
|
|
1734
|
-
onClick: () =>
|
|
1533
|
+
onClick: () => loadReturns(0, true),
|
|
1735
1534
|
children: "Try again"
|
|
1736
1535
|
}
|
|
1737
1536
|
) })
|
|
1738
1537
|
] }) : null,
|
|
1739
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading
|
|
1740
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No
|
|
1741
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
1538
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1539
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
|
|
1540
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
|
|
1742
1541
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1743
1542
|
/* @__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: "
|
|
1543
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
|
|
1745
1544
|
/* @__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" }),
|
|
1545
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
|
|
1746
1546
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1747
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
1547
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
|
|
1748
1548
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1749
1549
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1750
1550
|
] }) }),
|
|
1751
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1551
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1752
1552
|
"tr",
|
|
1753
1553
|
{
|
|
1754
1554
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1755
|
-
onClick: () => navigate(`/
|
|
1555
|
+
onClick: () => navigate(`/returns/${returnOrder.id}`),
|
|
1756
1556
|
children: [
|
|
1757
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children:
|
|
1758
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1557
|
+
/* @__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: returnOrder.id }) }) }),
|
|
1558
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
|
|
1559
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
|
|
1759
1560
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1760
1561
|
ui.Badge,
|
|
1761
1562
|
{
|
|
1762
1563
|
size: "2xsmall",
|
|
1763
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1764
|
-
children:
|
|
1564
|
+
className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
|
|
1565
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
1765
1566
|
}
|
|
1766
1567
|
) }),
|
|
1767
1568
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1768
|
-
const amount =
|
|
1569
|
+
const amount = returnOrder.refund_amount;
|
|
1769
1570
|
if (amount == null || amount === void 0) {
|
|
1770
1571
|
return "—";
|
|
1771
1572
|
}
|
|
1772
1573
|
const displayAmount = Number(amount) / 100;
|
|
1773
|
-
const currency =
|
|
1774
|
-
|
|
1775
|
-
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1574
|
+
const currency = returnOrder.currency_code || "$";
|
|
1575
|
+
return `${currency}${displayAmount.toFixed(2)}`;
|
|
1776
1576
|
})() }),
|
|
1777
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(
|
|
1577
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
|
|
1778
1578
|
year: "numeric",
|
|
1779
1579
|
month: "short",
|
|
1780
1580
|
day: "numeric",
|
|
@@ -1789,14 +1589,14 @@ const SwapsPage = () => {
|
|
|
1789
1589
|
size: "small",
|
|
1790
1590
|
onClick: (e) => {
|
|
1791
1591
|
e.stopPropagation();
|
|
1792
|
-
navigate(`/app/orders/${
|
|
1592
|
+
navigate(`/app/orders/${returnOrder.order_id}`);
|
|
1793
1593
|
},
|
|
1794
1594
|
children: "Go to order"
|
|
1795
1595
|
}
|
|
1796
1596
|
) })
|
|
1797
1597
|
]
|
|
1798
1598
|
},
|
|
1799
|
-
|
|
1599
|
+
returnOrder.id
|
|
1800
1600
|
)) })
|
|
1801
1601
|
] }) }),
|
|
1802
1602
|
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1804,17 +1604,25 @@ const SwapsPage = () => {
|
|
|
1804
1604
|
{
|
|
1805
1605
|
variant: "secondary",
|
|
1806
1606
|
isLoading: isFetchingMore,
|
|
1807
|
-
onClick: () =>
|
|
1607
|
+
onClick: () => loadReturns(offset, false),
|
|
1808
1608
|
children: "Load more"
|
|
1809
1609
|
}
|
|
1810
1610
|
) }) : null
|
|
1811
1611
|
] }) });
|
|
1812
1612
|
};
|
|
1813
|
-
const config$
|
|
1814
|
-
label: "
|
|
1613
|
+
const config$5 = adminSdk.defineRouteConfig({
|
|
1614
|
+
label: "Return Orders",
|
|
1815
1615
|
icon: icons.ArrowPath
|
|
1816
1616
|
});
|
|
1817
|
-
const
|
|
1617
|
+
const useDebounce = (value, delay) => {
|
|
1618
|
+
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
1619
|
+
react.useEffect(() => {
|
|
1620
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1621
|
+
return () => clearTimeout(handler);
|
|
1622
|
+
}, [value, delay]);
|
|
1623
|
+
return debouncedValue;
|
|
1624
|
+
};
|
|
1625
|
+
const getStatusBadgeClass$4 = (status) => {
|
|
1818
1626
|
const s2 = status.toLowerCase();
|
|
1819
1627
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1820
1628
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -1822,118 +1630,191 @@ const getStatusBadgeClass$3 = (status) => {
|
|
|
1822
1630
|
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1823
1631
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1824
1632
|
};
|
|
1825
|
-
const
|
|
1826
|
-
var _a;
|
|
1633
|
+
const PaymentsPage = () => {
|
|
1827
1634
|
const navigate = reactRouterDom.useNavigate();
|
|
1828
|
-
const
|
|
1829
|
-
const
|
|
1830
|
-
const [
|
|
1831
|
-
const
|
|
1635
|
+
const [items, setItems] = react.useState([]);
|
|
1636
|
+
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
1637
|
+
const [orderIdSearch, setOrderIdSearch] = react.useState("");
|
|
1638
|
+
const debouncedOrderId = useDebounce(orderIdSearch, 300);
|
|
1639
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
1640
|
+
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
1832
1641
|
const [error, setError] = react.useState(null);
|
|
1642
|
+
const [offset, setOffset] = react.useState(0);
|
|
1643
|
+
const [count, setCount] = react.useState(0);
|
|
1644
|
+
const limit = 50;
|
|
1645
|
+
const loadTransactions = react.useCallback(
|
|
1646
|
+
async (nextOffset, replace) => {
|
|
1647
|
+
try {
|
|
1648
|
+
if (replace) setIsLoading(true);
|
|
1649
|
+
else setIsFetchingMore(true);
|
|
1650
|
+
setError(null);
|
|
1651
|
+
const params = new URLSearchParams();
|
|
1652
|
+
params.set("limit", String(limit));
|
|
1653
|
+
params.set("offset", String(nextOffset));
|
|
1654
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
1655
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
1656
|
+
const response = await fetch(
|
|
1657
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
1658
|
+
{ credentials: "include" }
|
|
1659
|
+
);
|
|
1660
|
+
if (!response.ok) {
|
|
1661
|
+
const text = await response.text();
|
|
1662
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
1663
|
+
}
|
|
1664
|
+
const payload = await response.json();
|
|
1665
|
+
const list = payload.transactions ?? [];
|
|
1666
|
+
setCount(payload.count ?? 0);
|
|
1667
|
+
setOffset(nextOffset + list.length);
|
|
1668
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
1669
|
+
} catch (e) {
|
|
1670
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
1671
|
+
} finally {
|
|
1672
|
+
setIsLoading(false);
|
|
1673
|
+
setIsFetchingMore(false);
|
|
1674
|
+
}
|
|
1675
|
+
},
|
|
1676
|
+
[statusFilter, debouncedOrderId]
|
|
1677
|
+
);
|
|
1833
1678
|
react.useEffect(() => {
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1679
|
+
void loadTransactions(0, true);
|
|
1680
|
+
}, [loadTransactions]);
|
|
1681
|
+
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
1682
|
+
const displayStatus = (t) => {
|
|
1683
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
1684
|
+
return s2 !== "" ? s2 : "—";
|
|
1685
|
+
};
|
|
1686
|
+
const displayAmount = (t) => {
|
|
1687
|
+
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1688
|
+
return `${code} ${Number(t.amount)}`;
|
|
1689
|
+
};
|
|
1690
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1691
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1692
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1693
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
1695
|
+
] }),
|
|
1696
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
1697
|
+
] }),
|
|
1698
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1699
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1700
|
+
ui.Input,
|
|
1701
|
+
{
|
|
1702
|
+
placeholder: "Search by Order ID",
|
|
1703
|
+
value: orderIdSearch,
|
|
1704
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
1705
|
+
className: "md:max-w-sm",
|
|
1706
|
+
"aria-label": "Search by order ID"
|
|
1707
|
+
}
|
|
1708
|
+
),
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1710
|
+
"select",
|
|
1711
|
+
{
|
|
1712
|
+
value: statusFilter,
|
|
1713
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
1714
|
+
className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
|
|
1715
|
+
"aria-label": "Filter by status",
|
|
1716
|
+
children: [
|
|
1717
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
|
|
1718
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
|
|
1719
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1720
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
|
|
1721
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1722
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1723
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
) })
|
|
1727
|
+
] }),
|
|
1865
1728
|
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1866
1729
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1867
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1868
|
-
] }) :
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
] }),
|
|
1882
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1883
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
1884
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
|
|
1885
|
-
] }),
|
|
1886
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1887
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
1888
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
|
|
1889
|
-
] }),
|
|
1890
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1891
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
1892
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1893
|
-
ui.Badge,
|
|
1894
|
-
{
|
|
1895
|
-
size: "2xsmall",
|
|
1896
|
-
className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
|
|
1897
|
-
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
1898
|
-
}
|
|
1899
|
-
) })
|
|
1900
|
-
] }),
|
|
1901
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1902
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
1903
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
1904
|
-
] }),
|
|
1905
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1906
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
1907
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
1908
|
-
] }),
|
|
1909
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1910
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
1911
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
1912
|
-
] }),
|
|
1913
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1914
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
1915
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
1916
|
-
year: "numeric",
|
|
1917
|
-
month: "short",
|
|
1918
|
-
day: "numeric",
|
|
1919
|
-
hour: "numeric",
|
|
1920
|
-
minute: "2-digit",
|
|
1921
|
-
hour12: true
|
|
1922
|
-
}) })
|
|
1923
|
-
] })
|
|
1730
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
1731
|
+
] }) : null,
|
|
1732
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1733
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
1734
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
1735
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1736
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1737
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1738
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1739
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1740
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1741
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
1742
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1743
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1924
1744
|
] }) }),
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1745
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1746
|
+
"tr",
|
|
1747
|
+
{
|
|
1748
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1749
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1750
|
+
children: [
|
|
1751
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
1752
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
1753
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1754
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1755
|
+
ui.Badge,
|
|
1756
|
+
{
|
|
1757
|
+
size: "2xsmall",
|
|
1758
|
+
className: `uppercase ${getStatusBadgeClass$4(displayStatus(t))}`,
|
|
1759
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1760
|
+
}
|
|
1761
|
+
) }),
|
|
1762
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1763
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1764
|
+
year: "numeric",
|
|
1765
|
+
month: "short",
|
|
1766
|
+
day: "numeric",
|
|
1767
|
+
hour: "numeric",
|
|
1768
|
+
minute: "2-digit",
|
|
1769
|
+
hour12: true
|
|
1770
|
+
}) }),
|
|
1771
|
+
/* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
|
|
1772
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1773
|
+
ui.Button,
|
|
1774
|
+
{
|
|
1775
|
+
variant: "transparent",
|
|
1776
|
+
size: "small",
|
|
1777
|
+
onClick: (e) => {
|
|
1778
|
+
e.stopPropagation();
|
|
1779
|
+
navigate(`/payments/${t.payment_session_id}`);
|
|
1780
|
+
},
|
|
1781
|
+
children: "View details"
|
|
1782
|
+
}
|
|
1783
|
+
),
|
|
1784
|
+
t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1785
|
+
ui.Button,
|
|
1786
|
+
{
|
|
1787
|
+
variant: "transparent",
|
|
1788
|
+
size: "small",
|
|
1789
|
+
onClick: (e) => {
|
|
1790
|
+
e.stopPropagation();
|
|
1791
|
+
navigate(`/orders/${t.order_id}`);
|
|
1792
|
+
},
|
|
1793
|
+
children: "Order"
|
|
1794
|
+
}
|
|
1795
|
+
) : null
|
|
1796
|
+
] })
|
|
1797
|
+
]
|
|
1798
|
+
},
|
|
1799
|
+
t.payment_session_id
|
|
1800
|
+
)) })
|
|
1801
|
+
] }) }),
|
|
1802
|
+
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1803
|
+
ui.Button,
|
|
1804
|
+
{
|
|
1805
|
+
variant: "secondary",
|
|
1806
|
+
isLoading: isFetchingMore,
|
|
1807
|
+
onClick: () => loadTransactions(offset, false),
|
|
1808
|
+
children: "Load more"
|
|
1809
|
+
}
|
|
1810
|
+
) }) : null
|
|
1930
1811
|
] }) });
|
|
1931
1812
|
};
|
|
1932
|
-
const config$
|
|
1933
|
-
label: "
|
|
1813
|
+
const config$4 = adminSdk.defineRouteConfig({
|
|
1814
|
+
label: "Payments",
|
|
1934
1815
|
icon: icons.CreditCard
|
|
1935
1816
|
});
|
|
1936
|
-
const getStatusBadgeClass$
|
|
1817
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
1937
1818
|
const s2 = status.toLowerCase();
|
|
1938
1819
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1939
1820
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -2044,7 +1925,7 @@ const RefundDetailPage = () => {
|
|
|
2044
1925
|
ui.Badge,
|
|
2045
1926
|
{
|
|
2046
1927
|
size: "2xsmall",
|
|
2047
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1928
|
+
className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
|
|
2048
1929
|
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2049
1930
|
}
|
|
2050
1931
|
) })
|
|
@@ -2121,11 +2002,11 @@ const RefundDetailPage = () => {
|
|
|
2121
2002
|
] }) : null
|
|
2122
2003
|
] }) });
|
|
2123
2004
|
};
|
|
2124
|
-
const config$
|
|
2005
|
+
const config$3 = adminSdk.defineRouteConfig({
|
|
2125
2006
|
label: "Refund details",
|
|
2126
2007
|
icon: icons.Receipt
|
|
2127
2008
|
});
|
|
2128
|
-
const getStatusBadgeClass$
|
|
2009
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
2129
2010
|
const statusLower = status.toLowerCase();
|
|
2130
2011
|
if (statusLower === "requested") {
|
|
2131
2012
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2136,105 +2017,109 @@ const getStatusBadgeClass$1 = (status) => {
|
|
|
2136
2017
|
if (statusLower === "rejected") {
|
|
2137
2018
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2138
2019
|
}
|
|
2139
|
-
if (statusLower === "received") {
|
|
2140
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2141
|
-
}
|
|
2142
|
-
if (statusLower === "refunded") {
|
|
2143
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2144
|
-
}
|
|
2145
2020
|
if (statusLower === "completed") {
|
|
2146
2021
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2147
2022
|
}
|
|
2148
|
-
if (statusLower === "cancelled") {
|
|
2023
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2149
2024
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2150
2025
|
}
|
|
2026
|
+
if (statusLower === "pending") {
|
|
2027
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2028
|
+
}
|
|
2151
2029
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2152
2030
|
};
|
|
2153
|
-
const
|
|
2154
|
-
var _a, _b;
|
|
2031
|
+
const SwapDetailPage = () => {
|
|
2032
|
+
var _a, _b, _c;
|
|
2155
2033
|
const navigate = reactRouterDom.useNavigate();
|
|
2156
2034
|
const { id } = reactRouterDom.useParams();
|
|
2157
|
-
const [
|
|
2035
|
+
const [swap, setSwap] = react.useState(null);
|
|
2036
|
+
const [order, setOrder] = react.useState(null);
|
|
2158
2037
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
2159
|
-
|
|
2038
|
+
react.useState(false);
|
|
2039
|
+
const [isCancelling, setIsCancelling] = react.useState(false);
|
|
2160
2040
|
const [error, setError] = react.useState(null);
|
|
2161
2041
|
const [updateError, setUpdateError] = react.useState(null);
|
|
2162
2042
|
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
2163
2043
|
react.useEffect(() => {
|
|
2164
2044
|
if (!id) {
|
|
2165
|
-
navigate("/
|
|
2045
|
+
navigate("/swaps");
|
|
2166
2046
|
return;
|
|
2167
2047
|
}
|
|
2168
|
-
const
|
|
2048
|
+
const loadSwap = async () => {
|
|
2169
2049
|
try {
|
|
2170
2050
|
setIsLoading(true);
|
|
2171
2051
|
setError(null);
|
|
2172
|
-
const response = await fetch(`/admin/
|
|
2052
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2173
2053
|
credentials: "include"
|
|
2174
2054
|
});
|
|
2175
2055
|
if (!response.ok) {
|
|
2176
2056
|
const message = await response.text();
|
|
2177
|
-
throw new Error(message || "Unable to load
|
|
2057
|
+
throw new Error(message || "Unable to load swap");
|
|
2178
2058
|
}
|
|
2179
2059
|
const payload = await response.json();
|
|
2180
|
-
|
|
2060
|
+
setSwap(payload.swap);
|
|
2061
|
+
setOrder(payload.order || null);
|
|
2181
2062
|
} catch (loadError) {
|
|
2182
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2063
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2183
2064
|
setError(message);
|
|
2184
2065
|
} finally {
|
|
2185
2066
|
setIsLoading(false);
|
|
2186
2067
|
}
|
|
2187
2068
|
};
|
|
2188
|
-
void
|
|
2069
|
+
void loadSwap();
|
|
2189
2070
|
}, [id, navigate]);
|
|
2190
|
-
const
|
|
2071
|
+
const handleCancelExchange = async () => {
|
|
2191
2072
|
if (!id) {
|
|
2192
2073
|
return;
|
|
2193
2074
|
}
|
|
2194
2075
|
try {
|
|
2195
|
-
|
|
2076
|
+
setIsCancelling(true);
|
|
2196
2077
|
setUpdateError(null);
|
|
2197
2078
|
setUpdateSuccess(false);
|
|
2198
|
-
const response = await fetch(`/admin/
|
|
2079
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2199
2080
|
method: "POST",
|
|
2200
2081
|
headers: {
|
|
2201
2082
|
"Content-Type": "application/json"
|
|
2202
2083
|
},
|
|
2203
|
-
credentials: "include"
|
|
2204
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2084
|
+
credentials: "include"
|
|
2205
2085
|
});
|
|
2206
2086
|
if (!response.ok) {
|
|
2207
2087
|
const message = await response.text();
|
|
2208
|
-
throw new Error(message || "Unable to
|
|
2088
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2209
2089
|
}
|
|
2210
2090
|
const payload = await response.json();
|
|
2211
|
-
|
|
2091
|
+
setSwap(payload.swap);
|
|
2212
2092
|
setUpdateSuccess(true);
|
|
2213
2093
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2214
|
-
const detailResponse = await fetch(`/admin/
|
|
2094
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2215
2095
|
credentials: "include"
|
|
2216
2096
|
});
|
|
2217
2097
|
if (detailResponse.ok) {
|
|
2218
2098
|
const detailPayload = await detailResponse.json();
|
|
2219
|
-
|
|
2099
|
+
setSwap(detailPayload.swap);
|
|
2100
|
+
setOrder(detailPayload.order || null);
|
|
2220
2101
|
}
|
|
2221
|
-
} catch (
|
|
2222
|
-
const message =
|
|
2102
|
+
} catch (cancelErr) {
|
|
2103
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2223
2104
|
setUpdateError(message);
|
|
2224
2105
|
} finally {
|
|
2225
|
-
|
|
2106
|
+
setIsCancelling(false);
|
|
2226
2107
|
}
|
|
2227
2108
|
};
|
|
2109
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2110
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2111
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2112
|
+
);
|
|
2228
2113
|
if (isLoading) {
|
|
2229
|
-
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
|
|
2114
|
+
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..." }) }) }) });
|
|
2230
2115
|
}
|
|
2231
|
-
if (error || !
|
|
2116
|
+
if (error || !swap) {
|
|
2232
2117
|
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: [
|
|
2233
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2234
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/
|
|
2118
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2119
|
+
/* @__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" }) })
|
|
2235
2120
|
] }) }) });
|
|
2236
2121
|
}
|
|
2237
|
-
const statusHistory = ((
|
|
2122
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2238
2123
|
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: [
|
|
2239
2124
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2240
2125
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2242,7 +2127,7 @@ const ReturnDetailPage = () => {
|
|
|
2242
2127
|
{
|
|
2243
2128
|
variant: "transparent",
|
|
2244
2129
|
size: "small",
|
|
2245
|
-
onClick: () => navigate("/
|
|
2130
|
+
onClick: () => navigate("/swaps"),
|
|
2246
2131
|
className: "w-fit",
|
|
2247
2132
|
children: [
|
|
2248
2133
|
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
@@ -2252,81 +2137,67 @@ const ReturnDetailPage = () => {
|
|
|
2252
2137
|
),
|
|
2253
2138
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2254
2139
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2255
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
2256
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2140
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Exchange Details" }),
|
|
2141
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2257
2142
|
] }),
|
|
2258
2143
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2259
2144
|
ui.Badge,
|
|
2260
2145
|
{
|
|
2261
2146
|
size: "small",
|
|
2262
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2263
|
-
children:
|
|
2147
|
+
className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
|
|
2148
|
+
children: swap.status.replace(/_/g, " ")
|
|
2264
2149
|
}
|
|
2265
2150
|
)
|
|
2266
2151
|
] })
|
|
2267
2152
|
] }),
|
|
2268
|
-
|
|
2153
|
+
canCancelExchange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2269
2154
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2270
2155
|
ui.Button,
|
|
2271
2156
|
{
|
|
2272
2157
|
variant: "danger",
|
|
2273
|
-
onClick:
|
|
2274
|
-
disabled:
|
|
2275
|
-
isLoading:
|
|
2276
|
-
children: "
|
|
2158
|
+
onClick: handleCancelExchange,
|
|
2159
|
+
disabled: isCancelling,
|
|
2160
|
+
isLoading: isCancelling,
|
|
2161
|
+
children: "Cancel Exchange"
|
|
2277
2162
|
}
|
|
2278
2163
|
) }),
|
|
2279
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2280
|
-
] }),
|
|
2281
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2282
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2283
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2284
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2285
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2286
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
|
|
2287
|
-
] }),
|
|
2288
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2289
|
-
ui.Button,
|
|
2290
|
-
{
|
|
2291
|
-
variant: "secondary",
|
|
2292
|
-
onClick: () => {
|
|
2293
|
-
window.open(
|
|
2294
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
2295
|
-
"_blank"
|
|
2296
|
-
);
|
|
2297
|
-
},
|
|
2298
|
-
children: "View order"
|
|
2299
|
-
}
|
|
2300
|
-
) })
|
|
2301
|
-
] })
|
|
2164
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2302
2165
|
] }),
|
|
2303
2166
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2304
2167
|
/* @__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: "
|
|
2168
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2306
2169
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2307
2170
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2308
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2309
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2171
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2172
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
2310
2173
|
] }),
|
|
2311
2174
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2312
2175
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2313
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2176
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
2314
2177
|
] }),
|
|
2315
|
-
|
|
2178
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2179
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2180
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2181
|
+
] }),
|
|
2182
|
+
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2316
2183
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2317
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2184
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
2318
2185
|
] }),
|
|
2319
|
-
|
|
2186
|
+
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2320
2187
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2321
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2188
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
2322
2189
|
] }),
|
|
2323
2190
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2324
2191
|
/* @__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(
|
|
2192
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2326
2193
|
] }),
|
|
2327
2194
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2328
2195
|
/* @__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(
|
|
2196
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2197
|
+
] }),
|
|
2198
|
+
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2199
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2200
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
2330
2201
|
] })
|
|
2331
2202
|
] })
|
|
2332
2203
|
] }),
|
|
@@ -2341,7 +2212,7 @@ const ReturnDetailPage = () => {
|
|
|
2341
2212
|
ui.Badge,
|
|
2342
2213
|
{
|
|
2343
2214
|
size: "2xsmall",
|
|
2344
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2215
|
+
className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
|
|
2345
2216
|
children: entry.status.replace(/_/g, " ")
|
|
2346
2217
|
}
|
|
2347
2218
|
) }),
|
|
@@ -2356,31 +2227,31 @@ const ReturnDetailPage = () => {
|
|
|
2356
2227
|
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2357
2228
|
] })
|
|
2358
2229
|
] }),
|
|
2359
|
-
|
|
2230
|
+
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2360
2231
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2361
2232
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2362
2233
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2363
2234
|
/* @__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:
|
|
2235
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
2365
2236
|
] }),
|
|
2366
2237
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2367
2238
|
/* @__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:
|
|
2239
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
2369
2240
|
] }),
|
|
2370
2241
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2371
2242
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2372
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((
|
|
2243
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2373
2244
|
] }),
|
|
2374
|
-
|
|
2245
|
+
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2375
2246
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2376
2247
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
2377
|
-
|
|
2378
|
-
(Number(
|
|
2248
|
+
order.currency_code || "$",
|
|
2249
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2379
2250
|
] })
|
|
2380
2251
|
] })
|
|
2381
2252
|
] })
|
|
2382
2253
|
] }),
|
|
2383
|
-
|
|
2254
|
+
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: [
|
|
2384
2255
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2385
2256
|
/* @__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
2257
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
@@ -2388,22 +2259,33 @@ const ReturnDetailPage = () => {
|
|
|
2388
2259
|
/* @__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
2260
|
/* @__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
2261
|
] }) }),
|
|
2391
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2262
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2392
2263
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2393
2264
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2394
2265
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2395
2266
|
] }, item.id || index)) })
|
|
2396
2267
|
] }) })
|
|
2397
2268
|
] }),
|
|
2398
|
-
|
|
2399
|
-
|
|
2269
|
+
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: [
|
|
2270
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2271
|
+
/* @__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: [
|
|
2272
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2273
|
+
/* @__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" }),
|
|
2274
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2275
|
+
] }) }),
|
|
2276
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2277
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2278
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2279
|
+
] }, item.variant_id || index)) })
|
|
2280
|
+
] }) })
|
|
2281
|
+
] })
|
|
2400
2282
|
] }) });
|
|
2401
2283
|
};
|
|
2402
|
-
const config$
|
|
2403
|
-
label: "
|
|
2404
|
-
icon: icons.
|
|
2284
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
2285
|
+
label: "Swap Details",
|
|
2286
|
+
icon: icons.ArrowPath
|
|
2405
2287
|
});
|
|
2406
|
-
const getStatusBadgeClass = (status) => {
|
|
2288
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
2407
2289
|
const statusLower = status.toLowerCase();
|
|
2408
2290
|
if (statusLower === "requested") {
|
|
2409
2291
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2414,109 +2296,105 @@ const getStatusBadgeClass = (status) => {
|
|
|
2414
2296
|
if (statusLower === "rejected") {
|
|
2415
2297
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2416
2298
|
}
|
|
2299
|
+
if (statusLower === "received") {
|
|
2300
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2301
|
+
}
|
|
2302
|
+
if (statusLower === "refunded") {
|
|
2303
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2304
|
+
}
|
|
2417
2305
|
if (statusLower === "completed") {
|
|
2418
2306
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2419
2307
|
}
|
|
2420
|
-
if (statusLower === "cancelled"
|
|
2308
|
+
if (statusLower === "cancelled") {
|
|
2421
2309
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2422
2310
|
}
|
|
2423
|
-
if (statusLower === "pending") {
|
|
2424
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2425
|
-
}
|
|
2426
2311
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2427
2312
|
};
|
|
2428
|
-
const
|
|
2429
|
-
var _a, _b
|
|
2313
|
+
const ReturnDetailPage = () => {
|
|
2314
|
+
var _a, _b;
|
|
2430
2315
|
const navigate = reactRouterDom.useNavigate();
|
|
2431
2316
|
const { id } = reactRouterDom.useParams();
|
|
2432
|
-
const [
|
|
2433
|
-
const [order, setOrder] = react.useState(null);
|
|
2317
|
+
const [returnOrder, setReturnOrder] = react.useState(null);
|
|
2434
2318
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
2435
|
-
react.useState(false);
|
|
2436
|
-
const [isCancelling, setIsCancelling] = react.useState(false);
|
|
2319
|
+
const [isRejecting, setIsRejecting] = react.useState(false);
|
|
2437
2320
|
const [error, setError] = react.useState(null);
|
|
2438
2321
|
const [updateError, setUpdateError] = react.useState(null);
|
|
2439
2322
|
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
2440
2323
|
react.useEffect(() => {
|
|
2441
2324
|
if (!id) {
|
|
2442
|
-
navigate("/
|
|
2325
|
+
navigate("/returns");
|
|
2443
2326
|
return;
|
|
2444
2327
|
}
|
|
2445
|
-
const
|
|
2328
|
+
const loadReturn = async () => {
|
|
2446
2329
|
try {
|
|
2447
2330
|
setIsLoading(true);
|
|
2448
2331
|
setError(null);
|
|
2449
|
-
const response = await fetch(`/admin/
|
|
2332
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
2450
2333
|
credentials: "include"
|
|
2451
2334
|
});
|
|
2452
2335
|
if (!response.ok) {
|
|
2453
2336
|
const message = await response.text();
|
|
2454
|
-
throw new Error(message || "Unable to load
|
|
2337
|
+
throw new Error(message || "Unable to load return order");
|
|
2455
2338
|
}
|
|
2456
2339
|
const payload = await response.json();
|
|
2457
|
-
|
|
2458
|
-
setOrder(payload.order || null);
|
|
2340
|
+
setReturnOrder(payload.return);
|
|
2459
2341
|
} catch (loadError) {
|
|
2460
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2342
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
2461
2343
|
setError(message);
|
|
2462
2344
|
} finally {
|
|
2463
2345
|
setIsLoading(false);
|
|
2464
2346
|
}
|
|
2465
2347
|
};
|
|
2466
|
-
void
|
|
2348
|
+
void loadReturn();
|
|
2467
2349
|
}, [id, navigate]);
|
|
2468
|
-
const
|
|
2350
|
+
const handleReject = async () => {
|
|
2469
2351
|
if (!id) {
|
|
2470
2352
|
return;
|
|
2471
2353
|
}
|
|
2472
2354
|
try {
|
|
2473
|
-
|
|
2355
|
+
setIsRejecting(true);
|
|
2474
2356
|
setUpdateError(null);
|
|
2475
2357
|
setUpdateSuccess(false);
|
|
2476
|
-
const response = await fetch(`/admin/
|
|
2358
|
+
const response = await fetch(`/admin/returns/${id}/reject`, {
|
|
2477
2359
|
method: "POST",
|
|
2478
2360
|
headers: {
|
|
2479
2361
|
"Content-Type": "application/json"
|
|
2480
2362
|
},
|
|
2481
|
-
credentials: "include"
|
|
2363
|
+
credentials: "include",
|
|
2364
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2482
2365
|
});
|
|
2483
2366
|
if (!response.ok) {
|
|
2484
2367
|
const message = await response.text();
|
|
2485
|
-
throw new Error(message || "Unable to
|
|
2368
|
+
throw new Error(message || "Unable to reject return");
|
|
2486
2369
|
}
|
|
2487
2370
|
const payload = await response.json();
|
|
2488
|
-
|
|
2371
|
+
setReturnOrder(payload.return);
|
|
2489
2372
|
setUpdateSuccess(true);
|
|
2490
2373
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2491
|
-
const detailResponse = await fetch(`/admin/
|
|
2374
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
2492
2375
|
credentials: "include"
|
|
2493
2376
|
});
|
|
2494
2377
|
if (detailResponse.ok) {
|
|
2495
2378
|
const detailPayload = await detailResponse.json();
|
|
2496
|
-
|
|
2497
|
-
setOrder(detailPayload.order || null);
|
|
2379
|
+
setReturnOrder(detailPayload.return);
|
|
2498
2380
|
}
|
|
2499
|
-
} catch (
|
|
2500
|
-
const message =
|
|
2381
|
+
} catch (updateErr) {
|
|
2382
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
2501
2383
|
setUpdateError(message);
|
|
2502
2384
|
} finally {
|
|
2503
|
-
|
|
2385
|
+
setIsRejecting(false);
|
|
2504
2386
|
}
|
|
2505
2387
|
};
|
|
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
2388
|
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
|
|
2389
|
+
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 return order..." }) }) }) });
|
|
2512
2390
|
}
|
|
2513
|
-
if (error || !
|
|
2391
|
+
if (error || !returnOrder) {
|
|
2514
2392
|
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 || "
|
|
2516
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/
|
|
2393
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
2394
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2517
2395
|
] }) }) });
|
|
2518
2396
|
}
|
|
2519
|
-
const statusHistory = ((
|
|
2397
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
2520
2398
|
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
2399
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2522
2400
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2524,7 +2402,7 @@ const SwapDetailPage = () => {
|
|
|
2524
2402
|
{
|
|
2525
2403
|
variant: "transparent",
|
|
2526
2404
|
size: "small",
|
|
2527
|
-
onClick: () => navigate("/
|
|
2405
|
+
onClick: () => navigate("/returns"),
|
|
2528
2406
|
className: "w-fit",
|
|
2529
2407
|
children: [
|
|
2530
2408
|
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
@@ -2534,67 +2412,81 @@ const SwapDetailPage = () => {
|
|
|
2534
2412
|
),
|
|
2535
2413
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2536
2414
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2537
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
2538
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2415
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
|
|
2416
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
2539
2417
|
] }),
|
|
2540
2418
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2541
2419
|
ui.Badge,
|
|
2542
2420
|
{
|
|
2543
2421
|
size: "small",
|
|
2544
|
-
className: `uppercase ${getStatusBadgeClass(
|
|
2545
|
-
children:
|
|
2422
|
+
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
2423
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2546
2424
|
}
|
|
2547
2425
|
)
|
|
2548
2426
|
] })
|
|
2549
2427
|
] }),
|
|
2550
|
-
|
|
2428
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2551
2429
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2552
2430
|
ui.Button,
|
|
2553
2431
|
{
|
|
2554
2432
|
variant: "danger",
|
|
2555
|
-
onClick:
|
|
2556
|
-
disabled:
|
|
2557
|
-
isLoading:
|
|
2558
|
-
children: "Cancel
|
|
2433
|
+
onClick: handleReject,
|
|
2434
|
+
disabled: isRejecting,
|
|
2435
|
+
isLoading: isRejecting,
|
|
2436
|
+
children: "Reject (Cancel) Return"
|
|
2559
2437
|
}
|
|
2560
2438
|
) }),
|
|
2561
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2439
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
2440
|
+
] }),
|
|
2441
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2442
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2443
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2444
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2445
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2446
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
|
|
2447
|
+
] }),
|
|
2448
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2449
|
+
ui.Button,
|
|
2450
|
+
{
|
|
2451
|
+
variant: "secondary",
|
|
2452
|
+
onClick: () => {
|
|
2453
|
+
window.open(
|
|
2454
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
2455
|
+
"_blank"
|
|
2456
|
+
);
|
|
2457
|
+
},
|
|
2458
|
+
children: "View order"
|
|
2459
|
+
}
|
|
2460
|
+
) })
|
|
2461
|
+
] })
|
|
2562
2462
|
] }),
|
|
2563
2463
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2564
2464
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2565
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
2465
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2566
2466
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2567
2467
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2568
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2569
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2468
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2469
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
|
|
2570
2470
|
] }),
|
|
2571
2471
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2572
2472
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2573
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2574
|
-
] }),
|
|
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)}` : "—" })
|
|
2473
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
|
|
2578
2474
|
] }),
|
|
2579
|
-
|
|
2475
|
+
returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2580
2476
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2581
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2477
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
|
|
2582
2478
|
] }),
|
|
2583
|
-
|
|
2479
|
+
returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2584
2480
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2585
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
2481
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
|
|
2586
2482
|
] }),
|
|
2587
2483
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2588
2484
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2589
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(
|
|
2485
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2590
2486
|
] }),
|
|
2591
2487
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2592
2488
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2593
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(
|
|
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 })
|
|
2489
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2598
2490
|
] })
|
|
2599
2491
|
] })
|
|
2600
2492
|
] }),
|
|
@@ -2609,7 +2501,7 @@ const SwapDetailPage = () => {
|
|
|
2609
2501
|
ui.Badge,
|
|
2610
2502
|
{
|
|
2611
2503
|
size: "2xsmall",
|
|
2612
|
-
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
2504
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
2613
2505
|
children: entry.status.replace(/_/g, " ")
|
|
2614
2506
|
}
|
|
2615
2507
|
) }),
|
|
@@ -2624,31 +2516,31 @@ const SwapDetailPage = () => {
|
|
|
2624
2516
|
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2625
2517
|
] })
|
|
2626
2518
|
] }),
|
|
2627
|
-
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2519
|
+
returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2628
2520
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2629
2521
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2630
2522
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2631
2523
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2632
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
2524
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2633
2525
|
] }),
|
|
2634
2526
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2635
2527
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2636
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
2528
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2637
2529
|
] }),
|
|
2638
2530
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2639
2531
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2640
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((
|
|
2532
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2641
2533
|
] }),
|
|
2642
|
-
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2534
|
+
returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2643
2535
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2644
2536
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
2645
|
-
order.currency_code || "$",
|
|
2646
|
-
(Number(order.total) / 100).toFixed(2)
|
|
2537
|
+
returnOrder.order.currency_code || "$",
|
|
2538
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2647
2539
|
] })
|
|
2648
2540
|
] })
|
|
2649
2541
|
] })
|
|
2650
2542
|
] }),
|
|
2651
|
-
|
|
2543
|
+
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: [
|
|
2652
2544
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2653
2545
|
/* @__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: [
|
|
2654
2546
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
@@ -2656,31 +2548,139 @@ const SwapDetailPage = () => {
|
|
|
2656
2548
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2657
2549
|
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2658
2550
|
] }) }),
|
|
2659
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2551
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2660
2552
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2661
2553
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2662
2554
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2663
2555
|
] }, item.id || index)) })
|
|
2664
2556
|
] }) })
|
|
2665
2557
|
] }),
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2558
|
+
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 }) }),
|
|
2559
|
+
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" }) })
|
|
2560
|
+
] }) });
|
|
2561
|
+
};
|
|
2562
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
2563
|
+
label: "Return Order Details",
|
|
2564
|
+
icon: icons.CheckCircle
|
|
2565
|
+
});
|
|
2566
|
+
const getStatusBadgeClass = (status) => {
|
|
2567
|
+
const s2 = status.toLowerCase();
|
|
2568
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2569
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2570
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2571
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2572
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2573
|
+
};
|
|
2574
|
+
const PaymentDetailPage = () => {
|
|
2575
|
+
var _a;
|
|
2576
|
+
const navigate = reactRouterDom.useNavigate();
|
|
2577
|
+
const params = reactRouterDom.useParams();
|
|
2578
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2579
|
+
const [detail, setDetail] = react.useState(null);
|
|
2580
|
+
const [loading, setLoading] = react.useState(!!id);
|
|
2581
|
+
const [error, setError] = react.useState(null);
|
|
2582
|
+
react.useEffect(() => {
|
|
2583
|
+
if (!id) {
|
|
2584
|
+
setLoading(false);
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
let cancelled = false;
|
|
2588
|
+
setLoading(true);
|
|
2589
|
+
setError(null);
|
|
2590
|
+
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
2591
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2592
|
+
return res.json();
|
|
2593
|
+
}).then((data) => {
|
|
2594
|
+
if (!cancelled) setDetail(data);
|
|
2595
|
+
}).catch((e) => {
|
|
2596
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2597
|
+
}).finally(() => {
|
|
2598
|
+
if (!cancelled) setLoading(false);
|
|
2599
|
+
});
|
|
2600
|
+
return () => {
|
|
2601
|
+
cancelled = true;
|
|
2602
|
+
};
|
|
2603
|
+
}, [id]);
|
|
2604
|
+
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
2605
|
+
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
2606
|
+
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
2607
|
+
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
2608
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
2609
|
+
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2610
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
2611
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payment session" }),
|
|
2612
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
2613
|
+
] }) }),
|
|
2614
|
+
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2615
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2616
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
|
|
2617
|
+
] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2618
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2619
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2620
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
|
|
2621
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2622
|
+
ui.Button,
|
|
2623
|
+
{
|
|
2624
|
+
variant: "transparent",
|
|
2625
|
+
size: "small",
|
|
2626
|
+
onClick: () => navigate(`/orders/${detail.order_id}`),
|
|
2627
|
+
children: detail.order_id
|
|
2628
|
+
}
|
|
2629
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
|
|
2630
|
+
] }),
|
|
2631
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2632
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2633
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
|
|
2634
|
+
] }),
|
|
2635
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2636
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2637
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
|
|
2638
|
+
] }),
|
|
2639
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2640
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2641
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2642
|
+
ui.Badge,
|
|
2643
|
+
{
|
|
2644
|
+
size: "2xsmall",
|
|
2645
|
+
className: `uppercase ${getStatusBadgeClass(displayStatus)}`,
|
|
2646
|
+
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
2647
|
+
}
|
|
2648
|
+
) })
|
|
2649
|
+
] }),
|
|
2650
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2651
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
2652
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
2653
|
+
] }),
|
|
2654
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2655
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
2657
|
+
] }),
|
|
2658
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2659
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
2660
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
2661
|
+
] }),
|
|
2662
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2663
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
2664
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
2665
|
+
year: "numeric",
|
|
2666
|
+
month: "short",
|
|
2667
|
+
day: "numeric",
|
|
2668
|
+
hour: "numeric",
|
|
2669
|
+
minute: "2-digit",
|
|
2670
|
+
hour12: true
|
|
2671
|
+
}) })
|
|
2672
|
+
] })
|
|
2673
|
+
] }) }),
|
|
2674
|
+
Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
|
|
2676
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
|
|
2677
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
|
|
2678
|
+
] }) : null
|
|
2679
2679
|
] }) });
|
|
2680
2680
|
};
|
|
2681
2681
|
const config = adminSdk.defineRouteConfig({
|
|
2682
|
-
label: "
|
|
2683
|
-
icon: icons.
|
|
2682
|
+
label: "Payment details",
|
|
2683
|
+
icon: icons.CreditCard
|
|
2684
2684
|
});
|
|
2685
2685
|
const i18nTranslations0 = {};
|
|
2686
2686
|
const widgetModule = { widgets: [
|
|
@@ -2695,45 +2695,45 @@ const widgetModule = { widgets: [
|
|
|
2695
2695
|
] };
|
|
2696
2696
|
const routeModule = {
|
|
2697
2697
|
routes: [
|
|
2698
|
-
{
|
|
2699
|
-
Component: PaymentsPage,
|
|
2700
|
-
path: "/payments"
|
|
2701
|
-
},
|
|
2702
2698
|
{
|
|
2703
2699
|
Component: RefundsPage,
|
|
2704
2700
|
path: "/refunds"
|
|
2705
2701
|
},
|
|
2706
|
-
{
|
|
2707
|
-
Component: ReturnsPage,
|
|
2708
|
-
path: "/returns"
|
|
2709
|
-
},
|
|
2710
2702
|
{
|
|
2711
2703
|
Component: SwapsPage,
|
|
2712
2704
|
path: "/swaps"
|
|
2713
2705
|
},
|
|
2714
2706
|
{
|
|
2715
|
-
Component:
|
|
2716
|
-
path: "/
|
|
2707
|
+
Component: ReturnsPage,
|
|
2708
|
+
path: "/returns"
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
Component: PaymentsPage,
|
|
2712
|
+
path: "/payments"
|
|
2717
2713
|
},
|
|
2718
2714
|
{
|
|
2719
2715
|
Component: RefundDetailPage,
|
|
2720
2716
|
path: "/refunds/:id"
|
|
2721
2717
|
},
|
|
2718
|
+
{
|
|
2719
|
+
Component: SwapDetailPage,
|
|
2720
|
+
path: "/swaps/:id"
|
|
2721
|
+
},
|
|
2722
2722
|
{
|
|
2723
2723
|
Component: ReturnDetailPage,
|
|
2724
2724
|
path: "/returns/:id"
|
|
2725
2725
|
},
|
|
2726
2726
|
{
|
|
2727
|
-
Component:
|
|
2728
|
-
path: "/
|
|
2727
|
+
Component: PaymentDetailPage,
|
|
2728
|
+
path: "/payments/:id"
|
|
2729
2729
|
}
|
|
2730
2730
|
]
|
|
2731
2731
|
};
|
|
2732
2732
|
const menuItemModule = {
|
|
2733
2733
|
menuItems: [
|
|
2734
2734
|
{
|
|
2735
|
-
label: config$
|
|
2736
|
-
icon: config$
|
|
2735
|
+
label: config$4.label,
|
|
2736
|
+
icon: config$4.icon,
|
|
2737
2737
|
path: "/payments",
|
|
2738
2738
|
nested: void 0
|
|
2739
2739
|
},
|
|
@@ -2744,20 +2744,20 @@ const menuItemModule = {
|
|
|
2744
2744
|
nested: void 0
|
|
2745
2745
|
},
|
|
2746
2746
|
{
|
|
2747
|
-
label: config$
|
|
2748
|
-
icon: config$
|
|
2747
|
+
label: config$7.label,
|
|
2748
|
+
icon: config$7.icon,
|
|
2749
2749
|
path: "/refunds",
|
|
2750
2750
|
nested: void 0
|
|
2751
2751
|
},
|
|
2752
2752
|
{
|
|
2753
|
-
label: config$
|
|
2754
|
-
icon: config$
|
|
2753
|
+
label: config$6.label,
|
|
2754
|
+
icon: config$6.icon,
|
|
2755
2755
|
path: "/swaps",
|
|
2756
2756
|
nested: void 0
|
|
2757
2757
|
},
|
|
2758
2758
|
{
|
|
2759
|
-
label: config
|
|
2760
|
-
icon: config
|
|
2759
|
+
label: config.label,
|
|
2760
|
+
icon: config.icon,
|
|
2761
2761
|
path: "/payments/:id",
|
|
2762
2762
|
nested: void 0
|
|
2763
2763
|
},
|
|
@@ -2768,14 +2768,14 @@ const menuItemModule = {
|
|
|
2768
2768
|
nested: void 0
|
|
2769
2769
|
},
|
|
2770
2770
|
{
|
|
2771
|
-
label: config$
|
|
2772
|
-
icon: config$
|
|
2771
|
+
label: config$3.label,
|
|
2772
|
+
icon: config$3.icon,
|
|
2773
2773
|
path: "/refunds/:id",
|
|
2774
2774
|
nested: void 0
|
|
2775
2775
|
},
|
|
2776
2776
|
{
|
|
2777
|
-
label: config.label,
|
|
2778
|
-
icon: config.icon,
|
|
2777
|
+
label: config$2.label,
|
|
2778
|
+
icon: config$2.icon,
|
|
2779
2779
|
path: "/swaps/:id",
|
|
2780
2780
|
nested: void 0
|
|
2781
2781
|
}
|