order-management 0.0.88 → 0.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,7 +1360,7 @@ 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";
@@ -1185,7 +1385,7 @@ const ReturnsPage = () => {
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);
@@ -1331,7 +1531,7 @@ const ReturnsPage = () => {
1331
1531
  ui.Badge,
1332
1532
  {
1333
1533
  size: "2xsmall",
1334
- className: `uppercase ${getStatusBadgeClass$6(returnOrder.status)}`,
1534
+ className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
1335
1535
  children: returnOrder.status.replace(/_/g, " ")
1336
1536
  }
1337
1537
  ) }),
@@ -1380,11 +1580,11 @@ const ReturnsPage = () => {
1380
1580
  ) }) : null
1381
1581
  ] }) });
1382
1582
  };
1383
- const config$6 = adminSdk.defineRouteConfig({
1583
+ const config$5 = adminSdk.defineRouteConfig({
1384
1584
  label: "Return Orders",
1385
1585
  icon: icons.ArrowPath
1386
1586
  });
1387
- const useDebounce$1 = (value, delay) => {
1587
+ const useDebounce = (value, delay) => {
1388
1588
  const [debouncedValue, setDebouncedValue] = react.useState(value);
1389
1589
  react.useEffect(() => {
1390
1590
  const handler = setTimeout(() => setDebouncedValue(value), delay);
@@ -1392,247 +1592,47 @@ const useDebounce$1 = (value, delay) => {
1392
1592
  }, [value, delay]);
1393
1593
  return debouncedValue;
1394
1594
  };
1395
- const getStatusBadgeClass$5 = (status) => {
1396
- const s2 = status.toLowerCase();
1397
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1398
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1399
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1400
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1595
+ const getStatusBadgeClass$4 = (status) => {
1596
+ const statusLower = status.toLowerCase();
1597
+ if (statusLower === "requested") {
1598
+ return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1599
+ }
1600
+ if (statusLower === "approved") {
1601
+ return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1602
+ }
1603
+ if (statusLower === "rejected") {
1604
+ return "bg-ui-tag-red-bg text-ui-tag-red-text";
1605
+ }
1606
+ if (statusLower === "completed") {
1607
+ return "bg-ui-tag-green-bg text-ui-tag-green-text";
1608
+ }
1609
+ if (statusLower === "cancelled") {
1610
+ return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
1611
+ }
1401
1612
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1402
1613
  };
1403
- const PaymentsPage = () => {
1614
+ const SwapsPage = () => {
1404
1615
  const navigate = reactRouterDom.useNavigate();
1405
1616
  const [items, setItems] = react.useState([]);
1406
1617
  const [statusFilter, setStatusFilter] = react.useState("all");
1407
- const [orderIdSearch, setOrderIdSearch] = react.useState("");
1408
- const debouncedOrderId = useDebounce$1(orderIdSearch, 300);
1618
+ const [createdByFilter, setCreatedByFilter] = react.useState("all");
1619
+ const [searchQuery, setSearchQuery] = react.useState("");
1620
+ const debouncedSearchQuery = useDebounce(searchQuery, 300);
1409
1621
  const [isLoading, setIsLoading] = react.useState(true);
1410
1622
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1411
1623
  const [error, setError] = react.useState(null);
1412
1624
  const [offset, setOffset] = react.useState(0);
1413
1625
  const [count, setCount] = react.useState(0);
1414
1626
  const limit = 50;
1415
- const loadTransactions = react.useCallback(
1416
- async (nextOffset, replace) => {
1627
+ const loadSwaps = react.useCallback(
1628
+ async (nextOffset, replace = false) => {
1629
+ var _a;
1417
1630
  try {
1418
- if (replace) setIsLoading(true);
1419
- else setIsFetchingMore(true);
1420
- setError(null);
1421
- const params = new URLSearchParams();
1422
- params.set("limit", String(limit));
1423
- params.set("offset", String(nextOffset));
1424
- if (statusFilter !== "all") params.set("status", statusFilter);
1425
- if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
1426
- const response = await fetch(
1427
- `/admin/payment-transactions?${params.toString()}`,
1428
- { credentials: "include" }
1429
- );
1430
- if (!response.ok) {
1431
- const text = await response.text();
1432
- throw new Error(text || "Failed to load payment transactions");
1433
- }
1434
- const payload = await response.json();
1435
- const list = payload.transactions ?? [];
1436
- setCount(payload.count ?? 0);
1437
- setOffset(nextOffset + list.length);
1438
- setItems((prev) => replace ? list : [...prev, ...list]);
1439
- } catch (e) {
1440
- setError(e instanceof Error ? e.message : "Failed to load");
1441
- } finally {
1442
- setIsLoading(false);
1443
- setIsFetchingMore(false);
1444
- }
1445
- },
1446
- [statusFilter, debouncedOrderId]
1447
- );
1448
- react.useEffect(() => {
1449
- void loadTransactions(0, true);
1450
- }, [loadTransactions]);
1451
- const hasMore = react.useMemo(() => offset < count, [offset, count]);
1452
- const displayStatus = (t) => {
1453
- const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
1454
- return s2 !== "" ? s2 : "—";
1455
- };
1456
- const displayAmount = (t) => {
1457
- const code = (t.currency_code ?? "USD").toUpperCase();
1458
- return `${code} ${Number(t.amount)}`;
1459
- };
1460
- 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: [
1461
- /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1462
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1463
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
1464
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
1465
- ] }),
1466
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
1467
- ] }),
1468
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1469
- /* @__PURE__ */ jsxRuntime.jsx(
1470
- ui.Input,
1471
- {
1472
- placeholder: "Search by Order ID",
1473
- value: orderIdSearch,
1474
- onChange: (e) => setOrderIdSearch(e.target.value),
1475
- className: "md:max-w-sm",
1476
- "aria-label": "Search by order ID"
1477
- }
1478
- ),
1479
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
1480
- "select",
1481
- {
1482
- value: statusFilter,
1483
- onChange: (e) => setStatusFilter(e.target.value),
1484
- 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",
1485
- "aria-label": "Filter by status",
1486
- children: [
1487
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
1488
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
1489
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
1490
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
1491
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
1492
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
1493
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
1494
- ]
1495
- }
1496
- ) })
1497
- ] }),
1498
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1499
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1500
- /* @__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" }) })
1501
- ] }) : null,
1502
- 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: [
1503
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
1504
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
1505
- ] }) : /* @__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: [
1506
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1507
- /* @__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" }),
1508
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
1509
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
1510
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1511
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
1512
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1513
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1514
- ] }) }),
1515
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
1516
- "tr",
1517
- {
1518
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1519
- onClick: () => navigate(`/payments/${t.payment_session_id}`),
1520
- children: [
1521
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
1522
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
1523
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
1524
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1525
- ui.Badge,
1526
- {
1527
- size: "2xsmall",
1528
- className: `uppercase ${getStatusBadgeClass$5(displayStatus(t))}`,
1529
- children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
1530
- }
1531
- ) }),
1532
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
1533
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
1534
- year: "numeric",
1535
- month: "short",
1536
- day: "numeric",
1537
- hour: "numeric",
1538
- minute: "2-digit",
1539
- hour12: true
1540
- }) }),
1541
- /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
1542
- /* @__PURE__ */ jsxRuntime.jsx(
1543
- ui.Button,
1544
- {
1545
- variant: "transparent",
1546
- size: "small",
1547
- onClick: (e) => {
1548
- e.stopPropagation();
1549
- navigate(`/payments/${t.payment_session_id}`);
1550
- },
1551
- children: "View details"
1552
- }
1553
- ),
1554
- t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1555
- ui.Button,
1556
- {
1557
- variant: "transparent",
1558
- size: "small",
1559
- onClick: (e) => {
1560
- e.stopPropagation();
1561
- navigate(`/orders/${t.order_id}`);
1562
- },
1563
- children: "Order"
1564
- }
1565
- ) : null
1566
- ] })
1567
- ]
1568
- },
1569
- t.payment_session_id
1570
- )) })
1571
- ] }) }),
1572
- hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1573
- ui.Button,
1574
- {
1575
- variant: "secondary",
1576
- isLoading: isFetchingMore,
1577
- onClick: () => loadTransactions(offset, false),
1578
- children: "Load more"
1579
- }
1580
- ) }) : null
1581
- ] }) });
1582
- };
1583
- const config$5 = adminSdk.defineRouteConfig({
1584
- label: "Payments",
1585
- icon: icons.CreditCard
1586
- });
1587
- const useDebounce = (value, delay) => {
1588
- const [debouncedValue, setDebouncedValue] = react.useState(value);
1589
- react.useEffect(() => {
1590
- const handler = setTimeout(() => setDebouncedValue(value), delay);
1591
- return () => clearTimeout(handler);
1592
- }, [value, delay]);
1593
- return debouncedValue;
1594
- };
1595
- const getStatusBadgeClass$4 = (status) => {
1596
- const statusLower = status.toLowerCase();
1597
- if (statusLower === "requested") {
1598
- return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1599
- }
1600
- if (statusLower === "approved") {
1601
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1602
- }
1603
- if (statusLower === "rejected") {
1604
- return "bg-ui-tag-red-bg text-ui-tag-red-text";
1605
- }
1606
- if (statusLower === "completed") {
1607
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
1608
- }
1609
- if (statusLower === "cancelled") {
1610
- return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
1611
- }
1612
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1613
- };
1614
- const SwapsPage = () => {
1615
- const navigate = reactRouterDom.useNavigate();
1616
- const [items, setItems] = react.useState([]);
1617
- const [statusFilter, setStatusFilter] = react.useState("all");
1618
- const [createdByFilter, setCreatedByFilter] = react.useState("all");
1619
- const [searchQuery, setSearchQuery] = react.useState("");
1620
- const debouncedSearchQuery = useDebounce(searchQuery, 300);
1621
- const [isLoading, setIsLoading] = react.useState(true);
1622
- const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1623
- const [error, setError] = react.useState(null);
1624
- const [offset, setOffset] = react.useState(0);
1625
- const [count, setCount] = react.useState(0);
1626
- const limit = 50;
1627
- const loadSwaps = react.useCallback(
1628
- async (nextOffset, replace = false) => {
1629
- var _a;
1630
- try {
1631
- if (replace) {
1632
- setIsLoading(true);
1633
- } else {
1634
- setIsFetchingMore(true);
1635
- }
1631
+ if (replace) {
1632
+ setIsLoading(true);
1633
+ } else {
1634
+ setIsFetchingMore(true);
1635
+ }
1636
1636
  setError(null);
1637
1637
  const params = new URLSearchParams();
1638
1638
  params.set("limit", String(limit));
@@ -1822,18 +1822,14 @@ const getStatusBadgeClass$3 = (status) => {
1822
1822
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1823
1823
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1824
1824
  };
1825
- const formatAmount = (value) => {
1826
- return String(value);
1827
- };
1828
- const RefundDetailPage = () => {
1829
- var _a, _b, _c;
1825
+ const PaymentDetailPage = () => {
1826
+ var _a;
1830
1827
  const navigate = reactRouterDom.useNavigate();
1831
1828
  const params = reactRouterDom.useParams();
1832
1829
  const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
1833
1830
  const [detail, setDetail] = react.useState(null);
1834
1831
  const [loading, setLoading] = react.useState(!!id);
1835
1832
  const [error, setError] = react.useState(null);
1836
- const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
1837
1833
  react.useEffect(() => {
1838
1834
  if (!id) {
1839
1835
  setLoading(false);
@@ -1842,7 +1838,7 @@ const RefundDetailPage = () => {
1842
1838
  let cancelled = false;
1843
1839
  setLoading(true);
1844
1840
  setError(null);
1845
- fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
1841
+ fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
1846
1842
  if (!res.ok) throw new Error(res.statusText || "Failed to load");
1847
1843
  return res.json();
1848
1844
  }).then((data) => {
@@ -1856,40 +1852,163 @@ const RefundDetailPage = () => {
1856
1852
  cancelled = true;
1857
1853
  };
1858
1854
  }, [id]);
1859
- const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
1860
- const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
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)}` : "";
1861
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: [
1862
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: [
1863
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
1864
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
1865
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
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 ?? "—" })
1866
1864
  ] }) }),
1867
1865
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1868
1866
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1869
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
1867
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
1870
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: [
1871
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
1872
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
1873
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1874
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1875
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
1876
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
1877
- ] }),
1878
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1879
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
1880
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
1881
- ] }),
1882
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1883
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
1884
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
1885
- ] }),
1886
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1887
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
1888
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
1889
- year: "numeric",
1890
- month: "short",
1891
- day: "numeric",
1892
- hour: "numeric",
1869
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1870
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1871
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
1872
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
1873
+ ui.Button,
1874
+ {
1875
+ variant: "transparent",
1876
+ size: "small",
1877
+ onClick: () => navigate(`/orders/${detail.order_id}`),
1878
+ children: detail.order_id
1879
+ }
1880
+ ) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
1881
+ ] }),
1882
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1883
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
1884
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
1885
+ ] }),
1886
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1887
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
1888
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
1889
+ ] }),
1890
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1891
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
1892
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
1893
+ ui.Badge,
1894
+ {
1895
+ size: "2xsmall",
1896
+ className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
1897
+ children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
1898
+ }
1899
+ ) })
1900
+ ] }),
1901
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1902
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
1903
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
1904
+ ] }),
1905
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1906
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
1907
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
1908
+ ] }),
1909
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1910
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
1911
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
1912
+ ] }),
1913
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1914
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
1915
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
1916
+ year: "numeric",
1917
+ month: "short",
1918
+ day: "numeric",
1919
+ hour: "numeric",
1920
+ minute: "2-digit",
1921
+ hour12: true
1922
+ }) })
1923
+ ] })
1924
+ ] }) }),
1925
+ Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
1926
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
1927
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
1928
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
1929
+ ] }) : null
1930
+ ] }) });
1931
+ };
1932
+ const config$3 = adminSdk.defineRouteConfig({
1933
+ label: "Payment details",
1934
+ icon: icons.CreditCard
1935
+ });
1936
+ const getStatusBadgeClass$2 = (status) => {
1937
+ const s2 = status.toLowerCase();
1938
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1939
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1940
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1941
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1942
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1943
+ };
1944
+ const formatAmount = (value) => {
1945
+ return String(value);
1946
+ };
1947
+ const RefundDetailPage = () => {
1948
+ var _a, _b, _c;
1949
+ const navigate = reactRouterDom.useNavigate();
1950
+ const params = reactRouterDom.useParams();
1951
+ const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
1952
+ const [detail, setDetail] = react.useState(null);
1953
+ const [loading, setLoading] = react.useState(!!id);
1954
+ const [error, setError] = react.useState(null);
1955
+ const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
1956
+ react.useEffect(() => {
1957
+ if (!id) {
1958
+ setLoading(false);
1959
+ return;
1960
+ }
1961
+ let cancelled = false;
1962
+ setLoading(true);
1963
+ setError(null);
1964
+ fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
1965
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
1966
+ return res.json();
1967
+ }).then((data) => {
1968
+ if (!cancelled) setDetail(data);
1969
+ }).catch((e) => {
1970
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
1971
+ }).finally(() => {
1972
+ if (!cancelled) setLoading(false);
1973
+ });
1974
+ return () => {
1975
+ cancelled = true;
1976
+ };
1977
+ }, [id]);
1978
+ const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
1979
+ const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
1980
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
1981
+ /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1982
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
1983
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
1984
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
1985
+ ] }) }),
1986
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1987
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1988
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
1989
+ ] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
1990
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
1991
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
1992
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1993
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1994
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
1995
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
1996
+ ] }),
1997
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1998
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
1999
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
2000
+ ] }),
2001
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2002
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
2003
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
2004
+ ] }),
2005
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2006
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
2007
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
2008
+ year: "numeric",
2009
+ month: "short",
2010
+ day: "numeric",
2011
+ hour: "numeric",
1893
2012
  minute: "2-digit",
1894
2013
  hour12: true
1895
2014
  }) })
@@ -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.' })
2280
+ ] }),
2281
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
2282
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
2283
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
2284
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2285
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
2286
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
2287
+ ] }),
2288
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
2289
+ ui.Button,
2290
+ {
2291
+ variant: "secondary",
2292
+ onClick: () => {
2293
+ window.open(
2294
+ `/app/orders/${returnOrder.order_id}`,
2295
+ "_blank"
2296
+ );
2297
+ },
2298
+ children: "View order"
2299
+ }
2300
+ ) })
2301
+ ] })
2165
2302
  ] }),
2166
2303
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
2167
2304
  /* @__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" }),
2305
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
2169
2306
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
2170
2307
  /* @__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 })
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 })
2173
2310
  ] }),
2174
2311
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2175
2312
  /* @__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)}` : "—" })
2313
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
2181
2314
  ] }),
2182
- swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
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,182 +2356,52 @@ 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: [
2258
2387
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
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
- /* @__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
- ] }) }),
2262
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
2263
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
2264
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
2265
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
2266
- ] }, item.id || index)) })
2267
- ] }) })
2268
- ] }),
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
- ] })
2282
- ] }) });
2283
- };
2284
- const config$2 = adminSdk.defineRouteConfig({
2285
- label: "Swap Details",
2286
- icon: icons.ArrowPath
2287
- });
2288
- const getStatusBadgeClass$1 = (status) => {
2289
- const s2 = status.toLowerCase();
2290
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2291
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2292
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2293
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2294
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2295
- };
2296
- const PaymentDetailPage = () => {
2297
- var _a;
2298
- const navigate = reactRouterDom.useNavigate();
2299
- const params = reactRouterDom.useParams();
2300
- const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
2301
- const [detail, setDetail] = react.useState(null);
2302
- const [loading, setLoading] = react.useState(!!id);
2303
- const [error, setError] = react.useState(null);
2304
- react.useEffect(() => {
2305
- if (!id) {
2306
- setLoading(false);
2307
- return;
2308
- }
2309
- let cancelled = false;
2310
- setLoading(true);
2311
- setError(null);
2312
- fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
2313
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
2314
- return res.json();
2315
- }).then((data) => {
2316
- if (!cancelled) setDetail(data);
2317
- }).catch((e) => {
2318
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
2319
- }).finally(() => {
2320
- if (!cancelled) setLoading(false);
2321
- });
2322
- return () => {
2323
- cancelled = true;
2324
- };
2325
- }, [id]);
2326
- const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
2327
- const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
2328
- const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
2329
- const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
2330
- 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: [
2331
- /* @__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: [
2332
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
2333
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payment session" }),
2334
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
2335
- ] }) }),
2336
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2337
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2338
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
2339
- ] }) : 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: [
2340
- /* @__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: [
2341
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2342
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
2343
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2344
- ui.Button,
2345
- {
2346
- variant: "transparent",
2347
- size: "small",
2348
- onClick: () => navigate(`/orders/${detail.order_id}`),
2349
- children: detail.order_id
2350
- }
2351
- ) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
2352
- ] }),
2353
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2354
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
2355
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
2356
- ] }),
2357
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2358
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
2359
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
2360
- ] }),
2361
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2362
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
2363
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2364
- ui.Badge,
2365
- {
2366
- size: "2xsmall",
2367
- className: `uppercase ${getStatusBadgeClass$1(displayStatus)}`,
2368
- children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
2369
- }
2370
- ) })
2371
- ] }),
2372
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2373
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
2374
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
2375
- ] }),
2376
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2377
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
2378
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
2379
- ] }),
2380
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2381
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
2382
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
2383
- ] }),
2384
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2385
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
2386
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
2387
- year: "numeric",
2388
- month: "short",
2389
- day: "numeric",
2390
- hour: "numeric",
2391
- minute: "2-digit",
2392
- hour12: true
2393
- }) })
2394
- ] })
2395
- ] }) }),
2396
- Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2397
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
2398
- /* @__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) })
2399
- ] }) : /* @__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." }) })
2400
- ] }) : null
2389
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
2390
+ ] }) }),
2391
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
2392
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
2393
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
2394
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
2395
+ ] }, item.id || index)) })
2396
+ ] }) })
2397
+ ] }),
2398
+ updateError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: updateError }) }),
2399
+ updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
2401
2400
  ] }) });
2402
2401
  };
2403
2402
  const config$1 = adminSdk.defineRouteConfig({
2404
- label: "Payment details",
2405
- icon: icons.CreditCard
2403
+ label: "Return Order Details",
2404
+ icon: icons.CheckCircle
2406
2405
  });
2407
2406
  const getStatusBadgeClass = (status) => {
2408
2407
  const statusLower = status.toLowerCase();
@@ -2415,105 +2414,109 @@ const getStatusBadgeClass = (status) => {
2415
2414
  if (statusLower === "rejected") {
2416
2415
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
2417
2416
  }
2418
- if (statusLower === "received") {
2419
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2420
- }
2421
- if (statusLower === "refunded") {
2422
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
2423
- }
2424
2417
  if (statusLower === "completed") {
2425
2418
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
2426
2419
  }
2427
- if (statusLower === "cancelled") {
2420
+ if (statusLower === "cancelled" || statusLower === "canceled") {
2428
2421
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
2429
2422
  }
2423
+ if (statusLower === "pending") {
2424
+ return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2425
+ }
2430
2426
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2431
2427
  };
2432
- const ReturnDetailPage = () => {
2433
- var _a, _b;
2428
+ const SwapDetailPage = () => {
2429
+ var _a, _b, _c;
2434
2430
  const navigate = reactRouterDom.useNavigate();
2435
2431
  const { id } = reactRouterDom.useParams();
2436
- const [returnOrder, setReturnOrder] = react.useState(null);
2432
+ const [swap, setSwap] = react.useState(null);
2433
+ const [order, setOrder] = react.useState(null);
2437
2434
  const [isLoading, setIsLoading] = react.useState(true);
2438
- const [isRejecting, setIsRejecting] = react.useState(false);
2435
+ react.useState(false);
2436
+ const [isCancelling, setIsCancelling] = react.useState(false);
2439
2437
  const [error, setError] = react.useState(null);
2440
2438
  const [updateError, setUpdateError] = react.useState(null);
2441
2439
  const [updateSuccess, setUpdateSuccess] = react.useState(false);
2442
2440
  react.useEffect(() => {
2443
2441
  if (!id) {
2444
- navigate("/returns");
2442
+ navigate("/swaps");
2445
2443
  return;
2446
2444
  }
2447
- const loadReturn = async () => {
2445
+ const loadSwap = async () => {
2448
2446
  try {
2449
2447
  setIsLoading(true);
2450
2448
  setError(null);
2451
- const response = await fetch(`/admin/returns/${id}`, {
2449
+ const response = await fetch(`/admin/swaps/${id}`, {
2452
2450
  credentials: "include"
2453
2451
  });
2454
2452
  if (!response.ok) {
2455
2453
  const message = await response.text();
2456
- throw new Error(message || "Unable to load return order");
2454
+ throw new Error(message || "Unable to load swap");
2457
2455
  }
2458
2456
  const payload = await response.json();
2459
- setReturnOrder(payload.return);
2457
+ setSwap(payload.swap);
2458
+ setOrder(payload.order || null);
2460
2459
  } catch (loadError) {
2461
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
2460
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
2462
2461
  setError(message);
2463
2462
  } finally {
2464
2463
  setIsLoading(false);
2465
2464
  }
2466
2465
  };
2467
- void loadReturn();
2466
+ void loadSwap();
2468
2467
  }, [id, navigate]);
2469
- const handleReject = async () => {
2468
+ const handleCancelExchange = async () => {
2470
2469
  if (!id) {
2471
2470
  return;
2472
2471
  }
2473
2472
  try {
2474
- setIsRejecting(true);
2473
+ setIsCancelling(true);
2475
2474
  setUpdateError(null);
2476
2475
  setUpdateSuccess(false);
2477
- const response = await fetch(`/admin/returns/${id}/reject`, {
2476
+ const response = await fetch(`/admin/swaps/${id}/cancel`, {
2478
2477
  method: "POST",
2479
2478
  headers: {
2480
2479
  "Content-Type": "application/json"
2481
2480
  },
2482
- credentials: "include",
2483
- body: JSON.stringify({ reason: "Rejected by admin" })
2481
+ credentials: "include"
2484
2482
  });
2485
2483
  if (!response.ok) {
2486
2484
  const message = await response.text();
2487
- throw new Error(message || "Unable to reject return");
2485
+ throw new Error(message || "Unable to cancel exchange");
2488
2486
  }
2489
2487
  const payload = await response.json();
2490
- setReturnOrder(payload.return);
2488
+ setSwap(payload.swap);
2491
2489
  setUpdateSuccess(true);
2492
2490
  setTimeout(() => setUpdateSuccess(false), 3e3);
2493
- const detailResponse = await fetch(`/admin/returns/${id}`, {
2491
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
2494
2492
  credentials: "include"
2495
2493
  });
2496
2494
  if (detailResponse.ok) {
2497
2495
  const detailPayload = await detailResponse.json();
2498
- setReturnOrder(detailPayload.return);
2496
+ setSwap(detailPayload.swap);
2497
+ setOrder(detailPayload.order || null);
2499
2498
  }
2500
- } catch (updateErr) {
2501
- 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";
2502
2501
  setUpdateError(message);
2503
2502
  } finally {
2504
- setIsRejecting(false);
2503
+ setIsCancelling(false);
2505
2504
  }
2506
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
+ );
2507
2510
  if (isLoading) {
2508
- 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..." }) }) }) });
2509
2512
  }
2510
- if (error || !returnOrder) {
2513
+ if (error || !swap) {
2511
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: [
2512
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
2513
- /* @__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" }) })
2514
2517
  ] }) }) });
2515
2518
  }
2516
- const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
2519
+ const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
2517
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: [
2518
2521
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
2519
2522
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2521,7 +2524,7 @@ const ReturnDetailPage = () => {
2521
2524
  {
2522
2525
  variant: "transparent",
2523
2526
  size: "small",
2524
- onClick: () => navigate("/returns"),
2527
+ onClick: () => navigate("/swaps"),
2525
2528
  className: "w-fit",
2526
2529
  children: [
2527
2530
  /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
@@ -2531,81 +2534,67 @@ const ReturnDetailPage = () => {
2531
2534
  ),
2532
2535
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
2533
2536
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
2534
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
2535
- /* @__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 })
2536
2539
  ] }),
2537
2540
  /* @__PURE__ */ jsxRuntime.jsx(
2538
2541
  ui.Badge,
2539
2542
  {
2540
2543
  size: "small",
2541
- className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
2542
- children: returnOrder.status.replace(/_/g, " ")
2544
+ className: `uppercase ${getStatusBadgeClass(swap.status)}`,
2545
+ children: swap.status.replace(/_/g, " ")
2543
2546
  }
2544
2547
  )
2545
2548
  ] })
