order-management 0.0.78 → 0.0.79

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