order-management 0.0.83 → 0.0.85
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.
- package/.medusa/server/src/admin/index.js +678 -678
- package/.medusa/server/src/admin/index.mjs +679 -679
- package/.medusa/server/src/api/store/payment-details/[id]/route.js +13 -5
- package/.medusa/server/src/modules/payment-detail/service.js +2 -2
- package/.medusa/server/src/utils/notification-handler.js +13 -5
- package/.medusa/server/src/utils/phone-e164.js +66 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
3
|
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
4
4
|
import { Container, Text, Heading, Badge, Button, Label, Select, Textarea, Input } from "@medusajs/ui";
|
|
5
|
-
import { CashSolid, PencilSquareSolid, Trash, CreditCard, Receipt,
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, CreditCard, ArrowPath, Receipt, ArrowLeft, CheckCircle } from "@medusajs/icons";
|
|
6
6
|
import { useNavigate, useParams } from "react-router-dom";
|
|
7
7
|
function roundRectPath(ctx, x, y, w, h, r) {
|
|
8
8
|
ctx.beginPath();
|
|
@@ -1065,6 +1065,236 @@ const useDebounce$2 = (value, delay) => {
|
|
|
1065
1065
|
return debouncedValue;
|
|
1066
1066
|
};
|
|
1067
1067
|
const getStatusBadgeClass$6 = (status) => {
|
|
1068
|
+
const statusLower = status.toLowerCase();
|
|
1069
|
+
if (statusLower === "requested") {
|
|
1070
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1071
|
+
}
|
|
1072
|
+
if (statusLower === "approved") {
|
|
1073
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1074
|
+
}
|
|
1075
|
+
if (statusLower === "rejected") {
|
|
1076
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1077
|
+
}
|
|
1078
|
+
if (statusLower === "completed") {
|
|
1079
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1080
|
+
}
|
|
1081
|
+
if (statusLower === "cancelled") {
|
|
1082
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1083
|
+
}
|
|
1084
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1085
|
+
};
|
|
1086
|
+
const SwapsPage = () => {
|
|
1087
|
+
const navigate = useNavigate();
|
|
1088
|
+
const [items, setItems] = useState([]);
|
|
1089
|
+
const [statusFilter, setStatusFilter] = useState("all");
|
|
1090
|
+
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1091
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
1092
|
+
const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
|
|
1093
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1094
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1095
|
+
const [error, setError] = useState(null);
|
|
1096
|
+
const [offset, setOffset] = useState(0);
|
|
1097
|
+
const [count, setCount] = useState(0);
|
|
1098
|
+
const limit = 50;
|
|
1099
|
+
const loadSwaps = useCallback(
|
|
1100
|
+
async (nextOffset, replace = false) => {
|
|
1101
|
+
var _a;
|
|
1102
|
+
try {
|
|
1103
|
+
if (replace) {
|
|
1104
|
+
setIsLoading(true);
|
|
1105
|
+
} else {
|
|
1106
|
+
setIsFetchingMore(true);
|
|
1107
|
+
}
|
|
1108
|
+
setError(null);
|
|
1109
|
+
const params = new URLSearchParams();
|
|
1110
|
+
params.set("limit", String(limit));
|
|
1111
|
+
params.set("offset", String(nextOffset));
|
|
1112
|
+
if (statusFilter !== "all") {
|
|
1113
|
+
params.set("status", statusFilter);
|
|
1114
|
+
}
|
|
1115
|
+
if (debouncedSearchQuery.trim()) {
|
|
1116
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
1117
|
+
}
|
|
1118
|
+
if (createdByFilter !== "all") {
|
|
1119
|
+
params.set("created_by", createdByFilter);
|
|
1120
|
+
}
|
|
1121
|
+
const response = await fetch(
|
|
1122
|
+
`/admin/swaps?${params.toString()}`,
|
|
1123
|
+
{ credentials: "include" }
|
|
1124
|
+
);
|
|
1125
|
+
if (!response.ok) {
|
|
1126
|
+
const message = await response.text();
|
|
1127
|
+
throw new Error(message || "Unable to load swaps");
|
|
1128
|
+
}
|
|
1129
|
+
const payload = await response.json();
|
|
1130
|
+
setCount(payload.count ?? 0);
|
|
1131
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1132
|
+
setItems(
|
|
1133
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1134
|
+
);
|
|
1135
|
+
} catch (loadError) {
|
|
1136
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1137
|
+
setError(message);
|
|
1138
|
+
} finally {
|
|
1139
|
+
setIsLoading(false);
|
|
1140
|
+
setIsFetchingMore(false);
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1144
|
+
);
|
|
1145
|
+
useEffect(() => {
|
|
1146
|
+
void loadSwaps(0, true);
|
|
1147
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1148
|
+
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1149
|
+
const availableStatuses = useMemo(() => {
|
|
1150
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
1151
|
+
items.forEach((item) => statuses.add(item.status));
|
|
1152
|
+
return Array.from(statuses).sort();
|
|
1153
|
+
}, [items]);
|
|
1154
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1155
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1156
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1157
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchanges" }),
|
|
1158
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1159
|
+
] }),
|
|
1160
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1161
|
+
] }),
|
|
1162
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1163
|
+
/* @__PURE__ */ jsx(
|
|
1164
|
+
Input,
|
|
1165
|
+
{
|
|
1166
|
+
placeholder: "Search by swap ID or order ID",
|
|
1167
|
+
value: searchQuery,
|
|
1168
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
1169
|
+
className: "md:max-w-sm"
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1173
|
+
/* @__PURE__ */ jsxs(
|
|
1174
|
+
"select",
|
|
1175
|
+
{
|
|
1176
|
+
value: createdByFilter,
|
|
1177
|
+
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
1178
|
+
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",
|
|
1179
|
+
children: [
|
|
1180
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All (Created by)" }),
|
|
1181
|
+
/* @__PURE__ */ jsx("option", { value: "customer", children: "Customer" }),
|
|
1182
|
+
/* @__PURE__ */ jsx("option", { value: "admin", children: "Admin" })
|
|
1183
|
+
]
|
|
1184
|
+
}
|
|
1185
|
+
),
|
|
1186
|
+
/* @__PURE__ */ jsxs(
|
|
1187
|
+
"select",
|
|
1188
|
+
{
|
|
1189
|
+
value: statusFilter,
|
|
1190
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
1191
|
+
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",
|
|
1192
|
+
children: [
|
|
1193
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All Statuses" }),
|
|
1194
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1195
|
+
]
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
] })
|
|
1199
|
+
] }),
|
|
1200
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1201
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1202
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1203
|
+
Button,
|
|
1204
|
+
{
|
|
1205
|
+
variant: "secondary",
|
|
1206
|
+
onClick: () => loadSwaps(0, true),
|
|
1207
|
+
children: "Try again"
|
|
1208
|
+
}
|
|
1209
|
+
) })
|
|
1210
|
+
] }) : null,
|
|
1211
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1212
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1213
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1214
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1215
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1216
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
|
|
1217
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1218
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1219
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
1220
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1221
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1222
|
+
] }) }),
|
|
1223
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxs(
|
|
1224
|
+
"tr",
|
|
1225
|
+
{
|
|
1226
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1227
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1228
|
+
children: [
|
|
1229
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx("span", { children: swap.id }) }) }),
|
|
1230
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
1231
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1232
|
+
Badge,
|
|
1233
|
+
{
|
|
1234
|
+
size: "2xsmall",
|
|
1235
|
+
className: `uppercase ${getStatusBadgeClass$6(swap.status)}`,
|
|
1236
|
+
children: swap.status.replace(/_/g, " ")
|
|
1237
|
+
}
|
|
1238
|
+
) }),
|
|
1239
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1240
|
+
const amount = swap.difference_due;
|
|
1241
|
+
if (amount == null || amount === void 0) {
|
|
1242
|
+
return "—";
|
|
1243
|
+
}
|
|
1244
|
+
const displayAmount = Number(amount) / 100;
|
|
1245
|
+
const currency = swap.currency_code || "$";
|
|
1246
|
+
const sign = displayAmount >= 0 ? "+" : "";
|
|
1247
|
+
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1248
|
+
})() }),
|
|
1249
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
1250
|
+
year: "numeric",
|
|
1251
|
+
month: "short",
|
|
1252
|
+
day: "numeric",
|
|
1253
|
+
hour: "numeric",
|
|
1254
|
+
minute: "2-digit",
|
|
1255
|
+
hour12: true
|
|
1256
|
+
}) }),
|
|
1257
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1258
|
+
Button,
|
|
1259
|
+
{
|
|
1260
|
+
variant: "transparent",
|
|
1261
|
+
size: "small",
|
|
1262
|
+
onClick: (e) => {
|
|
1263
|
+
e.stopPropagation();
|
|
1264
|
+
navigate(`/app/orders/${swap.order_id}`);
|
|
1265
|
+
},
|
|
1266
|
+
children: "Go to order"
|
|
1267
|
+
}
|
|
1268
|
+
) })
|
|
1269
|
+
]
|
|
1270
|
+
},
|
|
1271
|
+
swap.id
|
|
1272
|
+
)) })
|
|
1273
|
+
] }) }),
|
|
1274
|
+
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1275
|
+
Button,
|
|
1276
|
+
{
|
|
1277
|
+
variant: "secondary",
|
|
1278
|
+
isLoading: isFetchingMore,
|
|
1279
|
+
onClick: () => loadSwaps(offset, false),
|
|
1280
|
+
children: "Load more"
|
|
1281
|
+
}
|
|
1282
|
+
) }) : null
|
|
1283
|
+
] }) });
|
|
1284
|
+
};
|
|
1285
|
+
const config$6 = defineRouteConfig({
|
|
1286
|
+
label: "Exchanges",
|
|
1287
|
+
icon: ArrowPath
|
|
1288
|
+
});
|
|
1289
|
+
const useDebounce$1 = (value, delay) => {
|
|
1290
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1291
|
+
useEffect(() => {
|
|
1292
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1293
|
+
return () => clearTimeout(handler);
|
|
1294
|
+
}, [value, delay]);
|
|
1295
|
+
return debouncedValue;
|
|
1296
|
+
};
|
|
1297
|
+
const getStatusBadgeClass$5 = (status) => {
|
|
1068
1298
|
const s2 = status.toLowerCase();
|
|
1069
1299
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1070
1300
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -1076,12 +1306,12 @@ const RefundsPage = () => {
|
|
|
1076
1306
|
const navigate = useNavigate();
|
|
1077
1307
|
const [items, setItems] = useState([]);
|
|
1078
1308
|
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1079
|
-
const debouncedOrderId = useDebounce$
|
|
1309
|
+
const debouncedOrderId = useDebounce$1(orderIdSearch, 300);
|
|
1080
1310
|
const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
|
|
1081
1311
|
const [providerSearch, setProviderSearch] = useState("");
|
|
1082
|
-
const debouncedProvider = useDebounce$
|
|
1312
|
+
const debouncedProvider = useDebounce$1(providerSearch, 300);
|
|
1083
1313
|
const [currencySearch, setCurrencySearch] = useState("");
|
|
1084
|
-
const debouncedCurrency = useDebounce$
|
|
1314
|
+
const debouncedCurrency = useDebounce$1(currencySearch, 300);
|
|
1085
1315
|
const [dateFrom, setDateFrom] = useState("");
|
|
1086
1316
|
const [dateTo, setDateTo] = useState("");
|
|
1087
1317
|
const [amountMin, setAmountMin] = useState("");
|
|
@@ -1293,7 +1523,7 @@ const RefundsPage = () => {
|
|
|
1293
1523
|
Badge,
|
|
1294
1524
|
{
|
|
1295
1525
|
size: "2xsmall",
|
|
1296
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1526
|
+
className: `uppercase ${getStatusBadgeClass$5(displayStatus(r))}`,
|
|
1297
1527
|
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
1298
1528
|
}
|
|
1299
1529
|
) }),
|
|
@@ -1347,11 +1577,11 @@ const RefundsPage = () => {
|
|
|
1347
1577
|
) }) : null
|
|
1348
1578
|
] }) });
|
|
1349
1579
|
};
|
|
1350
|
-
const config$
|
|
1580
|
+
const config$5 = defineRouteConfig({
|
|
1351
1581
|
label: "Refunds",
|
|
1352
1582
|
icon: Receipt
|
|
1353
1583
|
});
|
|
1354
|
-
const useDebounce
|
|
1584
|
+
const useDebounce = (value, delay) => {
|
|
1355
1585
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1356
1586
|
useEffect(() => {
|
|
1357
1587
|
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
@@ -1359,7 +1589,7 @@ const useDebounce$1 = (value, delay) => {
|
|
|
1359
1589
|
}, [value, delay]);
|
|
1360
1590
|
return debouncedValue;
|
|
1361
1591
|
};
|
|
1362
|
-
const getStatusBadgeClass$
|
|
1592
|
+
const getStatusBadgeClass$4 = (status) => {
|
|
1363
1593
|
const statusLower = status.toLowerCase();
|
|
1364
1594
|
if (statusLower === "requested") {
|
|
1365
1595
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -1384,7 +1614,7 @@ const ReturnsPage = () => {
|
|
|
1384
1614
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1385
1615
|
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1386
1616
|
const [searchQuery, setSearchQuery] = useState("");
|
|
1387
|
-
const debouncedSearchQuery = useDebounce
|
|
1617
|
+
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1388
1618
|
const [isLoading, setIsLoading] = useState(true);
|
|
1389
1619
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1390
1620
|
const [error, setError] = useState(null);
|
|
@@ -1530,7 +1760,7 @@ const ReturnsPage = () => {
|
|
|
1530
1760
|
Badge,
|
|
1531
1761
|
{
|
|
1532
1762
|
size: "2xsmall",
|
|
1533
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1763
|
+
className: `uppercase ${getStatusBadgeClass$4(returnOrder.status)}`,
|
|
1534
1764
|
children: returnOrder.status.replace(/_/g, " ")
|
|
1535
1765
|
}
|
|
1536
1766
|
) }),
|
|
@@ -1579,247 +1809,17 @@ const ReturnsPage = () => {
|
|
|
1579
1809
|
) }) : null
|
|
1580
1810
|
] }) });
|
|
1581
1811
|
};
|
|
1582
|
-
const config$
|
|
1812
|
+
const config$4 = defineRouteConfig({
|
|
1583
1813
|
label: "Return Orders",
|
|
1584
1814
|
icon: ArrowPath
|
|
1585
1815
|
});
|
|
1586
|
-
const
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
return
|
|
1593
|
-
};
|
|
1594
|
-
const getStatusBadgeClass$4 = (status) => {
|
|
1595
|
-
const statusLower = status.toLowerCase();
|
|
1596
|
-
if (statusLower === "requested") {
|
|
1597
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1598
|
-
}
|
|
1599
|
-
if (statusLower === "approved") {
|
|
1600
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1601
|
-
}
|
|
1602
|
-
if (statusLower === "rejected") {
|
|
1603
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1604
|
-
}
|
|
1605
|
-
if (statusLower === "completed") {
|
|
1606
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1607
|
-
}
|
|
1608
|
-
if (statusLower === "cancelled") {
|
|
1609
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1610
|
-
}
|
|
1611
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1612
|
-
};
|
|
1613
|
-
const SwapsPage = () => {
|
|
1614
|
-
const navigate = useNavigate();
|
|
1615
|
-
const [items, setItems] = useState([]);
|
|
1616
|
-
const [statusFilter, setStatusFilter] = useState("all");
|
|
1617
|
-
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1618
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
1619
|
-
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1620
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
1621
|
-
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1622
|
-
const [error, setError] = useState(null);
|
|
1623
|
-
const [offset, setOffset] = useState(0);
|
|
1624
|
-
const [count, setCount] = useState(0);
|
|
1625
|
-
const limit = 50;
|
|
1626
|
-
const loadSwaps = useCallback(
|
|
1627
|
-
async (nextOffset, replace = false) => {
|
|
1628
|
-
var _a;
|
|
1629
|
-
try {
|
|
1630
|
-
if (replace) {
|
|
1631
|
-
setIsLoading(true);
|
|
1632
|
-
} else {
|
|
1633
|
-
setIsFetchingMore(true);
|
|
1634
|
-
}
|
|
1635
|
-
setError(null);
|
|
1636
|
-
const params = new URLSearchParams();
|
|
1637
|
-
params.set("limit", String(limit));
|
|
1638
|
-
params.set("offset", String(nextOffset));
|
|
1639
|
-
if (statusFilter !== "all") {
|
|
1640
|
-
params.set("status", statusFilter);
|
|
1641
|
-
}
|
|
1642
|
-
if (debouncedSearchQuery.trim()) {
|
|
1643
|
-
params.set("order_id", debouncedSearchQuery.trim());
|
|
1644
|
-
}
|
|
1645
|
-
if (createdByFilter !== "all") {
|
|
1646
|
-
params.set("created_by", createdByFilter);
|
|
1647
|
-
}
|
|
1648
|
-
const response = await fetch(
|
|
1649
|
-
`/admin/swaps?${params.toString()}`,
|
|
1650
|
-
{ credentials: "include" }
|
|
1651
|
-
);
|
|
1652
|
-
if (!response.ok) {
|
|
1653
|
-
const message = await response.text();
|
|
1654
|
-
throw new Error(message || "Unable to load swaps");
|
|
1655
|
-
}
|
|
1656
|
-
const payload = await response.json();
|
|
1657
|
-
setCount(payload.count ?? 0);
|
|
1658
|
-
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1659
|
-
setItems(
|
|
1660
|
-
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1661
|
-
);
|
|
1662
|
-
} catch (loadError) {
|
|
1663
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1664
|
-
setError(message);
|
|
1665
|
-
} finally {
|
|
1666
|
-
setIsLoading(false);
|
|
1667
|
-
setIsFetchingMore(false);
|
|
1668
|
-
}
|
|
1669
|
-
},
|
|
1670
|
-
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1671
|
-
);
|
|
1672
|
-
useEffect(() => {
|
|
1673
|
-
void loadSwaps(0, true);
|
|
1674
|
-
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1675
|
-
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1676
|
-
const availableStatuses = useMemo(() => {
|
|
1677
|
-
const statuses = /* @__PURE__ */ new Set();
|
|
1678
|
-
items.forEach((item) => statuses.add(item.status));
|
|
1679
|
-
return Array.from(statuses).sort();
|
|
1680
|
-
}, [items]);
|
|
1681
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
1682
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1683
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1684
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchanges" }),
|
|
1685
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1686
|
-
] }),
|
|
1687
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1688
|
-
] }),
|
|
1689
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1690
|
-
/* @__PURE__ */ jsx(
|
|
1691
|
-
Input,
|
|
1692
|
-
{
|
|
1693
|
-
placeholder: "Search by swap ID or order ID",
|
|
1694
|
-
value: searchQuery,
|
|
1695
|
-
onChange: (event) => setSearchQuery(event.target.value),
|
|
1696
|
-
className: "md:max-w-sm"
|
|
1697
|
-
}
|
|
1698
|
-
),
|
|
1699
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1700
|
-
/* @__PURE__ */ jsxs(
|
|
1701
|
-
"select",
|
|
1702
|
-
{
|
|
1703
|
-
value: createdByFilter,
|
|
1704
|
-
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
1705
|
-
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",
|
|
1706
|
-
children: [
|
|
1707
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All (Created by)" }),
|
|
1708
|
-
/* @__PURE__ */ jsx("option", { value: "customer", children: "Customer" }),
|
|
1709
|
-
/* @__PURE__ */ jsx("option", { value: "admin", children: "Admin" })
|
|
1710
|
-
]
|
|
1711
|
-
}
|
|
1712
|
-
),
|
|
1713
|
-
/* @__PURE__ */ jsxs(
|
|
1714
|
-
"select",
|
|
1715
|
-
{
|
|
1716
|
-
value: statusFilter,
|
|
1717
|
-
onChange: (event) => setStatusFilter(event.target.value),
|
|
1718
|
-
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",
|
|
1719
|
-
children: [
|
|
1720
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All Statuses" }),
|
|
1721
|
-
availableStatuses.map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1722
|
-
]
|
|
1723
|
-
}
|
|
1724
|
-
)
|
|
1725
|
-
] })
|
|
1726
|
-
] }),
|
|
1727
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1728
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1729
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1730
|
-
Button,
|
|
1731
|
-
{
|
|
1732
|
-
variant: "secondary",
|
|
1733
|
-
onClick: () => loadSwaps(0, true),
|
|
1734
|
-
children: "Try again"
|
|
1735
|
-
}
|
|
1736
|
-
) })
|
|
1737
|
-
] }) : null,
|
|
1738
|
-
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1739
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1740
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1741
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
1742
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1743
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
|
|
1744
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1745
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1746
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
1747
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1748
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1749
|
-
] }) }),
|
|
1750
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxs(
|
|
1751
|
-
"tr",
|
|
1752
|
-
{
|
|
1753
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1754
|
-
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1755
|
-
children: [
|
|
1756
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx("span", { children: swap.id }) }) }),
|
|
1757
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
1758
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1759
|
-
Badge,
|
|
1760
|
-
{
|
|
1761
|
-
size: "2xsmall",
|
|
1762
|
-
className: `uppercase ${getStatusBadgeClass$4(swap.status)}`,
|
|
1763
|
-
children: swap.status.replace(/_/g, " ")
|
|
1764
|
-
}
|
|
1765
|
-
) }),
|
|
1766
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1767
|
-
const amount = swap.difference_due;
|
|
1768
|
-
if (amount == null || amount === void 0) {
|
|
1769
|
-
return "—";
|
|
1770
|
-
}
|
|
1771
|
-
const displayAmount = Number(amount) / 100;
|
|
1772
|
-
const currency = swap.currency_code || "$";
|
|
1773
|
-
const sign = displayAmount >= 0 ? "+" : "";
|
|
1774
|
-
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1775
|
-
})() }),
|
|
1776
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
1777
|
-
year: "numeric",
|
|
1778
|
-
month: "short",
|
|
1779
|
-
day: "numeric",
|
|
1780
|
-
hour: "numeric",
|
|
1781
|
-
minute: "2-digit",
|
|
1782
|
-
hour12: true
|
|
1783
|
-
}) }),
|
|
1784
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1785
|
-
Button,
|
|
1786
|
-
{
|
|
1787
|
-
variant: "transparent",
|
|
1788
|
-
size: "small",
|
|
1789
|
-
onClick: (e) => {
|
|
1790
|
-
e.stopPropagation();
|
|
1791
|
-
navigate(`/app/orders/${swap.order_id}`);
|
|
1792
|
-
},
|
|
1793
|
-
children: "Go to order"
|
|
1794
|
-
}
|
|
1795
|
-
) })
|
|
1796
|
-
]
|
|
1797
|
-
},
|
|
1798
|
-
swap.id
|
|
1799
|
-
)) })
|
|
1800
|
-
] }) }),
|
|
1801
|
-
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1802
|
-
Button,
|
|
1803
|
-
{
|
|
1804
|
-
variant: "secondary",
|
|
1805
|
-
isLoading: isFetchingMore,
|
|
1806
|
-
onClick: () => loadSwaps(offset, false),
|
|
1807
|
-
children: "Load more"
|
|
1808
|
-
}
|
|
1809
|
-
) }) : null
|
|
1810
|
-
] }) });
|
|
1811
|
-
};
|
|
1812
|
-
const config$4 = defineRouteConfig({
|
|
1813
|
-
label: "Exchanges",
|
|
1814
|
-
icon: ArrowPath
|
|
1815
|
-
});
|
|
1816
|
-
const getStatusBadgeClass$3 = (status) => {
|
|
1817
|
-
const s2 = status.toLowerCase();
|
|
1818
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1819
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1820
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1821
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1822
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1816
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
1817
|
+
const s2 = status.toLowerCase();
|
|
1818
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1819
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1820
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1821
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1822
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1823
1823
|
};
|
|
1824
1824
|
const PaymentDetailPage = () => {
|
|
1825
1825
|
var _a;
|
|
@@ -1933,196 +1933,283 @@ const config$3 = defineRouteConfig({
|
|
|
1933
1933
|
icon: CreditCard
|
|
1934
1934
|
});
|
|
1935
1935
|
const getStatusBadgeClass$2 = (status) => {
|
|
1936
|
-
const
|
|
1937
|
-
if (
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
if (
|
|
1936
|
+
const statusLower = status.toLowerCase();
|
|
1937
|
+
if (statusLower === "requested") {
|
|
1938
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1939
|
+
}
|
|
1940
|
+
if (statusLower === "approved") {
|
|
1941
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1942
|
+
}
|
|
1943
|
+
if (statusLower === "rejected") {
|
|
1944
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1945
|
+
}
|
|
1946
|
+
if (statusLower === "completed") {
|
|
1947
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1948
|
+
}
|
|
1949
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
1950
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1951
|
+
}
|
|
1952
|
+
if (statusLower === "pending") {
|
|
1953
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1954
|
+
}
|
|
1941
1955
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1942
1956
|
};
|
|
1943
|
-
const
|
|
1944
|
-
return String(value);
|
|
1945
|
-
};
|
|
1946
|
-
const RefundDetailPage = () => {
|
|
1957
|
+
const SwapDetailPage = () => {
|
|
1947
1958
|
var _a, _b, _c;
|
|
1948
1959
|
const navigate = useNavigate();
|
|
1949
|
-
const
|
|
1950
|
-
const
|
|
1951
|
-
const [
|
|
1952
|
-
const [
|
|
1960
|
+
const { id } = useParams();
|
|
1961
|
+
const [swap, setSwap] = useState(null);
|
|
1962
|
+
const [order, setOrder] = useState(null);
|
|
1963
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1964
|
+
useState(false);
|
|
1965
|
+
const [isCancelling, setIsCancelling] = useState(false);
|
|
1953
1966
|
const [error, setError] = useState(null);
|
|
1954
|
-
const [
|
|
1967
|
+
const [updateError, setUpdateError] = useState(null);
|
|
1968
|
+
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
1955
1969
|
useEffect(() => {
|
|
1956
1970
|
if (!id) {
|
|
1957
|
-
|
|
1971
|
+
navigate("/swaps");
|
|
1958
1972
|
return;
|
|
1959
1973
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1974
|
+
const loadSwap = async () => {
|
|
1975
|
+
try {
|
|
1976
|
+
setIsLoading(true);
|
|
1977
|
+
setError(null);
|
|
1978
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
1979
|
+
credentials: "include"
|
|
1980
|
+
});
|
|
1981
|
+
if (!response.ok) {
|
|
1982
|
+
const message = await response.text();
|
|
1983
|
+
throw new Error(message || "Unable to load swap");
|
|
1984
|
+
}
|
|
1985
|
+
const payload = await response.json();
|
|
1986
|
+
setSwap(payload.swap);
|
|
1987
|
+
setOrder(payload.order || null);
|
|
1988
|
+
} catch (loadError) {
|
|
1989
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
1990
|
+
setError(message);
|
|
1991
|
+
} finally {
|
|
1992
|
+
setIsLoading(false);
|
|
1993
|
+
}
|
|
1975
1994
|
};
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
const
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1995
|
+
void loadSwap();
|
|
1996
|
+
}, [id, navigate]);
|
|
1997
|
+
const handleCancelExchange = async () => {
|
|
1998
|
+
if (!id) {
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
try {
|
|
2002
|
+
setIsCancelling(true);
|
|
2003
|
+
setUpdateError(null);
|
|
2004
|
+
setUpdateSuccess(false);
|
|
2005
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2006
|
+
method: "POST",
|
|
2007
|
+
headers: {
|
|
2008
|
+
"Content-Type": "application/json"
|
|
2009
|
+
},
|
|
2010
|
+
credentials: "include"
|
|
2011
|
+
});
|
|
2012
|
+
if (!response.ok) {
|
|
2013
|
+
const message = await response.text();
|
|
2014
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2015
|
+
}
|
|
2016
|
+
const payload = await response.json();
|
|
2017
|
+
setSwap(payload.swap);
|
|
2018
|
+
setUpdateSuccess(true);
|
|
2019
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2020
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2021
|
+
credentials: "include"
|
|
2022
|
+
});
|
|
2023
|
+
if (detailResponse.ok) {
|
|
2024
|
+
const detailPayload = await detailResponse.json();
|
|
2025
|
+
setSwap(detailPayload.swap);
|
|
2026
|
+
setOrder(detailPayload.order || null);
|
|
2027
|
+
}
|
|
2028
|
+
} catch (cancelErr) {
|
|
2029
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2030
|
+
setUpdateError(message);
|
|
2031
|
+
} finally {
|
|
2032
|
+
setIsCancelling(false);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2036
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2037
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2038
|
+
);
|
|
2039
|
+
if (isLoading) {
|
|
2040
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swap..." }) }) }) });
|
|
2041
|
+
}
|
|
2042
|
+
if (error || !swap) {
|
|
2043
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2044
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2045
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2046
|
+
] }) }) });
|
|
2047
|
+
}
|
|
2048
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2049
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
2050
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2051
|
+
/* @__PURE__ */ jsxs(
|
|
2052
|
+
Button,
|
|
2053
|
+
{
|
|
2054
|
+
variant: "transparent",
|
|
2055
|
+
size: "small",
|
|
2056
|
+
onClick: () => navigate("/swaps"),
|
|
2057
|
+
className: "w-fit",
|
|
2058
|
+
children: [
|
|
2059
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
2060
|
+
"Back to list"
|
|
2061
|
+
]
|
|
2062
|
+
}
|
|
2063
|
+
),
|
|
2064
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2065
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2066
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
2067
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2068
|
+
] }),
|
|
2069
|
+
/* @__PURE__ */ jsx(
|
|
2070
|
+
Badge,
|
|
2071
|
+
{
|
|
2072
|
+
size: "small",
|
|
2073
|
+
className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
|
|
2074
|
+
children: swap.status.replace(/_/g, " ")
|
|
2075
|
+
}
|
|
2076
|
+
)
|
|
2077
|
+
] })
|
|
2078
|
+
] }),
|
|
2079
|
+
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2080
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2081
|
+
Button,
|
|
2082
|
+
{
|
|
2083
|
+
variant: "danger",
|
|
2084
|
+
onClick: handleCancelExchange,
|
|
2085
|
+
disabled: isCancelling,
|
|
2086
|
+
isLoading: isCancelling,
|
|
2087
|
+
children: "Cancel Exchange"
|
|
2088
|
+
}
|
|
2089
|
+
) }),
|
|
2090
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2091
|
+
] }),
|
|
2092
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2093
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2094
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2095
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2000
2096
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2001
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2002
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2097
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2098
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
2003
2099
|
] }),
|
|
2004
2100
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2005
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2006
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2007
|
-
year: "numeric",
|
|
2008
|
-
month: "short",
|
|
2009
|
-
day: "numeric",
|
|
2010
|
-
hour: "numeric",
|
|
2011
|
-
minute: "2-digit",
|
|
2012
|
-
hour12: true
|
|
2013
|
-
}) })
|
|
2101
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2102
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
2014
2103
|
] }),
|
|
2015
|
-
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2016
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
2017
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
2018
|
-
] }) : null
|
|
2019
|
-
] })
|
|
2020
|
-
] }),
|
|
2021
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2022
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
2023
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2024
2104
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2025
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2026
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2105
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2106
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2027
2107
|
] }),
|
|
2028
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2029
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2030
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2108
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2109
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2110
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
2031
2111
|
] }),
|
|
2032
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2033
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2034
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2112
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2113
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2114
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
2035
2115
|
] }),
|
|
2036
2116
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2037
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2038
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2117
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2118
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2039
2119
|
] }),
|
|
2040
2120
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2041
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2042
|
-
/* @__PURE__ */ jsx(
|
|
2043
|
-
Badge,
|
|
2044
|
-
{
|
|
2045
|
-
size: "2xsmall",
|
|
2046
|
-
className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
|
|
2047
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2048
|
-
}
|
|
2049
|
-
) })
|
|
2121
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2122
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2050
2123
|
] }),
|
|
2051
|
-
|
|
2052
|
-
/* @__PURE__ */
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
] }),
|
|
2056
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2057
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2058
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2059
|
-
] }),
|
|
2060
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2061
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2062
|
-
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2063
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
2064
|
-
"%"
|
|
2065
|
-
] })
|
|
2066
|
-
] })
|
|
2067
|
-
] }) : null
|
|
2124
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2125
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2126
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2127
|
+
] })
|
|
2068
2128
|
] })
|
|
2069
2129
|
] }),
|
|
2070
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-
|
|
2071
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2075
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2076
|
-
Button,
|
|
2077
|
-
{
|
|
2078
|
-
variant: "transparent",
|
|
2079
|
-
size: "small",
|
|
2080
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2081
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
2082
|
-
}
|
|
2083
|
-
) })
|
|
2084
|
-
] }),
|
|
2085
|
-
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2086
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2087
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2088
|
-
] }) : null,
|
|
2089
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2090
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2091
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2092
|
-
] }) : null,
|
|
2093
|
-
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2094
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2095
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2096
|
-
] }) : null,
|
|
2097
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2098
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2099
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2100
|
-
] }) : null
|
|
2101
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2102
|
-
] }),
|
|
2103
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2104
|
-
/* @__PURE__ */ jsxs(
|
|
2105
|
-
"button",
|
|
2130
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2131
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
2132
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsx(
|
|
2133
|
+
"div",
|
|
2106
2134
|
{
|
|
2107
|
-
|
|
2108
|
-
className: "flex
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2135
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
2136
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2137
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
2138
|
+
Badge,
|
|
2139
|
+
{
|
|
2140
|
+
size: "2xsmall",
|
|
2141
|
+
className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
|
|
2142
|
+
children: entry.status.replace(/_/g, " ")
|
|
2143
|
+
}
|
|
2144
|
+
) }),
|
|
2145
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
2146
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
2147
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
2148
|
+
entry.reason && ` - ${entry.reason}`
|
|
2149
|
+
] })
|
|
2150
|
+
] })
|
|
2151
|
+
},
|
|
2152
|
+
index
|
|
2153
|
+
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2119
2154
|
] })
|
|
2120
|
-
] })
|
|
2155
|
+
] }),
|
|
2156
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2157
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2158
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2159
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2160
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2161
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2162
|
+
] }),
|
|
2163
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2164
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2165
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2166
|
+
] }),
|
|
2167
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2168
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2169
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2170
|
+
] }),
|
|
2171
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2172
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2173
|
+
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2174
|
+
order.currency_code || "$",
|
|
2175
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2176
|
+
] })
|
|
2177
|
+
] })
|
|
2178
|
+
] })
|
|
2179
|
+
] }),
|
|
2180
|
+
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2181
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2182
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2183
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2184
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2185
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2186
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2187
|
+
] }) }),
|
|
2188
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2189
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2190
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2191
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2192
|
+
] }, item.id || index)) })
|
|
2193
|
+
] }) })
|
|
2194
|
+
] }),
|
|
2195
|
+
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2196
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2197
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2198
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2199
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2200
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2201
|
+
] }) }),
|
|
2202
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2203
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2204
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2205
|
+
] }, item.variant_id || index)) })
|
|
2206
|
+
] }) })
|
|
2207
|
+
] })
|
|
2121
2208
|
] }) });
|
|
2122
2209
|
};
|
|
2123
2210
|
const config$2 = defineRouteConfig({
|
|
2124
|
-
label: "
|
|
2125
|
-
icon:
|
|
2211
|
+
label: "Swap Details",
|
|
2212
|
+
icon: ArrowPath
|
|
2126
2213
|
});
|
|
2127
2214
|
const getStatusBadgeClass$1 = (status) => {
|
|
2128
2215
|
const statusLower = status.toLowerCase();
|
|
@@ -2403,283 +2490,196 @@ const config$1 = defineRouteConfig({
|
|
|
2403
2490
|
icon: CheckCircle
|
|
2404
2491
|
});
|
|
2405
2492
|
const getStatusBadgeClass = (status) => {
|
|
2406
|
-
const
|
|
2407
|
-
if (
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
if (
|
|
2411
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2412
|
-
}
|
|
2413
|
-
if (statusLower === "rejected") {
|
|
2414
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2415
|
-
}
|
|
2416
|
-
if (statusLower === "completed") {
|
|
2417
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2418
|
-
}
|
|
2419
|
-
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2420
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2421
|
-
}
|
|
2422
|
-
if (statusLower === "pending") {
|
|
2423
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2424
|
-
}
|
|
2493
|
+
const s2 = status.toLowerCase();
|
|
2494
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2495
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2496
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2497
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2425
2498
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2426
2499
|
};
|
|
2427
|
-
const
|
|
2500
|
+
const formatAmount = (value) => {
|
|
2501
|
+
return String(value);
|
|
2502
|
+
};
|
|
2503
|
+
const RefundDetailPage = () => {
|
|
2428
2504
|
var _a, _b, _c;
|
|
2429
2505
|
const navigate = useNavigate();
|
|
2430
|
-
const
|
|
2431
|
-
const
|
|
2432
|
-
const [
|
|
2433
|
-
const [
|
|
2434
|
-
useState(false);
|
|
2435
|
-
const [isCancelling, setIsCancelling] = useState(false);
|
|
2506
|
+
const params = useParams();
|
|
2507
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2508
|
+
const [detail, setDetail] = useState(null);
|
|
2509
|
+
const [loading, setLoading] = useState(!!id);
|
|
2436
2510
|
const [error, setError] = useState(null);
|
|
2437
|
-
const [
|
|
2438
|
-
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2511
|
+
const [gatewayExpanded, setGatewayExpanded] = useState(false);
|
|
2439
2512
|
useEffect(() => {
|
|
2440
2513
|
if (!id) {
|
|
2441
|
-
|
|
2514
|
+
setLoading(false);
|
|
2442
2515
|
return;
|
|
2443
2516
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2460
|
-
setError(message);
|
|
2461
|
-
} finally {
|
|
2462
|
-
setIsLoading(false);
|
|
2463
|
-
}
|
|
2517
|
+
let cancelled = false;
|
|
2518
|
+
setLoading(true);
|
|
2519
|
+
setError(null);
|
|
2520
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
2521
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2522
|
+
return res.json();
|
|
2523
|
+
}).then((data) => {
|
|
2524
|
+
if (!cancelled) setDetail(data);
|
|
2525
|
+
}).catch((e) => {
|
|
2526
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2527
|
+
}).finally(() => {
|
|
2528
|
+
if (!cancelled) setLoading(false);
|
|
2529
|
+
});
|
|
2530
|
+
return () => {
|
|
2531
|
+
cancelled = true;
|
|
2464
2532
|
};
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
const
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
},
|
|
2480
|
-
|
|
2481
|
-
});
|
|
2482
|
-
if (!response.ok) {
|
|
2483
|
-
const message = await response.text();
|
|
2484
|
-
throw new Error(message || "Unable to cancel exchange");
|
|
2485
|
-
}
|
|
2486
|
-
const payload = await response.json();
|
|
2487
|
-
setSwap(payload.swap);
|
|
2488
|
-
setUpdateSuccess(true);
|
|
2489
|
-
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2490
|
-
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2491
|
-
credentials: "include"
|
|
2492
|
-
});
|
|
2493
|
-
if (detailResponse.ok) {
|
|
2494
|
-
const detailPayload = await detailResponse.json();
|
|
2495
|
-
setSwap(detailPayload.swap);
|
|
2496
|
-
setOrder(detailPayload.order || null);
|
|
2497
|
-
}
|
|
2498
|
-
} catch (cancelErr) {
|
|
2499
|
-
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2500
|
-
setUpdateError(message);
|
|
2501
|
-
} finally {
|
|
2502
|
-
setIsCancelling(false);
|
|
2503
|
-
}
|
|
2504
|
-
};
|
|
2505
|
-
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2506
|
-
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2507
|
-
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2508
|
-
);
|
|
2509
|
-
if (isLoading) {
|
|
2510
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swap..." }) }) }) });
|
|
2511
|
-
}
|
|
2512
|
-
if (error || !swap) {
|
|
2513
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2514
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2515
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2516
|
-
] }) }) });
|
|
2517
|
-
}
|
|
2518
|
-
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2519
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
2520
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2521
|
-
/* @__PURE__ */ jsxs(
|
|
2522
|
-
Button,
|
|
2523
|
-
{
|
|
2524
|
-
variant: "transparent",
|
|
2525
|
-
size: "small",
|
|
2526
|
-
onClick: () => navigate("/swaps"),
|
|
2527
|
-
className: "w-fit",
|
|
2528
|
-
children: [
|
|
2529
|
-
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
2530
|
-
"Back to list"
|
|
2531
|
-
]
|
|
2532
|
-
}
|
|
2533
|
-
),
|
|
2534
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2535
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2536
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
2537
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2538
|
-
] }),
|
|
2539
|
-
/* @__PURE__ */ jsx(
|
|
2540
|
-
Badge,
|
|
2541
|
-
{
|
|
2542
|
-
size: "small",
|
|
2543
|
-
className: `uppercase ${getStatusBadgeClass(swap.status)}`,
|
|
2544
|
-
children: swap.status.replace(/_/g, " ")
|
|
2545
|
-
}
|
|
2546
|
-
)
|
|
2547
|
-
] })
|
|
2548
|
-
] }),
|
|
2549
|
-
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2550
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2551
|
-
Button,
|
|
2552
|
-
{
|
|
2553
|
-
variant: "danger",
|
|
2554
|
-
onClick: handleCancelExchange,
|
|
2555
|
-
disabled: isCancelling,
|
|
2556
|
-
isLoading: isCancelling,
|
|
2557
|
-
children: "Cancel Exchange"
|
|
2558
|
-
}
|
|
2559
|
-
) }),
|
|
2560
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2561
|
-
] }),
|
|
2562
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2563
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2564
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2565
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2533
|
+
}, [id]);
|
|
2534
|
+
const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
|
|
2535
|
+
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;
|
|
2536
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxs(Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
2537
|
+
/* @__PURE__ */ jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2538
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
2539
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
|
|
2540
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
2541
|
+
] }) }),
|
|
2542
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2543
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2544
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
2545
|
+
] }) : loading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2546
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2547
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
2548
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2566
2549
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2567
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2568
|
-
/* @__PURE__ */ jsx(Text, { className: "font-
|
|
2550
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
2551
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
2569
2552
|
] }),
|
|
2570
2553
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2571
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2572
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2554
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2555
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
2573
2556
|
] }),
|
|
2574
2557
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2575
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2576
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2558
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
2559
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
2577
2560
|
] }),
|
|
2578
|
-
|
|
2579
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2580
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2561
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2562
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
2563
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
2564
|
+
year: "numeric",
|
|
2565
|
+
month: "short",
|
|
2566
|
+
day: "numeric",
|
|
2567
|
+
hour: "numeric",
|
|
2568
|
+
minute: "2-digit",
|
|
2569
|
+
hour12: true
|
|
2570
|
+
}) })
|
|
2581
2571
|
] }),
|
|
2582
|
-
|
|
2583
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2584
|
-
/* @__PURE__ */ jsx(Text, { className: "font-
|
|
2572
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2573
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
2574
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
2575
|
+
] }) : null
|
|
2576
|
+
] })
|
|
2577
|
+
] }),
|
|
2578
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2579
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
2580
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2581
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2582
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
2583
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
2585
2584
|
] }),
|
|
2586
2585
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2587
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2588
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2586
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
2587
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
2589
2588
|
] }),
|
|
2590
2589
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2591
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2592
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2590
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
2591
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
2593
2592
|
] }),
|
|
2594
|
-
|
|
2595
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-
|
|
2596
|
-
/* @__PURE__ */ jsx(Text, { className: "
|
|
2597
|
-
] })
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
/* @__PURE__ */
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2593
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2594
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2595
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
2596
|
+
] }),
|
|
2597
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2598
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2599
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2600
|
+
Badge,
|
|
2601
|
+
{
|
|
2602
|
+
size: "2xsmall",
|
|
2603
|
+
className: `uppercase ${getStatusBadgeClass(paymentStatus)}`,
|
|
2604
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
2605
|
+
}
|
|
2606
|
+
) })
|
|
2607
|
+
] }),
|
|
2608
|
+
detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2609
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2610
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
2611
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
2612
|
+
] }),
|
|
2613
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2614
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
2615
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
2616
|
+
] }),
|
|
2617
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2618
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
2619
|
+
/* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
|
|
2620
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
2621
|
+
"%"
|
|
2619
2622
|
] })
|
|
2620
2623
|
] })
|
|
2621
|
-
}
|
|
2622
|
-
index
|
|
2623
|
-
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2624
|
-
] })
|
|
2625
|
-
] }),
|
|
2626
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2627
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2628
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2629
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2630
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2631
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2632
|
-
] }),
|
|
2633
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2634
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2635
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2636
|
-
] }),
|
|
2637
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2638
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2639
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2640
|
-
] }),
|
|
2641
|
-
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2642
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2643
|
-
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2644
|
-
order.currency_code || "$",
|
|
2645
|
-
(Number(order.total) / 100).toFixed(2)
|
|
2646
|
-
] })
|
|
2624
|
+
] }) : null
|
|
2647
2625
|
] })
|
|
2626
|
+
] }),
|
|
2627
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2628
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
2629
|
+
detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2630
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2631
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
2632
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2633
|
+
Button,
|
|
2634
|
+
{
|
|
2635
|
+
variant: "transparent",
|
|
2636
|
+
size: "small",
|
|
2637
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
2638
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
2639
|
+
}
|
|
2640
|
+
) })
|
|
2641
|
+
] }),
|
|
2642
|
+
detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2643
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
2644
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
2645
|
+
] }) : null,
|
|
2646
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2647
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
2648
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
2649
|
+
] }) : null,
|
|
2650
|
+
detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2651
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
2652
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
|
|
2653
|
+
] }) : null,
|
|
2654
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
|
|
2655
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
2656
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
2657
|
+
] }) : null
|
|
2658
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
2659
|
+
] }),
|
|
2660
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2661
|
+
/* @__PURE__ */ jsxs(
|
|
2662
|
+
"button",
|
|
2663
|
+
{
|
|
2664
|
+
type: "button",
|
|
2665
|
+
className: "flex w-full items-center justify-between text-left",
|
|
2666
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
2667
|
+
"aria-expanded": gatewayExpanded,
|
|
2668
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
2669
|
+
children: [
|
|
2670
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
2671
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
2672
|
+
]
|
|
2673
|
+
}
|
|
2674
|
+
),
|
|
2675
|
+
gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ 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__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
2648
2676
|
] })
|
|
2649
|
-
] })
|
|
2650
|
-
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2651
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2652
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2653
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2654
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
2655
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2656
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2657
|
-
] }) }),
|
|
2658
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2659
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2660
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2661
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2662
|
-
] }, item.id || index)) })
|
|
2663
|
-
] }) })
|
|
2664
|
-
] }),
|
|
2665
|
-
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2666
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2667
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2668
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2669
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2670
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2671
|
-
] }) }),
|
|
2672
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2673
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2674
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2675
|
-
] }, item.variant_id || index)) })
|
|
2676
|
-
] }) })
|
|
2677
|
-
] })
|
|
2677
|
+
] }) : null
|
|
2678
2678
|
] }) });
|
|
2679
2679
|
};
|
|
2680
2680
|
const config = defineRouteConfig({
|
|
2681
|
-
label: "
|
|
2682
|
-
icon:
|
|
2681
|
+
label: "Refund details",
|
|
2682
|
+
icon: Receipt
|
|
2683
2683
|
});
|
|
2684
2684
|
const i18nTranslations0 = {};
|
|
2685
2685
|
const widgetModule = { widgets: [
|
|
@@ -2698,6 +2698,10 @@ const routeModule = {
|
|
|
2698
2698
|
Component: PaymentsPage,
|
|
2699
2699
|
path: "/payments"
|
|
2700
2700
|
},
|
|
2701
|
+
{
|
|
2702
|
+
Component: SwapsPage,
|
|
2703
|
+
path: "/swaps"
|
|
2704
|
+
},
|
|
2701
2705
|
{
|
|
2702
2706
|
Component: RefundsPage,
|
|
2703
2707
|
path: "/refunds"
|
|
@@ -2706,46 +2710,36 @@ const routeModule = {
|
|
|
2706
2710
|
Component: ReturnsPage,
|
|
2707
2711
|
path: "/returns"
|
|
2708
2712
|
},
|
|
2709
|
-
{
|
|
2710
|
-
Component: SwapsPage,
|
|
2711
|
-
path: "/swaps"
|
|
2712
|
-
},
|
|
2713
2713
|
{
|
|
2714
2714
|
Component: PaymentDetailPage,
|
|
2715
2715
|
path: "/payments/:id"
|
|
2716
2716
|
},
|
|
2717
2717
|
{
|
|
2718
|
-
Component:
|
|
2719
|
-
path: "/
|
|
2718
|
+
Component: SwapDetailPage,
|
|
2719
|
+
path: "/swaps/:id"
|
|
2720
2720
|
},
|
|
2721
2721
|
{
|
|
2722
2722
|
Component: ReturnDetailPage,
|
|
2723
2723
|
path: "/returns/:id"
|
|
2724
2724
|
},
|
|
2725
2725
|
{
|
|
2726
|
-
Component:
|
|
2727
|
-
path: "/
|
|
2726
|
+
Component: RefundDetailPage,
|
|
2727
|
+
path: "/refunds/:id"
|
|
2728
2728
|
}
|
|
2729
2729
|
]
|
|
2730
2730
|
};
|
|
2731
2731
|
const menuItemModule = {
|
|
2732
2732
|
menuItems: [
|
|
2733
2733
|
{
|
|
2734
|
-
label: config$
|
|
2735
|
-
icon: config$
|
|
2736
|
-
path: "/
|
|
2734
|
+
label: config$4.label,
|
|
2735
|
+
icon: config$4.icon,
|
|
2736
|
+
path: "/returns",
|
|
2737
2737
|
nested: void 0
|
|
2738
2738
|
},
|
|
2739
2739
|
{
|
|
2740
2740
|
label: config$5.label,
|
|
2741
2741
|
icon: config$5.icon,
|
|
2742
|
-
path: "/
|
|
2743
|
-
nested: void 0
|
|
2744
|
-
},
|
|
2745
|
-
{
|
|
2746
|
-
label: config$4.label,
|
|
2747
|
-
icon: config$4.icon,
|
|
2748
|
-
path: "/swaps",
|
|
2742
|
+
path: "/refunds",
|
|
2749
2743
|
nested: void 0
|
|
2750
2744
|
},
|
|
2751
2745
|
{
|
|
@@ -2755,9 +2749,9 @@ const menuItemModule = {
|
|
|
2755
2749
|
nested: void 0
|
|
2756
2750
|
},
|
|
2757
2751
|
{
|
|
2758
|
-
label: config$
|
|
2759
|
-
icon: config$
|
|
2760
|
-
path: "/
|
|
2752
|
+
label: config$6.label,
|
|
2753
|
+
icon: config$6.icon,
|
|
2754
|
+
path: "/swaps",
|
|
2761
2755
|
nested: void 0
|
|
2762
2756
|
},
|
|
2763
2757
|
{
|
|
@@ -2769,7 +2763,7 @@ const menuItemModule = {
|
|
|
2769
2763
|
{
|
|
2770
2764
|
label: config.label,
|
|
2771
2765
|
icon: config.icon,
|
|
2772
|
-
path: "/
|
|
2766
|
+
path: "/refunds/:id",
|
|
2773
2767
|
nested: void 0
|
|
2774
2768
|
},
|
|
2775
2769
|
{
|
|
@@ -2777,6 +2771,12 @@ const menuItemModule = {
|
|
|
2777
2771
|
icon: config$3.icon,
|
|
2778
2772
|
path: "/payments/:id",
|
|
2779
2773
|
nested: void 0
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
label: config$2.label,
|
|
2777
|
+
icon: config$2.icon,
|
|
2778
|
+
path: "/swaps/:id",
|
|
2779
|
+
nested: void 0
|
|
2780
2780
|
}
|
|
2781
2781
|
]
|
|
2782
2782
|
};
|