order-management 0.0.61 → 0.0.63

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.
@@ -470,13 +470,28 @@ const OrderGiftItemsWidget = ({ data }) => {
470
470
  adminSdk.defineWidgetConfig({
471
471
  zone: "order.details.side.after"
472
472
  });
473
+ const FIELD_LABELS = {
474
+ // UPI
475
+ upi_id: "UPI ID",
476
+ // Bank
477
+ account_holder_name: "Account Holder",
478
+ bank_name: "Bank Name",
479
+ account_number: "Account Number",
480
+ ifsc: "IFSC Code",
481
+ branch_name: "Branch Name",
482
+ // Card
483
+ card_holder_name: "Card Holder",
484
+ card_number: "Card Number",
485
+ expiry_date: "Expiry Date",
486
+ cvv: "CVV"
487
+ };
473
488
  function getOrderIdFromPath() {
474
489
  if (typeof window === "undefined") return void 0;
475
490
  const m = window.location.pathname.match(/\/orders\/([^/]+)/);
476
491
  return m ? m[1] : void 0;
477
492
  }
478
493
  const OrderRefundContextWidget = (props) => {
479
- var _a, _b, _c, _d, _e, _f;
494
+ var _a, _b, _c, _d, _e;
480
495
  const orderId = ((_a = props.order) == null ? void 0 : _a.id) ?? ((_c = (_b = props.data) == null ? void 0 : _b.order) == null ? void 0 : _c.id) ?? getOrderIdFromPath();
481
496
  const [context, setContext] = react.useState(null);
482
497
  const [loading, setLoading] = react.useState(!!orderId);
@@ -643,19 +658,22 @@ const OrderRefundContextWidget = (props) => {
643
658
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: context.return_id }),
644
659
  ((_d = context.refund_mapping) == null ? void 0 : _d.is_refunded) ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Refunded" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Not refunded" })
645
660
  ] }),
646
- paymentDetail && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-1 border-t border-ui-border-base pt-3", children: [
647
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Payment method (refund destination)" }),
661
+ paymentDetail && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2 border-t border-ui-border-base pt-3", children: [
662
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
663
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Payment method (refund destination)" }),
664
+ paymentDetail.source === "specified" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "green", children: "Customer specified" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "orange", children: "Customer default" })
665
+ ] }),
666
+ paymentDetail.source === "default" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "The customer did not specify a payment method for this return. Showing their default payment method." }) }),
648
667
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
649
- /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: paymentDetail.type }),
668
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { children: paymentDetail.type.toUpperCase() }),
650
669
  paymentDetail.is_default && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "blue", children: "Default" })
651
670
  ] }),
652
- Object.keys(paymentDetail.detail_json).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1 text-ui-fg-subtle", children: Object.entries(paymentDetail.detail_json).map(([k, v]) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs", children: [
653
- k,
654
- ": ",
655
- String(v)
671
+ Object.keys(paymentDetail.detail_json).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 grid grid-cols-2 gap-x-6 gap-y-2", children: Object.entries(paymentDetail.detail_json).map(([k, v]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
672
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: FIELD_LABELS[k] ?? k }),
673
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "block", children: String(v) })
656
674
  ] }, k)) })
657
675
  ] }),
658
- !paymentDetail && ((_e = context.refund_mapping) == null ? void 0 : _e.payment_id) && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-muted", children: "Payment detail not found or not accessible." }),
676
+ !paymentDetail && context.return_id && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 rounded-md border border-ui-border-base bg-ui-bg-subtle px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "No payment method found for this customer." }) }),
659
677
  (context == null ? void 0 : context.refund_mapping) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-3 border-t border-ui-border-base pt-3", children: [
660
678
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
661
679
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", className: "text-ui-fg-subtle", children: "Refund mode, details & images" }),
@@ -798,7 +816,7 @@ const OrderRefundContextWidget = (props) => {
798
816
  ] }),
799
817
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
800
818
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", weight: "plus", className: "text-ui-fg-muted", children: "Images" }),
801
- ((_f = context.refund_mapping.images) == null ? void 0 : _f.length) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-wrap gap-2", children: context.refund_mapping.images.map((url, i) => /* @__PURE__ */ jsxRuntime.jsxs(
819
+ ((_e = context.refund_mapping.images) == null ? void 0 : _e.length) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-wrap gap-2", children: context.refund_mapping.images.map((url, i) => /* @__PURE__ */ jsxRuntime.jsxs(
802
820
  "a",