2546
2549
  ] }),
2547
- 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: [
2548
2551
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
2549
2552
  ui.Button,
2550
2553
  {
2551
2554
  variant: "danger",
2552
- onClick: handleReject,
2553
- disabled: isRejecting,
2554
- isLoading: isRejecting,
2555
- children: "Reject (Cancel) Return"
2555
+ onClick: handleCancelExchange,
2556
+ disabled: isCancelling,
2557
+ isLoading: isCancelling,
2558
+ children: "Cancel Exchange"
2556
2559
  }
2557
2560
  ) }),
2558
- /* @__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.' })
2559
- ] }),
2560
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
2561
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
2562
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
2563
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2564
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
2565
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
2566
- ] }),
2567
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
2568
- ui.Button,
2569
- {
2570
- variant: "secondary",
2571
- onClick: () => {
2572
- window.open(
2573
- `/app/orders/${returnOrder.order_id}`,
2574
- "_blank"
2575
- );
2576
- },
2577
- children: "View order"
2578
- }
2579
- ) })
2580
- ] })
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." })
2581
2562
  ] }),
2582
2563
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
2583
2564
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
2584
- /* @__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" }),
2585
2566
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
2586
2567
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2587
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
2588
- /* @__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 })
2589
2570
  ] }),
2590
2571
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2591
2572
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
2592
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
2573
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
2593
2574
  ] }),
2594
- 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: [
2595
2580
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
2596
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
2581
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
2597
2582
  ] }),
2598
- returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2583
+ swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2599
2584
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
2600
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
2585
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
2601
2586
  ] }),
2602
2587
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2603
2588
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
2604
- /* @__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() })
2605
2590
  ] }),
2606
2591
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2607
2592
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
2608
- /* @__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 })
2609
2598
  ] })
2610
2599
  ] })
2611
2600
  ] }),
@@ -2635,31 +2624,31 @@ const ReturnDetailPage = () => {
2635
2624
  )) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
2636
2625
  ] })
2637
2626
  ] }),
2638
- 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: [
2639
2628
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
2640
2629
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
2641
2630
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2642
2631
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
2643
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
2632
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
2644
2633
  ] }),
2645
2634
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2646
2635
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
2647
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
2636
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
2648
2637
  ] }),
2649
2638
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2650
2639
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
2651
- /* @__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 || "—" })
2652
2641
  ] }),
2653
- returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2642
+ order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2654
2643
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
2655
2644
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
2656
- returnOrder.order.currency_code || "$",
2657
- (Number(returnOrder.order.total) / 100).toFixed(2)
2645
+ order.currency_code || "$",
2646
+ (Number(order.total) / 100).toFixed(2)
2658
2647
  ] })
2659
2648
  ] })
2660
2649
  ] })
2661
2650
  ] }),
2662
- 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: [
2663
2652
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
2664
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: [
2665
2654
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
@@ -2667,20 +2656,31 @@ const ReturnDetailPage = () => {
2667
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" }),
2668
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" })
2669
2658
  ] }) }),
2670
- /* @__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: [
2671
2660
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
2672
2661
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
2673
2662
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
2674
2663
  ] }, item.id || index)) })
2675
2664
  ] }) })
2676
2665
  ] }),
2677
- 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 }) }),
2678
- 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" }) })
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: "Return Order Details",
2683
- icon: icons.CheckCircle
2682
+ label: "Swap Details",
2683
+ icon: icons.ArrowPath
2684
2684
  });
2685
2685
  const i18nTranslations0 = {};
2686
2686
  const widgetModule = { widgets: [
@@ -2695,6 +2695,10 @@ const widgetModule = { widgets: [
2695
2695
  ] };
2696
2696
  const routeModule = {
2697
2697
  routes: [
2698
+ {
2699
+ Component: PaymentsPage,
2700
+ path: "/payments"
2701
+ },
2698
2702
  {
2699
2703
  Component: RefundsPage,
2700
2704
  path: "/refunds"
@@ -2703,50 +2707,46 @@ const routeModule = {
2703
2707
  Component: ReturnsPage,
2704
2708
  path: "/returns"
2705
2709
  },
2706
- {
2707
- Component: PaymentsPage,
2708
- path: "/payments"
2709
- },
2710
2710
  {
2711
2711
  Component: SwapsPage,
2712
2712
  path: "/swaps"
2713
2713
  },
2714
- {
2715
- Component: RefundDetailPage,
2716
- path: "/refunds/:id"
2717
- },
2718
- {
2719
- Component: SwapDetailPage,
2720
- path: "/swaps/:id"
2721
- },
2722
2714
  {
2723
2715
  Component: PaymentDetailPage,
2724
2716
  path: "/payments/:id"
2725
2717
  },
2718
+ {
2719
+ Component: RefundDetailPage,
2720
+ path: "/refunds/:id"
2721
+ },
2726
2722
  {
2727
2723
  Component: ReturnDetailPage,
2728
2724
  path: "/returns/:id"
2725
+ },
2726
+ {
2727
+ Component: SwapDetailPage,
2728
+ path: "/swaps/:id"
2729
2729
  }
2730
2730
  ]
2731
2731
  };
2732
2732
  const menuItemModule = {
2733
2733
  menuItems: [
2734
2734
  {
2735
- label: config$5.label,
2736
- icon: config$5.icon,
2735
+ label: config$7.label,
2736
+ icon: config$7.icon,
2737
2737
  path: "/payments",
2738
2738
  nested: void 0
2739
2739
  },
2740
2740
  {
2741
2741
  label: config$6.label,
2742
2742
  icon: config$6.icon,
2743
- path: "/returns",
2743
+ path: "/refunds",
2744
2744
  nested: void 0
2745
2745
  },
2746
2746
  {
2747
- label: config$7.label,
2748
- icon: config$7.icon,
2749
- path: "/refunds",
2747
+ label: config$5.label,
2748
+ icon: config$5.icon,
2749
+ path: "/returns",
2750
2750
  nested: void 0
2751
2751
  },
2752
2752
  {
@@ -2756,27 +2756,27 @@ const menuItemModule = {
2756
2756
  nested: void 0
2757
2757
  },
2758
2758
  {
2759
- label: config.label,
2760
- icon: config.icon,
2761
- path: "/returns/:id",
2762
- nested: void 0
2763
- },
2764
- {
2765
- label: config$1.label,
2766
- icon: config$1.icon,
2759
+ label: config$3.label,
2760
+ icon: config$3.icon,
2767
2761
  path: "/payments/:id",
2768
2762
  nested: void 0
2769
2763
  },
2770
2764
  {
2771
2765
  label: config$2.label,
2772
2766
  icon: config$2.icon,
2773
- path: "/swaps/:id",
2767
+ path: "/refunds/:id",
2774
2768
  nested: void 0
2775
2769
  },
2776
2770
  {
2777
- label: config$3.label,
2778
- icon: config$3.icon,
2779
- path: "/refunds/:id",
2771
+ label: config$1.label,
2772
+ icon: config$1.icon,
2773
+ path: "/returns/:id",
2774
+ nested: void 0
2775
+ },
2776
+ {
2777
+ label: config.label,
2778
+ icon: config.icon,
2779
+ path: "/swaps/:id",
2780
2780
  nested: void 0
2781
2781
  }
2782
2782
  ]