803
821
  {
804
822
  href: url,
@@ -1044,238 +1062,6 @@ const useDebounce$2 = (value, delay) => {
1044
1062
  return debouncedValue;
1045
1063
  };
1046
1064
  const getStatusBadgeClass$6 = (status) => {
1047
- const statusLower = status.toLowerCase();
1048
- if (statusLower === "requested") {
1049
- return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1050
- }
1051
- if (statusLower === "received") {
1052
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1053
- }
1054
- if (statusLower === "requires_action") {
1055
- return "bg-ui-tag-red-bg text-ui-tag-red-text";
1056
- }
1057
- if (statusLower === "completed") {
1058
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
1059
- }
1060
- if (statusLower === "canceled") {
1061
- return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
1062
- }
1063
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1064
- };
1065
- const ReturnsPage = () => {
1066
- const navigate = reactRouterDom.useNavigate();
1067
- const [items, setItems] = react.useState([]);
1068
- const [statusFilter, setStatusFilter] = react.useState("all");
1069
- const [createdByFilter, setCreatedByFilter] = react.useState("all");
1070
- const [searchQuery, setSearchQuery] = react.useState("");
1071
- const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
1072
- const [isLoading, setIsLoading] = react.useState(true);
1073
- const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1074
- const [error, setError] = react.useState(null);
1075
- const [offset, setOffset] = react.useState(0);
1076
- const [count, setCount] = react.useState(0);
1077
- const limit = 50;
1078
- const loadReturns = react.useCallback(
1079
- async (nextOffset, replace = false) => {
1080
- var _a;
1081
- try {
1082
- if (replace) {
1083
- setIsLoading(true);
1084
- } else {
1085
- setIsFetchingMore(true);
1086
- }
1087
- setError(null);
1088
- const params = new URLSearchParams();
1089
- params.set("limit", String(limit));
1090
- params.set("offset", String(nextOffset));
1091
- if (statusFilter !== "all") {
1092
- params.set("status", statusFilter);
1093
- }
1094
- if (debouncedSearchQuery.trim()) {
1095
- params.set("q", debouncedSearchQuery.trim());
1096
- }
1097
- if (createdByFilter !== "all") {
1098
- params.set("created_by", createdByFilter);
1099
- }
1100
- params.set("order", "created_at");
1101
- const response = await fetch(
1102
- `/admin/return?${params.toString()}`,
1103
- { credentials: "include" }
1104
- );
1105
- if (!response.ok) {
1106
- const message = await response.text();
1107
- throw new Error(message || "Unable to load return orders");
1108
- }
1109
- const payload = await response.json();
1110
- setCount(payload.count ?? 0);
1111
- setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
1112
- setItems(
1113
- (prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
1114
- );
1115
- } catch (loadError) {
1116
- const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
1117
- setError(message);
1118
- } finally {
1119
- setIsLoading(false);
1120
- setIsFetchingMore(false);
1121
- }
1122
- },
1123
- [statusFilter, createdByFilter, debouncedSearchQuery]
1124
- );
1125
- react.useEffect(() => {
1126
- void loadReturns(0, true);
1127
- }, [statusFilter, createdByFilter, debouncedSearchQuery, loadReturns]);
1128
- const hasMore = react.useMemo(() => offset < count, [offset, count]);
1129
- const availableStatuses = react.useMemo(() => {
1130
- const statuses = /* @__PURE__ */ new Set();
1131
- items.forEach((item) => statuses.add(item.status));
1132
- return Array.from(statuses).sort();
1133
- }, [items]);
1134
- 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: [
1135
- /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1136
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1137
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
1138
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
1139
- ] }),
1140
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
1141
- ] }),
1142
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1143
- /* @__PURE__ */ jsxRuntime.jsx(
1144
- ui.Input,
1145
- {
1146
- placeholder: "Search by return ID, order ID, or customer email",
1147
- value: searchQuery,
1148
- onChange: (event) => setSearchQuery(event.target.value),
1149
- className: "md:max-w-sm"
1150
- }
1151
- ),
1152
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
1153
- /* @__PURE__ */ jsxRuntime.jsxs(
1154
- "select",
1155
- {
1156
- value: createdByFilter,
1157
- onChange: (event) => setCreatedByFilter(event.target.value),
1158
- 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",
1159
- children: [
1160
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
1161
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
1162
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
1163
- ]
1164
- }
1165
- ),
1166
- /* @__PURE__ */ jsxRuntime.jsxs(
1167
- "select",
1168
- {
1169
- value: statusFilter,
1170
- onChange: (event) => setStatusFilter(event.target.value),
1171
- 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",
1172
- children: [
1173
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
1174
- availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
1175
- ]
1176
- }
1177
- )
1178
- ] })
1179
- ] }),
1180
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1181
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1182
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1183
- ui.Button,
1184
- {
1185
- variant: "secondary",
1186
- onClick: () => loadReturns(0, true),
1187
- children: "Try again"
1188
- }
1189
- ) })
1190
- ] }) : null,
1191
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1192
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
1193
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
1194
- ] }) : /* @__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: [
1195
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1196
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
1197
- /* @__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" }),
1198
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
1199
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1200
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
1201
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1202
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1203
- ] }) }),
1204
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
1205
- "tr",
1206
- {
1207
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1208
- onClick: () => navigate(`/returns/${returnOrder.id}`),
1209
- children: [
1210
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
1211
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
1212
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
1213
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1214
- ui.Badge,
1215
- {
1216
- size: "2xsmall",
1217
- className: `uppercase ${getStatusBadgeClass$6(returnOrder.status)}`,
1218
- children: returnOrder.status.replace(/_/g, " ")
1219
- }
1220
- ) }),
1221
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
1222
- const amount = returnOrder.refund_amount;
1223
- if (amount == null || amount === void 0) {
1224
- return "—";
1225
- }
1226
- const displayAmount = Number(amount) / 100;
1227
- const currency = returnOrder.currency_code || "$";
1228
- return `${currency}${displayAmount.toFixed(2)}`;
1229
- })() }),
1230
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
1231
- year: "numeric",
1232
- month: "short",
1233
- day: "numeric",
1234
- hour: "numeric",
1235
- minute: "2-digit",
1236
- hour12: true
1237
- }) }),
1238
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1239
- ui.Button,
1240
- {
1241
- variant: "transparent",
1242
- size: "small",
1243
- onClick: (e) => {
1244
- e.stopPropagation();
1245
- navigate(`/app/orders/${returnOrder.order_id}`);
1246
- },
1247
- children: "Go to order"
1248
- }
1249
- ) })
1250
- ]
1251
- },
1252
- returnOrder.id
1253
- )) })
1254
- ] }) }),
1255
- hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1256
- ui.Button,
1257
- {
1258
- variant: "secondary",
1259
- isLoading: isFetchingMore,
1260
- onClick: () => loadReturns(offset, false),
1261
- children: "Load more"
1262
- }
1263
- ) }) : null
1264
- ] }) });
1265
- };
1266
- const config$6 = adminSdk.defineRouteConfig({
1267
- label: "Return Orders",
1268
- icon: icons.ArrowPath
1269
- });
1270
- const useDebounce$1 = (value, delay) => {
1271
- const [debouncedValue, setDebouncedValue] = react.useState(value);
1272
- react.useEffect(() => {
1273
- const handler = setTimeout(() => setDebouncedValue(value), delay);
1274
- return () => clearTimeout(handler);
1275
- }, [value, delay]);
1276
- return debouncedValue;
1277
- };
1278
- const getStatusBadgeClass$5 = (status) => {
1279
1065
  const s2 = status.toLowerCase();
1280
1066
  if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1281
1067
  if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
@@ -1287,12 +1073,12 @@ const RefundsPage = () => {
1287
1073
  const navigate = reactRouterDom.useNavigate();
1288
1074
  const [items, setItems] = react.useState([]);
1289
1075
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
1290
- const debouncedOrderId = useDebounce$1(orderIdSearch, 300);
1076
+ const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
1291
1077
  const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
1292
1078
  const [providerSearch, setProviderSearch] = react.useState("");
1293
- const debouncedProvider = useDebounce$1(providerSearch, 300);
1079
+ const debouncedProvider = useDebounce$2(providerSearch, 300);
1294
1080
  const [currencySearch, setCurrencySearch] = react.useState("");
1295
- const debouncedCurrency = useDebounce$1(currencySearch, 300);
1081
+ const debouncedCurrency = useDebounce$2(currencySearch, 300);
1296
1082
  const [dateFrom, setDateFrom] = react.useState("");
1297
1083
  const [dateTo, setDateTo] = react.useState("");
1298
1084
  const [amountMin, setAmountMin] = react.useState("");
@@ -1504,7 +1290,7 @@ const RefundsPage = () => {
1504
1290
  ui.Badge,
1505
1291
  {
1506
1292
  size: "2xsmall",
1507
- className: `uppercase ${getStatusBadgeClass$5(displayStatus(r))}`,
1293
+ className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
1508
1294
  children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
1509
1295
  }
1510
1296
  ) }),
@@ -1558,11 +1344,11 @@ const RefundsPage = () => {
1558
1344
  ) }) : null
1559
1345
  ] }) });
1560
1346
  };
1561
- const config$5 = adminSdk.defineRouteConfig({
1347
+ const config$6 = adminSdk.defineRouteConfig({
1562
1348
  label: "Refunds",
1563
1349
  icon: icons.Receipt
1564
1350
  });
1565
- const useDebounce = (value, delay) => {
1351
+ const useDebounce$1 = (value, delay) => {
1566
1352
  const [debouncedValue, setDebouncedValue] = react.useState(value);
1567
1353
  react.useEffect(() => {
1568
1354
  const handler = setTimeout(() => setDebouncedValue(value), delay);
@@ -1570,39 +1356,39 @@ const useDebounce = (value, delay) => {
1570
1356
  }, [value, delay]);
1571
1357
  return debouncedValue;
1572
1358
  };
1573
- const getStatusBadgeClass$4 = (status) => {
1359
+ const getStatusBadgeClass$5 = (status) => {
1574
1360
  const statusLower = status.toLowerCase();
1575
1361
  if (statusLower === "requested") {
1576
1362
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1577
1363
  }
1578
- if (statusLower === "approved") {
1364
+ if (statusLower === "received") {
1579
1365
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1580
1366
  }
1581
- if (statusLower === "rejected") {
1367
+ if (statusLower === "requires_action") {
1582
1368
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
1583
1369
  }
1584
1370
  if (statusLower === "completed") {
1585
1371
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
1586
1372
  }
1587
- if (statusLower === "cancelled") {
1373
+ if (statusLower === "canceled") {
1588
1374
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
1589
1375
  }
1590
1376
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1591
1377
  };
1592
- const SwapsPage = () => {
1378
+ const ReturnsPage = () => {
1593
1379
  const navigate = reactRouterDom.useNavigate();
1594
1380
  const [items, setItems] = react.useState([]);
1595
1381
  const [statusFilter, setStatusFilter] = react.useState("all");
1596
1382
  const [createdByFilter, setCreatedByFilter] = react.useState("all");
1597
1383
  const [searchQuery, setSearchQuery] = react.useState("");
1598
- const debouncedSearchQuery = useDebounce(searchQuery, 300);
1384
+ const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
1599
1385
  const [isLoading, setIsLoading] = react.useState(true);
1600
1386
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1601
1387
  const [error, setError] = react.useState(null);
1602
1388
  const [offset, setOffset] = react.useState(0);
1603
1389
  const [count, setCount] = react.useState(0);
1604
1390
  const limit = 50;
1605
- const loadSwaps = react.useCallback(
1391
+ const loadReturns = react.useCallback(
1606
1392
  async (nextOffset, replace = false) => {
1607
1393
  var _a;
1608
1394
  try {
@@ -1619,18 +1405,250 @@ const SwapsPage = () => {
1619
1405
  params.set("status", statusFilter);
1620
1406
  }
1621
1407
  if (debouncedSearchQuery.trim()) {
1622
- params.set("order_id", debouncedSearchQuery.trim());
1408
+ params.set("q", debouncedSearchQuery.trim());
1623
1409
  }
1624
1410
  if (createdByFilter !== "all") {
1625
1411
  params.set("created_by", createdByFilter);
1626
1412
  }
1413
+ params.set("order", "created_at");
1627
1414
  const response = await fetch(
1628
- `/admin/swaps?${params.toString()}`,
1415
+ `/admin/return?${params.toString()}`,
1629
1416
  { credentials: "include" }
1630
1417
  );
1631
1418
  if (!response.ok) {
1632
1419
  const message = await response.text();
1633
- throw new Error(message || "Unable to load swaps");
1420
+ throw new Error(message || "Unable to load return orders");
1421
+ }
1422
+ const payload = await response.json();
1423
+ setCount(payload.count ?? 0);
1424
+ setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
1425
+ setItems(
1426
+ (prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
1427
+ );
1428
+ } catch (loadError) {
1429
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
1430
+ setError(message);
1431
+ } finally {
1432
+ setIsLoading(false);
1433
+ setIsFetchingMore(false);
1434
+ }
1435
+ },
1436
+ [statusFilter, createdByFilter, debouncedSearchQuery]
1437
+ );
1438
+ react.useEffect(() => {
1439
+ void loadReturns(0, true);
1440
+ }, [statusFilter, createdByFilter, debouncedSearchQuery, loadReturns]);
1441
+ const hasMore = react.useMemo(() => offset < count, [offset, count]);
1442
+ const availableStatuses = react.useMemo(() => {
1443
+ const statuses = /* @__PURE__ */ new Set();
1444
+ items.forEach((item) => statuses.add(item.status));
1445
+ return Array.from(statuses).sort();
1446
+ }, [items]);
1447
+ 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: [
1448
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1449
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1450
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
1451
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
1452
+ ] }),
1453
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
1454
+ ] }),
1455
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
1456
+ /* @__PURE__ */ jsxRuntime.jsx(
1457
+ ui.Input,
1458
+ {
1459
+ placeholder: "Search by return ID, order ID, or customer email",
1460
+ value: searchQuery,
1461
+ onChange: (event) => setSearchQuery(event.target.value),
1462
+ className: "md:max-w-sm"
1463
+ }
1464
+ ),
1465
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
1466
+ /* @__PURE__ */ jsxRuntime.jsxs(
1467
+ "select",
1468
+ {
1469
+ value: createdByFilter,
1470
+ onChange: (event) => setCreatedByFilter(event.target.value),
1471
+ 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",
1472
+ children: [
1473
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
1474
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
1475
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
1476
+ ]
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ jsxRuntime.jsxs(
1480
+ "select",
1481
+ {
1482
+ value: statusFilter,
1483
+ onChange: (event) => setStatusFilter(event.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
+ children: [
1486
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
1487
+ availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
1488
+ ]
1489
+ }
1490
+ )
1491
+ ] })
1492
+ ] }),
1493
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1494
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1495
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1496
+ ui.Button,
1497
+ {
1498
+ variant: "secondary",
1499
+ onClick: () => loadReturns(0, true),
1500
+ children: "Try again"
1501
+ }
1502
+ ) })
1503
+ ] }) : null,
1504
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
1505
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
1506
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
1507
+ ] }) : /* @__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: [
1508
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1509
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
1510
+ /* @__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" }),
1511
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
1512
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
1513
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
1514
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
1515
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
1516
+ ] }) }),
1517
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
1518
+ "tr",
1519
+ {
1520
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
1521
+ onClick: () => navigate(`/returns/${returnOrder.id}`),
1522
+ children: [
1523
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
1524
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
1525
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
1526
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1527
+ ui.Badge,
1528
+ {
1529
+ size: "2xsmall",
1530
+ className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
1531
+ children: returnOrder.status.replace(/_/g, " ")
1532
+ }
1533
+ ) }),
1534
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
1535
+ const amount = returnOrder.refund_amount;
1536
+ if (amount == null || amount === void 0) {
1537
+ return "—";
1538
+ }
1539
+ const displayAmount = Number(amount) / 100;
1540
+ const currency = returnOrder.currency_code || "$";
1541
+ return `${currency}${displayAmount.toFixed(2)}`;
1542
+ })() }),
1543
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
1544
+ year: "numeric",
1545
+ month: "short",
1546
+ day: "numeric",
1547
+ hour: "numeric",
1548
+ minute: "2-digit",
1549
+ hour12: true
1550
+ }) }),
1551
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
1552
+ ui.Button,
1553
+ {
1554
+ variant: "transparent",
1555
+ size: "small",
1556
+ onClick: (e) => {
1557
+ e.stopPropagation();
1558
+ navigate(`/app/orders/${returnOrder.order_id}`);
1559
+ },
1560
+ children: "Go to order"
1561
+ }
1562
+ ) })
1563
+ ]
1564
+ },
1565
+ returnOrder.id
1566
+ )) })
1567
+ ] }) }),
1568
+ hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1569
+ ui.Button,
1570
+ {
1571
+ variant: "secondary",
1572
+ isLoading: isFetchingMore,
1573
+ onClick: () => loadReturns(offset, false),
1574
+ children: "Load more"
1575
+ }
1576
+ ) }) : null
1577
+ ] }) });
1578
+ };
1579
+ const config$5 = adminSdk.defineRouteConfig({
1580
+ label: "Return Orders",
1581
+ icon: icons.ArrowPath
1582
+ });
1583
+ const useDebounce = (value, delay) => {
1584
+ const [debouncedValue, setDebouncedValue] = react.useState(value);
1585
+ react.useEffect(() => {
1586
+ const handler = setTimeout(() => setDebouncedValue(value), delay);
1587
+ return () => clearTimeout(handler);
1588
+ }, [value, delay]);
1589
+ return debouncedValue;
1590
+ };
1591
+ const getStatusBadgeClass$4 = (status) => {
1592
+ const statusLower = status.toLowerCase();
1593
+ if (statusLower === "requested") {
1594
+ return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1595
+ }
1596
+ if (statusLower === "approved") {
1597
+ return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1598
+ }
1599
+ if (statusLower === "rejected") {
1600
+ return "bg-ui-tag-red-bg text-ui-tag-red-text";
1601
+ }
1602
+ if (statusLower === "completed") {
1603
+ return "bg-ui-tag-green-bg text-ui-tag-green-text";
1604
+ }
1605
+ if (statusLower === "cancelled") {
1606
+ return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
1607
+ }
1608
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1609
+ };
1610
+ const SwapsPage = () => {
1611
+ const navigate = reactRouterDom.useNavigate();
1612
+ const [items, setItems] = react.useState([]);
1613
+ const [statusFilter, setStatusFilter] = react.useState("all");
1614
+ const [createdByFilter, setCreatedByFilter] = react.useState("all");
1615
+ const [searchQuery, setSearchQuery] = react.useState("");
1616
+ const debouncedSearchQuery = useDebounce(searchQuery, 300);
1617
+ const [isLoading, setIsLoading] = react.useState(true);
1618
+ const [isFetchingMore, setIsFetchingMore] = react.useState(false);
1619
+ const [error, setError] = react.useState(null);
1620
+ const [offset, setOffset] = react.useState(0);
1621
+ const [count, setCount] = react.useState(0);
1622
+ const limit = 50;
1623
+ const loadSwaps = react.useCallback(
1624
+ async (nextOffset, replace = false) => {
1625
+ var _a;
1626
+ try {
1627
+ if (replace) {
1628
+ setIsLoading(true);
1629
+ } else {
1630
+ setIsFetchingMore(true);
1631
+ }
1632
+ setError(null);
1633
+ const params = new URLSearchParams();
1634
+ params.set("limit", String(limit));
1635
+ params.set("offset", String(nextOffset));
1636
+ if (statusFilter !== "all") {
1637
+ params.set("status", statusFilter);
1638
+ }
1639
+ if (debouncedSearchQuery.trim()) {
1640
+ params.set("order_id", debouncedSearchQuery.trim());
1641
+ }
1642
+ if (createdByFilter !== "all") {
1643
+ params.set("created_by", createdByFilter);
1644
+ }
1645
+ const response = await fetch(
1646
+ `/admin/swaps?${params.toString()}`,
1647
+ { credentials: "include" }
1648
+ );
1649
+ if (!response.ok) {
1650
+ const message = await response.text();
1651
+ throw new Error(message || "Unable to load swaps");
1634
1652
  }
1635
1653
  const payload = await response.json();
1636
1654
  setCount(payload.count ?? 0);
@@ -1907,11 +1925,203 @@ const PaymentDetailPage = () => {
1907
1925
  ] }) : null
1908
1926
  ] }) });
1909
1927
  };
1910
- const config$3 = adminSdk.defineRouteConfig({
1911
- label: "Payment details",
1912
- icon: icons.CreditCard
1928
+ const config$3 = adminSdk.defineRouteConfig({
1929
+ label: "Payment details",
1930
+ icon: icons.CreditCard
1931
+ });
1932
+ const getStatusBadgeClass$2 = (status) => {
1933
+ const s2 = status.toLowerCase();
1934
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
1935
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
1936
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
1937
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
1938
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
1939
+ };
1940
+ const formatAmount = (value) => {
1941
+ return String(value);
1942
+ };
1943
+ const RefundDetailPage = () => {
1944
+ var _a, _b, _c;
1945
+ const navigate = reactRouterDom.useNavigate();
1946
+ const params = reactRouterDom.useParams();
1947
+ const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
1948
+ const [detail, setDetail] = react.useState(null);
1949
+ const [loading, setLoading] = react.useState(!!id);
1950
+ const [error, setError] = react.useState(null);
1951
+ const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
1952
+ react.useEffect(() => {
1953
+ if (!id) {
1954
+ setLoading(false);
1955
+ return;
1956
+ }
1957
+ let cancelled = false;
1958
+ setLoading(true);
1959
+ setError(null);
1960
+ fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
1961
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
1962
+ return res.json();
1963
+ }).then((data) => {
1964
+ if (!cancelled) setDetail(data);
1965
+ }).catch((e) => {
1966
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
1967
+ }).finally(() => {
1968
+ if (!cancelled) setLoading(false);
1969
+ });
1970
+ return () => {
1971
+ cancelled = true;
1972
+ };
1973
+ }, [id]);
1974
+ const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
1975
+ 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;
1976
+ 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: [
1977
+ /* @__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: [
1978
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
1979
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
1980
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
1981
+ ] }) }),
1982
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
1983
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
1984
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
1985
+ ] }) : 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: [
1986
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
1987
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
1988
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1989
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1990
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
1991
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
1992
+ ] }),
1993
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1994
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
1995
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
1996
+ ] }),
1997
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1998
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
1999
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
2000
+ ] }),
2001
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2002
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
2003
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
2004
+ year: "numeric",
2005
+ month: "short",
2006
+ day: "numeric",
2007
+ hour: "numeric",
2008
+ minute: "2-digit",
2009
+ hour12: true
2010
+ }) })
2011
+ ] }),
2012
+ detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2013
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
2014
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
2015
+ ] }) : null
2016
+ ] })
2017
+ ] }),
2018
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2019
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
2020
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2021
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2022
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
2023
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
2024
+ ] }),
2025
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2026
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
2027
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
2028
+ ] }),
2029
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2030
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
2031
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
2032
+ ] }),
2033
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2034
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
2035
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
2036
+ ] }),
2037
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2038
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
2039
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2040
+ ui.Badge,
2041
+ {
2042
+ size: "2xsmall",
2043
+ className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
2044
+ children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
2045
+ }
2046
+ ) })
2047
+ ] }),
2048
+ detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2049
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2050
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
2051
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
2052
+ ] }),
2053
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2054
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
2055
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
2056
+ ] }),
2057
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2058
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
2059
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
2060
+ detail.computed.refund_percentage.toFixed(1),
2061
+ "%"
2062
+ ] })
2063
+ ] })
2064
+ ] }) : null
2065
+ ] })
2066
+ ] }),
2067
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2068
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
2069
+ detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2070
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2071
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
2072
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2073
+ ui.Button,
2074
+ {
2075
+ variant: "transparent",
2076
+ size: "small",
2077
+ onClick: () => navigate(`/orders/${detail.order.order_id}`),
2078
+ children: detail.order.order_number ?? detail.order.order_id
2079
+ }
2080
+ ) })
2081
+ ] }),
2082
+ detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2083
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
2084
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
2085
+ ] }) : null,
2086
+ detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2087
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
2088
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
2089
+ ] }) : null,
2090
+ detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2091
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
2092
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
2093
+ ] }) : null,
2094
+ detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2095
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
2096
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
2097
+ ] }) : null
2098
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
2099
+ ] }),
2100
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2101
+ /* @__PURE__ */ jsxRuntime.jsxs(
2102
+ "button",
2103
+ {
2104
+ type: "button",
2105
+ className: "flex w-full items-center justify-between text-left",
2106
+ onClick: () => setGatewayExpanded((prev) => !prev),
2107
+ "aria-expanded": gatewayExpanded,
2108
+ "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
2109
+ children: [
2110
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
2111
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
2112
+ ]
2113
+ }
2114
+ ),
2115
+ gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
2116
+ ] })
2117
+ ] }) : null
2118
+ ] }) });
2119
+ };
2120
+ const config$2 = adminSdk.defineRouteConfig({
2121
+ label: "Refund details",
2122
+ icon: icons.Receipt
1913
2123
  });
1914
- const getStatusBadgeClass$2 = (status) => {
2124
+ const getStatusBadgeClass$1 = (status) => {
1915
2125
  const statusLower = status.toLowerCase();
1916
2126
  if (statusLower === "requested") {
1917
2127
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -2045,7 +2255,7 @@ const ReturnDetailPage = () => {
2045
2255
  ui.Badge,
2046
2256
  {
2047
2257
  size: "small",
2048
- className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
2258
+ className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
2049
2259
  children: returnOrder.status.replace(/_/g, " ")
2050
2260
  }
2051
2261
  )
@@ -2127,7 +2337,7 @@ const ReturnDetailPage = () => {
2127
2337
  ui.Badge,
2128
2338
  {
2129
2339
  size: "2xsmall",
2130
- className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
2340
+ className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
2131
2341
  children: entry.status.replace(/_/g, " ")
2132
2342
  }
2133
2343
  ) }),
@@ -2185,202 +2395,10 @@ const ReturnDetailPage = () => {
2185
2395
  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" }) })
2186
2396
  ] }) });
2187
2397
  };
2188
- const config$2 = adminSdk.defineRouteConfig({
2398
+ const config$1 = adminSdk.defineRouteConfig({
2189
2399
  label: "Return Order Details",
2190
2400
  icon: icons.CheckCircle
2191
2401
  });
2192
- const getStatusBadgeClass$1 = (status) => {
2193
- const s2 = status.toLowerCase();
2194
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2195
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2196
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2197
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2198
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2199
- };
2200
- const formatAmount = (value) => {
2201
- return String(value);
2202
- };
2203
- const RefundDetailPage = () => {
2204
- var _a, _b, _c;
2205
- const navigate = reactRouterDom.useNavigate();
2206
- const params = reactRouterDom.useParams();
2207
- const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
2208
- const [detail, setDetail] = react.useState(null);
2209
- const [loading, setLoading] = react.useState(!!id);
2210
- const [error, setError] = react.useState(null);
2211
- const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
2212
- react.useEffect(() => {
2213
- if (!id) {
2214
- setLoading(false);
2215
- return;
2216
- }
2217
- let cancelled = false;
2218
- setLoading(true);
2219
- setError(null);
2220
- fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
2221
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
2222
- return res.json();
2223
- }).then((data) => {
2224
- if (!cancelled) setDetail(data);
2225
- }).catch((e) => {
2226
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
2227
- }).finally(() => {
2228
- if (!cancelled) setLoading(false);
2229
- });
2230
- return () => {
2231
- cancelled = true;
2232
- };
2233
- }, [id]);
2234
- const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
2235
- 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;
2236
- 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: [
2237
- /* @__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: [
2238
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
2239
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
2240
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
2241
- ] }) }),
2242
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2243
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2244
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
2245
- ] }) : 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: [
2246
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2247
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
2248
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2249
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2250
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
2251
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
2252
- ] }),
2253
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2254
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
2255
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
2256
- ] }),
2257
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2258
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
2259
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
2260
- ] }),
2261
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2262
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
2263
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
2264
- year: "numeric",
2265
- month: "short",
2266
- day: "numeric",
2267
- hour: "numeric",
2268
- minute: "2-digit",
2269
- hour12: true
2270
- }) })
2271
- ] }),
2272
- detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2273
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
2274
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
2275
- ] }) : null
2276
- ] })
2277
- ] }),
2278
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2279
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
2280
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2281
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2282
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
2283
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
2284
- ] }),
2285
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2286
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
2287
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
2288
- ] }),
2289
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2290
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
2291
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
2292
- ] }),
2293
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2294
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
2295
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
2296
- ] }),
2297
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2298
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
2299
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2300
- ui.Badge,
2301
- {
2302
- size: "2xsmall",
2303
- className: `uppercase ${getStatusBadgeClass$1(paymentStatus)}`,
2304
- children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
2305
- }
2306
- ) })
2307
- ] }),
2308
- detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2309
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2310
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
2311
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
2312
- ] }),
2313
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2314
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
2315
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
2316
- ] }),
2317
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2318
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
2319
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
2320
- detail.computed.refund_percentage.toFixed(1),
2321
- "%"
2322
- ] })
2323
- ] })
2324
- ] }) : null
2325
- ] })
2326
- ] }),
2327
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2328
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
2329
- detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
2330
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2331
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
2332
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
2333
- ui.Button,
2334
- {
2335
- variant: "transparent",
2336
- size: "small",
2337
- onClick: () => navigate(`/orders/${detail.order.order_id}`),
2338
- children: detail.order.order_number ?? detail.order.order_id
2339
- }
2340
- ) })
2341
- ] }),
2342
- detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2343
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
2344
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
2345
- ] }) : null,
2346
- detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2347
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
2348
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
2349
- ] }) : null,
2350
- detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2351
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
2352
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
2353
- ] }) : null,
2354
- detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2355
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
2356
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
2357
- ] }) : null
2358
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
2359
- ] }),
2360
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
2361
- /* @__PURE__ */ jsxRuntime.jsxs(
2362
- "button",
2363
- {
2364
- type: "button",
2365
- className: "flex w-full items-center justify-between text-left",
2366
- onClick: () => setGatewayExpanded((prev) => !prev),
2367
- "aria-expanded": gatewayExpanded,
2368
- "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
2369
- children: [
2370
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
2371
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
2372
- ]
2373
- }
2374
- ),
2375
- gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
2376
- ] })
2377
- ] }) : null
2378
- ] }) });
2379
- };
2380
- const config$1 = adminSdk.defineRouteConfig({
2381
- label: "Refund details",
2382
- icon: icons.Receipt
2383
- });
2384
2402
  const getStatusBadgeClass = (status) => {
2385
2403
  const statusLower = status.toLowerCase();
2386
2404
  if (statusLower === "requested") {
@@ -2677,14 +2695,14 @@ const routeModule = {
2677
2695
  Component: PaymentsPage,
2678
2696
  path: "/payments"
2679
2697
  },
2680
- {
2681
- Component: ReturnsPage,
2682
- path: "/returns"
2683
- },
2684
2698
  {
2685
2699
  Component: RefundsPage,
2686
2700
  path: "/refunds"
2687
2701
  },
2702
+ {
2703
+ Component: ReturnsPage,
2704
+ path: "/returns"
2705
+ },
2688
2706
  {
2689
2707
  Component: SwapsPage,
2690
2708
  path: "/swaps"
@@ -2693,14 +2711,14 @@ const routeModule = {
2693
2711
  Component: PaymentDetailPage,
2694
2712
  path: "/payments/:id"
2695
2713
  },
2696
- {
2697
- Component: ReturnDetailPage,
2698
- path: "/returns/:id"
2699
- },
2700
2714
  {
2701
2715
  Component: RefundDetailPage,
2702
2716
  path: "/refunds/:id"
2703
2717
  },
2718
+ {
2719
+ Component: ReturnDetailPage,
2720
+ path: "/returns/:id"
2721
+ },
2704
2722
  {
2705
2723
  Component: SwapDetailPage,
2706
2724
  path: "/swaps/:id"
@@ -2710,20 +2728,14 @@ const routeModule = {
2710
2728
  const menuItemModule = {
2711
2729
  menuItems: [
2712
2730
  {
2713
- label: config$7.label,
2714
- icon: config$7.icon,
2715
- path: "/payments",
2731
+ label: config$6.label,
2732
+ icon: config$6.icon,
2733
+ path: "/refunds",
2716
2734
  nested: void 0
2717
2735
  },
2718
2736
  {
2719
2737
  label: config$5.label,
2720
2738
  icon: config$5.icon,
2721
- path: "/refunds",
2722
- nested: void 0
2723
- },
2724
- {
2725
- label: config$6.label,
2726
- icon: config$6.icon,
2727
2739
  path: "/returns",
2728
2740
  nested: void 0
2729
2741
  },
@@ -2734,20 +2746,20 @@ const menuItemModule = {
2734
2746
  nested: void 0
2735
2747
  },
2736
2748
  {
2737
- label: config$3.label,
2738
- icon: config$3.icon,
2739
- path: "/payments/:id",
2749
+ label: config$7.label,
2750
+ icon: config$7.icon,
2751
+ path: "/payments",
2740
2752
  nested: void 0
2741
2753
  },
2742
2754
  {
2743
- label: config$1.label,
2744
- icon: config$1.icon,
2755
+ label: config$2.label,
2756
+ icon: config$2.icon,
2745
2757
  path: "/refunds/:id",
2746
2758
  nested: void 0
2747
2759
  },
2748
2760
  {
2749
- label: config$2.label,
2750
- icon: config$2.icon,
2761
+ label: config$1.label,
2762
+ icon: config$1.icon,
2751
2763
  path: "/returns/:id",
2752
2764
  nested: void 0
2753
2765
  },
@@ -2756,6 +2768,12 @@ const menuItemModule = {
2756
2768
  icon: config.icon,
2757
2769
  path: "/swaps/:id",
2758
2770
  nested: void 0
2771
+ },
2772
+ {
2773
+ label: config$3.label,
2774
+ icon: config$3.icon,
2775
+ path: "/payments/:id",
2776
+ nested: void 0
2759
2777
  }
2760
2778
  ]
2761
2779
  };