order-management 0.0.76 → 0.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +600 -600
- package/.medusa/server/src/admin/index.mjs +601 -601
- package/.medusa/server/src/config.js +2 -1
- package/.medusa/server/src/subscribers/order-fulfilled.js +260 -1
- package/.medusa/server/src/workflows/steps/send-notification-step.js +1 -35
- package/README.md +7 -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, Receipt, CreditCard,
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, Receipt, ArrowPath, CreditCard, 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();
|
|
@@ -1160,144 +1160,188 @@ const useDebounce$2 = (value, delay) => {
|
|
|
1160
1160
|
return debouncedValue;
|
|
1161
1161
|
};
|
|
1162
1162
|
const getStatusBadgeClass$6 = (status) => {
|
|
1163
|
-
const
|
|
1164
|
-
if (
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
if (
|
|
1163
|
+
const statusLower = status.toLowerCase();
|
|
1164
|
+
if (statusLower === "requested") {
|
|
1165
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1166
|
+
}
|
|
1167
|
+
if (statusLower === "approved") {
|
|
1168
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1169
|
+
}
|
|
1170
|
+
if (statusLower === "rejected") {
|
|
1171
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1172
|
+
}
|
|
1173
|
+
if (statusLower === "completed") {
|
|
1174
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1175
|
+
}
|
|
1176
|
+
if (statusLower === "cancelled") {
|
|
1177
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
1178
|
+
}
|
|
1168
1179
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1169
1180
|
};
|
|
1170
|
-
const
|
|
1181
|
+
const SwapsPage = () => {
|
|
1171
1182
|
const navigate = useNavigate();
|
|
1172
1183
|
const [items, setItems] = useState([]);
|
|
1173
1184
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1174
|
-
const [
|
|
1175
|
-
const
|
|
1185
|
+
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1186
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
1187
|
+
const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
|
|
1176
1188
|
const [isLoading, setIsLoading] = useState(true);
|
|
1177
1189
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1178
1190
|
const [error, setError] = useState(null);
|
|
1179
1191
|
const [offset, setOffset] = useState(0);
|
|
1180
1192
|
const [count, setCount] = useState(0);
|
|
1181
1193
|
const limit = 50;
|
|
1182
|
-
const
|
|
1183
|
-
async (nextOffset, replace) => {
|
|
1194
|
+
const loadSwaps = useCallback(
|
|
1195
|
+
async (nextOffset, replace = false) => {
|
|
1196
|
+
var _a;
|
|
1184
1197
|
try {
|
|
1185
|
-
if (replace)
|
|
1186
|
-
|
|
1198
|
+
if (replace) {
|
|
1199
|
+
setIsLoading(true);
|
|
1200
|
+
} else {
|
|
1201
|
+
setIsFetchingMore(true);
|
|
1202
|
+
}
|
|
1187
1203
|
setError(null);
|
|
1188
1204
|
const params = new URLSearchParams();
|
|
1189
1205
|
params.set("limit", String(limit));
|
|
1190
1206
|
params.set("offset", String(nextOffset));
|
|
1191
|
-
if (statusFilter !== "all")
|
|
1192
|
-
|
|
1207
|
+
if (statusFilter !== "all") {
|
|
1208
|
+
params.set("status", statusFilter);
|
|
1209
|
+
}
|
|
1210
|
+
if (debouncedSearchQuery.trim()) {
|
|
1211
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
1212
|
+
}
|
|
1213
|
+
if (createdByFilter !== "all") {
|
|
1214
|
+
params.set("created_by", createdByFilter);
|
|
1215
|
+
}
|
|
1193
1216
|
const response = await fetch(
|
|
1194
|
-
`/admin/
|
|
1217
|
+
`/admin/swaps?${params.toString()}`,
|
|
1195
1218
|
{ credentials: "include" }
|
|
1196
1219
|
);
|
|
1197
1220
|
if (!response.ok) {
|
|
1198
|
-
const
|
|
1199
|
-
throw new Error(
|
|
1221
|
+
const message = await response.text();
|
|
1222
|
+
throw new Error(message || "Unable to load swaps");
|
|
1200
1223
|
}
|
|
1201
1224
|
const payload = await response.json();
|
|
1202
|
-
const list = payload.transactions ?? [];
|
|
1203
1225
|
setCount(payload.count ?? 0);
|
|
1204
|
-
setOffset(nextOffset +
|
|
1205
|
-
setItems(
|
|
1206
|
-
|
|
1207
|
-
|
|
1226
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
1227
|
+
setItems(
|
|
1228
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
1229
|
+
);
|
|
1230
|
+
} catch (loadError) {
|
|
1231
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1232
|
+
setError(message);
|
|
1208
1233
|
} finally {
|
|
1209
1234
|
setIsLoading(false);
|
|
1210
1235
|
setIsFetchingMore(false);
|
|
1211
1236
|
}
|
|
1212
1237
|
},
|
|
1213
|
-
[statusFilter,
|
|
1238
|
+
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
1214
1239
|
);
|
|
1215
1240
|
useEffect(() => {
|
|
1216
|
-
void
|
|
1217
|
-
}, [
|
|
1241
|
+
void loadSwaps(0, true);
|
|
1242
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadSwaps]);
|
|
1218
1243
|
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1219
|
-
const
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1225
|
-
return `${code} ${Number(t.amount)}`;
|
|
1226
|
-
};
|
|
1244
|
+
const availableStatuses = useMemo(() => {
|
|
1245
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
1246
|
+
items.forEach((item) => statuses.add(item.status));
|
|
1247
|
+
return Array.from(statuses).sort();
|
|
1248
|
+
}, [items]);
|
|
1227
1249
|
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: [
|
|
1228
1250
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1229
1251
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1230
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
1231
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1252
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchanges" }),
|
|
1253
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer exchange requests" })
|
|
1232
1254
|
] }),
|
|
1233
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () =>
|
|
1255
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
1234
1256
|
] }),
|
|
1235
1257
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1236
1258
|
/* @__PURE__ */ jsx(
|
|
1237
1259
|
Input,
|
|
1238
1260
|
{
|
|
1239
|
-
placeholder: "Search by
|
|
1240
|
-
value:
|
|
1241
|
-
onChange: (
|
|
1242
|
-
className: "md:max-w-sm"
|
|
1243
|
-
"aria-label": "Search by order ID"
|
|
1261
|
+
placeholder: "Search by swap ID or order ID",
|
|
1262
|
+
value: searchQuery,
|
|
1263
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
1264
|
+
className: "md:max-w-sm"
|
|
1244
1265
|
}
|
|
1245
1266
|
),
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1267
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1268
|
+
/* @__PURE__ */ jsxs(
|
|
1269
|
+
"select",
|
|
1270
|
+
{
|
|
1271
|
+
value: createdByFilter,
|
|
1272
|
+
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
1273
|
+
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",
|
|
1274
|
+
children: [
|
|
1275
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All (Created by)" }),
|
|
1276
|
+
/* @__PURE__ */ jsx("option", { value: "customer", children: "Customer" }),
|
|
1277
|
+
/* @__PURE__ */ jsx("option", { value: "admin", children: "Admin" })
|
|
1278
|
+
]
|
|
1279
|
+
}
|
|
1280
|
+
),
|
|
1281
|
+
/* @__PURE__ */ jsxs(
|
|
1282
|
+
"select",
|
|
1283
|
+
{
|
|
1284
|
+
value: statusFilter,
|
|
1285
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
1286
|
+
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",
|
|
1287
|
+
children: [
|
|
1288
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All Statuses" }),
|
|
1289
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
)
|
|
1293
|
+
] })
|
|
1264
1294
|
] }),
|
|
1265
1295
|
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1266
1296
|
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1267
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1297
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1298
|
+
Button,
|
|
1299
|
+
{
|
|
1300
|
+
variant: "secondary",
|
|
1301
|
+
onClick: () => loadSwaps(0, true),
|
|
1302
|
+
children: "Try again"
|
|
1303
|
+
}
|
|
1304
|
+
) })
|
|
1268
1305
|
] }) : null,
|
|
1269
|
-
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading
|
|
1270
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No
|
|
1271
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
1306
|
+
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: [
|
|
1307
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No exchanges yet" }),
|
|
1308
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Exchange requests created by customers will appear here." })
|
|
1272
1309
|
] }) : /* @__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: [
|
|
1273
1310
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1311
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Exchange ID" }),
|
|
1274
1312
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1275
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1276
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1277
1313
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1278
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "
|
|
1314
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
1279
1315
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1280
1316
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1281
1317
|
] }) }),
|
|
1282
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1318
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxs(
|
|
1283
1319
|
"tr",
|
|
1284
1320
|
{
|
|
1285
1321
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1286
|
-
onClick: () => navigate(`/
|
|
1322
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
1287
1323
|
children: [
|
|
1288
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children:
|
|
1289
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1290
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1324
|
+
/* @__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 }) }) }),
|
|
1325
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
1291
1326
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1292
1327
|
Badge,
|
|
1293
1328
|
{
|
|
1294
1329
|
size: "2xsmall",
|
|
1295
|
-
className: `uppercase ${getStatusBadgeClass$6(
|
|
1296
|
-
children:
|
|
1330
|
+
className: `uppercase ${getStatusBadgeClass$6(swap.status)}`,
|
|
1331
|
+
children: swap.status.replace(/_/g, " ")
|
|
1297
1332
|
}
|
|
1298
1333
|
) }),
|
|
1299
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1300
|
-
|
|
1334
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
1335
|
+
const amount = swap.difference_due;
|
|
1336
|
+
if (amount == null || amount === void 0) {
|
|
1337
|
+
return "—";
|
|
1338
|
+
}
|
|
1339
|
+
const displayAmount = Number(amount) / 100;
|
|
1340
|
+
const currency = swap.currency_code || "$";
|
|
1341
|
+
const sign = displayAmount >= 0 ? "+" : "";
|
|
1342
|
+
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
1343
|
+
})() }),
|
|
1344
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
1301
1345
|
year: "numeric",
|
|
1302
1346
|
month: "short",
|
|
1303
1347
|
day: "numeric",
|
|
@@ -1305,35 +1349,21 @@ const PaymentsPage = () => {
|
|
|
1305
1349
|
minute: "2-digit",
|
|
1306
1350
|
hour12: true
|
|
1307
1351
|
}) }),
|
|
1308
|
-
/* @__PURE__ */
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
),
|
|
1321
|
-
t.order_id ? /* @__PURE__ */ jsx(
|
|
1322
|
-
Button,
|
|
1323
|
-
{
|
|
1324
|
-
variant: "transparent",
|
|
1325
|
-
size: "small",
|
|
1326
|
-
onClick: (e) => {
|
|
1327
|
-
e.stopPropagation();
|
|
1328
|
-
navigate(`/orders/${t.order_id}`);
|
|
1329
|
-
},
|
|
1330
|
-
children: "Order"
|
|
1331
|
-
}
|
|
1332
|
-
) : null
|
|
1333
|
-
] })
|
|
1352
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1353
|
+
Button,
|
|
1354
|
+
{
|
|
1355
|
+
variant: "transparent",
|
|
1356
|
+
size: "small",
|
|
1357
|
+
onClick: (e) => {
|
|
1358
|
+
e.stopPropagation();
|
|
1359
|
+
navigate(`/app/orders/${swap.order_id}`);
|
|
1360
|
+
},
|
|
1361
|
+
children: "Go to order"
|
|
1362
|
+
}
|
|
1363
|
+
) })
|
|
1334
1364
|
]
|
|
1335
1365
|
},
|
|
1336
|
-
|
|
1366
|
+
swap.id
|
|
1337
1367
|
)) })
|
|
1338
1368
|
] }) }),
|
|
1339
1369
|
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
@@ -1341,15 +1371,15 @@ const PaymentsPage = () => {
|
|
|
1341
1371
|
{
|
|
1342
1372
|
variant: "secondary",
|
|
1343
1373
|
isLoading: isFetchingMore,
|
|
1344
|
-
onClick: () =>
|
|
1374
|
+
onClick: () => loadSwaps(offset, false),
|
|
1345
1375
|
children: "Load more"
|
|
1346
1376
|
}
|
|
1347
1377
|
) }) : null
|
|
1348
1378
|
] }) });
|
|
1349
1379
|
};
|
|
1350
1380
|
const config$6 = defineRouteConfig({
|
|
1351
|
-
label: "
|
|
1352
|
-
icon:
|
|
1381
|
+
label: "Exchanges",
|
|
1382
|
+
icon: ArrowPath
|
|
1353
1383
|
});
|
|
1354
1384
|
const useDebounce$1 = (value, delay) => {
|
|
1355
1385
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
@@ -1592,188 +1622,144 @@ const useDebounce = (value, delay) => {
|
|
|
1592
1622
|
return debouncedValue;
|
|
1593
1623
|
};
|
|
1594
1624
|
const getStatusBadgeClass$4 = (status) => {
|
|
1595
|
-
const
|
|
1596
|
-
if (
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
if (
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
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();
|
|
1625
|
+
const s2 = status.toLowerCase();
|
|
1626
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1627
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1628
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1629
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1630
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1631
|
+
};
|
|
1632
|
+
const PaymentsPage = () => {
|
|
1633
|
+
const navigate = useNavigate();
|
|
1615
1634
|
const [items, setItems] = useState([]);
|
|
1616
1635
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1617
|
-
const [
|
|
1618
|
-
const
|
|
1619
|
-
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1636
|
+
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1637
|
+
const debouncedOrderId = useDebounce(orderIdSearch, 300);
|
|
1620
1638
|
const [isLoading, setIsLoading] = useState(true);
|
|
1621
1639
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1622
1640
|
const [error, setError] = useState(null);
|
|
1623
1641
|
const [offset, setOffset] = useState(0);
|
|
1624
1642
|
const [count, setCount] = useState(0);
|
|
1625
1643
|
const limit = 50;
|
|
1626
|
-
const
|
|
1627
|
-
async (nextOffset, replace
|
|
1628
|
-
var _a;
|
|
1644
|
+
const loadTransactions = useCallback(
|
|
1645
|
+
async (nextOffset, replace) => {
|
|
1629
1646
|
try {
|
|
1630
|
-
if (replace)
|
|
1631
|
-
|
|
1632
|
-
} else {
|
|
1633
|
-
setIsFetchingMore(true);
|
|
1634
|
-
}
|
|
1647
|
+
if (replace) setIsLoading(true);
|
|
1648
|
+
else setIsFetchingMore(true);
|
|
1635
1649
|
setError(null);
|
|
1636
1650
|
const params = new URLSearchParams();
|
|
1637
1651
|
params.set("limit", String(limit));
|
|
1638
1652
|
params.set("offset", String(nextOffset));
|
|
1639
|
-
if (statusFilter !== "all")
|
|
1640
|
-
|
|
1641
|
-
}
|
|
1642
|
-
if (debouncedSearchQuery.trim()) {
|
|
1643
|
-
params.set("order_id", debouncedSearchQuery.trim());
|
|
1644
|
-
}
|
|
1645
|
-
if (createdByFilter !== "all") {
|
|
1646
|
-
params.set("created_by", createdByFilter);
|
|
1647
|
-
}
|
|
1653
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
1654
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
1648
1655
|
const response = await fetch(
|
|
1649
|
-
`/admin/
|
|
1656
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
1650
1657
|
{ credentials: "include" }
|
|
1651
1658
|
);
|
|
1652
1659
|
if (!response.ok) {
|
|
1653
|
-
const
|
|
1654
|
-
throw new Error(
|
|
1660
|
+
const text = await response.text();
|
|
1661
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
1655
1662
|
}
|
|
1656
1663
|
const payload = await response.json();
|
|
1664
|
+
const list = payload.transactions ?? [];
|
|
1657
1665
|
setCount(payload.count ?? 0);
|
|
1658
|
-
setOffset(nextOffset +
|
|
1659
|
-
setItems(
|
|
1660
|
-
|
|
1661
|
-
);
|
|
1662
|
-
} catch (loadError) {
|
|
1663
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
1664
|
-
setError(message);
|
|
1666
|
+
setOffset(nextOffset + list.length);
|
|
1667
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
1668
|
+
} catch (e) {
|
|
1669
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
1665
1670
|
} finally {
|
|
1666
1671
|
setIsLoading(false);
|
|
1667
1672
|
setIsFetchingMore(false);
|
|
1668
1673
|
}
|
|
1669
1674
|
},
|
|
1670
|
-
[statusFilter,
|
|
1675
|
+
[statusFilter, debouncedOrderId]
|
|
1671
1676
|
);
|
|
1672
1677
|
useEffect(() => {
|
|
1673
|
-
void
|
|
1674
|
-
}, [
|
|
1678
|
+
void loadTransactions(0, true);
|
|
1679
|
+
}, [loadTransactions]);
|
|
1675
1680
|
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1676
|
-
const
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
+
const displayStatus = (t) => {
|
|
1682
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
1683
|
+
return s2 !== "" ? s2 : "—";
|
|
1684
|
+
};
|
|
1685
|
+
const displayAmount = (t) => {
|
|
1686
|
+
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1687
|
+
return `${code} ${Number(t.amount)}`;
|
|
1688
|
+
};
|
|
1681
1689
|
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
1690
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1683
1691
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1684
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
1685
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1692
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
1693
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
1686
1694
|
] }),
|
|
1687
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () =>
|
|
1695
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
1688
1696
|
] }),
|
|
1689
1697
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1690
1698
|
/* @__PURE__ */ jsx(
|
|
1691
1699
|
Input,
|
|
1692
1700
|
{
|
|
1693
|
-
placeholder: "Search by
|
|
1694
|
-
value:
|
|
1695
|
-
onChange: (
|
|
1696
|
-
className: "md:max-w-sm"
|
|
1701
|
+
placeholder: "Search by Order ID",
|
|
1702
|
+
value: orderIdSearch,
|
|
1703
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
1704
|
+
className: "md:max-w-sm",
|
|
1705
|
+
"aria-label": "Search by order ID"
|
|
1697
1706
|
}
|
|
1698
1707
|
),
|
|
1699
|
-
/* @__PURE__ */
|
|
1700
|
-
|
|
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,
|
|
1708
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
1709
|
+
"select",
|
|
1731
1710
|
{
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1711
|
+
value: statusFilter,
|
|
1712
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
1713
|
+
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",
|
|
1714
|
+
"aria-label": "Filter by status",
|
|
1715
|
+
children: [
|
|
1716
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1717
|
+
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1718
|
+
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1719
|
+
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1720
|
+
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1721
|
+
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1722
|
+
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1723
|
+
]
|
|
1735
1724
|
}
|
|
1736
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(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
1737
1730
|
] }) : null,
|
|
1738
|
-
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading
|
|
1739
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No
|
|
1740
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
1731
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
1732
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
1733
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
1741
1734
|
] }) : /* @__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
1735
|
/* @__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
1736
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1737
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1738
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1745
1739
|
/* @__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: "
|
|
1740
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
1747
1741
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1748
1742
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1749
1743
|
] }) }),
|
|
1750
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((
|
|
1744
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
1751
1745
|
"tr",
|
|
1752
1746
|
{
|
|
1753
1747
|
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1754
|
-
onClick: () => navigate(`/
|
|
1748
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1755
1749
|
children: [
|
|
1756
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children:
|
|
1757
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1750
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
1751
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
1752
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1758
1753
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1759
1754
|
Badge,
|
|
1760
1755
|
{
|
|
1761
1756
|
size: "2xsmall",
|
|
1762
|
-
className: `uppercase ${getStatusBadgeClass$4(
|
|
1763
|
-
children:
|
|
1757
|
+
className: `uppercase ${getStatusBadgeClass$4(displayStatus(t))}`,
|
|
1758
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1764
1759
|
}
|
|
1765
1760
|
) }),
|
|
1766
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
1767
|
-
|
|
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", {
|
|
1761
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1762
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1777
1763
|
year: "numeric",
|
|
1778
1764
|
month: "short",
|
|
1779
1765
|
day: "numeric",
|
|
@@ -1781,21 +1767,35 @@ const SwapsPage = () => {
|
|
|
1781
1767
|
minute: "2-digit",
|
|
1782
1768
|
hour12: true
|
|
1783
1769
|
}) }),
|
|
1784
|
-
/* @__PURE__ */
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
e
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1770
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
1771
|
+
/* @__PURE__ */ jsx(
|
|
1772
|
+
Button,
|
|
1773
|
+
{
|
|
1774
|
+
variant: "transparent",
|
|
1775
|
+
size: "small",
|
|
1776
|
+
onClick: (e) => {
|
|
1777
|
+
e.stopPropagation();
|
|
1778
|
+
navigate(`/payments/${t.payment_session_id}`);
|
|
1779
|
+
},
|
|
1780
|
+
children: "View details"
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
t.order_id ? /* @__PURE__ */ jsx(
|
|
1784
|
+
Button,
|
|
1785
|
+
{
|
|
1786
|
+
variant: "transparent",
|
|
1787
|
+
size: "small",
|
|
1788
|
+
onClick: (e) => {
|
|
1789
|
+
e.stopPropagation();
|
|
1790
|
+
navigate(`/orders/${t.order_id}`);
|
|
1791
|
+
},
|
|
1792
|
+
children: "Order"
|
|
1793
|
+
}
|
|
1794
|
+
) : null
|
|
1795
|
+
] })
|
|
1796
1796
|
]
|
|
1797
1797
|
},
|
|
1798
|
-
|
|
1798
|
+
t.payment_session_id
|
|
1799
1799
|
)) })
|
|
1800
1800
|
] }) }),
|
|
1801
1801
|
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
@@ -1803,15 +1803,15 @@ const SwapsPage = () => {
|
|
|
1803
1803
|
{
|
|
1804
1804
|
variant: "secondary",
|
|
1805
1805
|
isLoading: isFetchingMore,
|
|
1806
|
-
onClick: () =>
|
|
1806
|
+
onClick: () => loadTransactions(offset, false),
|
|
1807
1807
|
children: "Load more"
|
|
1808
1808
|
}
|
|
1809
1809
|
) }) : null
|
|
1810
1810
|
] }) });
|
|
1811
1811
|
};
|
|
1812
1812
|
const config$4 = defineRouteConfig({
|
|
1813
|
-
label: "
|
|
1814
|
-
icon:
|
|
1813
|
+
label: "Payments",
|
|
1814
|
+
icon: CreditCard
|
|
1815
1815
|
});
|
|
1816
1816
|
const getStatusBadgeClass$3 = (status) => {
|
|
1817
1817
|
const s2 = status.toLowerCase();
|
|
@@ -2006,234 +2006,119 @@ const config$3 = defineRouteConfig({
|
|
|
2006
2006
|
icon: Receipt
|
|
2007
2007
|
});
|
|
2008
2008
|
const getStatusBadgeClass$2 = (status) => {
|
|
2009
|
-
const
|
|
2010
|
-
if (
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
if (
|
|
2009
|
+
const statusLower = status.toLowerCase();
|
|
2010
|
+
if (statusLower === "requested") {
|
|
2011
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2012
|
+
}
|
|
2013
|
+
if (statusLower === "approved") {
|
|
2014
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2015
|
+
}
|
|
2016
|
+
if (statusLower === "rejected") {
|
|
2017
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2018
|
+
}
|
|
2019
|
+
if (statusLower === "completed") {
|
|
2020
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2021
|
+
}
|
|
2022
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2023
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2024
|
+
}
|
|
2025
|
+
if (statusLower === "pending") {
|
|
2026
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2027
|
+
}
|
|
2014
2028
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2015
2029
|
};
|
|
2016
|
-
const
|
|
2017
|
-
var _a;
|
|
2018
|
-
const navigate = useNavigate();
|
|
2019
|
-
const params = useParams();
|
|
2020
|
-
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2021
|
-
const [detail, setDetail] = useState(null);
|
|
2022
|
-
const [loading, setLoading] = useState(!!id);
|
|
2023
|
-
const [error, setError] = useState(null);
|
|
2024
|
-
useEffect(() => {
|
|
2025
|
-
if (!id) {
|
|
2026
|
-
setLoading(false);
|
|
2027
|
-
return;
|
|
2028
|
-
}
|
|
2029
|
-
let cancelled = false;
|
|
2030
|
-
setLoading(true);
|
|
2031
|
-
setError(null);
|
|
2032
|
-
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
2033
|
-
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2034
|
-
return res.json();
|
|
2035
|
-
}).then((data) => {
|
|
2036
|
-
if (!cancelled) setDetail(data);
|
|
2037
|
-
}).catch((e) => {
|
|
2038
|
-
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2039
|
-
}).finally(() => {
|
|
2040
|
-
if (!cancelled) setLoading(false);
|
|
2041
|
-
});
|
|
2042
|
-
return () => {
|
|
2043
|
-
cancelled = true;
|
|
2044
|
-
};
|
|
2045
|
-
}, [id]);
|
|
2046
|
-
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
2047
|
-
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
2048
|
-
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
2049
|
-
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
2050
|
-
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: [
|
|
2051
|
-
/* @__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: [
|
|
2052
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
2053
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
|
|
2054
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
2055
|
-
] }) }),
|
|
2056
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2057
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2058
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
|
|
2059
|
-
] }) : 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: [
|
|
2060
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2061
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2062
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
|
|
2063
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsx(
|
|
2064
|
-
Button,
|
|
2065
|
-
{
|
|
2066
|
-
variant: "transparent",
|
|
2067
|
-
size: "small",
|
|
2068
|
-
onClick: () => navigate(`/orders/${detail.order_id}`),
|
|
2069
|
-
children: detail.order_id
|
|
2070
|
-
}
|
|
2071
|
-
) : /* @__PURE__ */ jsx(Text, { children: "—" }) })
|
|
2072
|
-
] }),
|
|
2073
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2074
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2075
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: displayAmount })
|
|
2076
|
-
] }),
|
|
2077
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2078
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2079
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.provider_id })
|
|
2080
|
-
] }),
|
|
2081
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2082
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2083
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2084
|
-
Badge,
|
|
2085
|
-
{
|
|
2086
|
-
size: "2xsmall",
|
|
2087
|
-
className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
|
|
2088
|
-
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
2089
|
-
}
|
|
2090
|
-
) })
|
|
2091
|
-
] }),
|
|
2092
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2093
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
2094
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
2095
|
-
] }),
|
|
2096
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2097
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
2098
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
2099
|
-
] }),
|
|
2100
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2101
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
2102
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
2103
|
-
] }),
|
|
2104
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2105
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
2106
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
2107
|
-
year: "numeric",
|
|
2108
|
-
month: "short",
|
|
2109
|
-
day: "numeric",
|
|
2110
|
-
hour: "numeric",
|
|
2111
|
-
minute: "2-digit",
|
|
2112
|
-
hour12: true
|
|
2113
|
-
}) })
|
|
2114
|
-
] })
|
|
2115
|
-
] }) }),
|
|
2116
|
-
Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2117
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
|
|
2118
|
-
/* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
|
|
2119
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
|
|
2120
|
-
] }) : null
|
|
2121
|
-
] }) });
|
|
2122
|
-
};
|
|
2123
|
-
const config$2 = defineRouteConfig({
|
|
2124
|
-
label: "Payment details",
|
|
2125
|
-
icon: CreditCard
|
|
2126
|
-
});
|
|
2127
|
-
const getStatusBadgeClass$1 = (status) => {
|
|
2128
|
-
const statusLower = status.toLowerCase();
|
|
2129
|
-
if (statusLower === "requested") {
|
|
2130
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2131
|
-
}
|
|
2132
|
-
if (statusLower === "approved") {
|
|
2133
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2134
|
-
}
|
|
2135
|
-
if (statusLower === "rejected") {
|
|
2136
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2137
|
-
}
|
|
2138
|
-
if (statusLower === "received") {
|
|
2139
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2140
|
-
}
|
|
2141
|
-
if (statusLower === "refunded") {
|
|
2142
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2143
|
-
}
|
|
2144
|
-
if (statusLower === "completed") {
|
|
2145
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2146
|
-
}
|
|
2147
|
-
if (statusLower === "cancelled") {
|
|
2148
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2149
|
-
}
|
|
2150
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2151
|
-
};
|
|
2152
|
-
const ReturnDetailPage = () => {
|
|
2153
|
-
var _a, _b;
|
|
2030
|
+
const SwapDetailPage = () => {
|
|
2031
|
+
var _a, _b, _c;
|
|
2154
2032
|
const navigate = useNavigate();
|
|
2155
2033
|
const { id } = useParams();
|
|
2156
|
-
const [
|
|
2034
|
+
const [swap, setSwap] = useState(null);
|
|
2035
|
+
const [order, setOrder] = useState(null);
|
|
2157
2036
|
const [isLoading, setIsLoading] = useState(true);
|
|
2158
|
-
|
|
2037
|
+
useState(false);
|
|
2038
|
+
const [isCancelling, setIsCancelling] = useState(false);
|
|
2159
2039
|
const [error, setError] = useState(null);
|
|
2160
2040
|
const [updateError, setUpdateError] = useState(null);
|
|
2161
2041
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2162
2042
|
useEffect(() => {
|
|
2163
2043
|
if (!id) {
|
|
2164
|
-
navigate("/
|
|
2044
|
+
navigate("/swaps");
|
|
2165
2045
|
return;
|
|
2166
2046
|
}
|
|
2167
|
-
const
|
|
2047
|
+
const loadSwap = async () => {
|
|
2168
2048
|
try {
|
|
2169
2049
|
setIsLoading(true);
|
|
2170
2050
|
setError(null);
|
|
2171
|
-
const response = await fetch(`/admin/
|
|
2051
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2172
2052
|
credentials: "include"
|
|
2173
2053
|
});
|
|
2174
2054
|
if (!response.ok) {
|
|
2175
2055
|
const message = await response.text();
|
|
2176
|
-
throw new Error(message || "Unable to load
|
|
2056
|
+
throw new Error(message || "Unable to load swap");
|
|
2177
2057
|
}
|
|
2178
2058
|
const payload = await response.json();
|
|
2179
|
-
|
|
2059
|
+
setSwap(payload.swap);
|
|
2060
|
+
setOrder(payload.order || null);
|
|
2180
2061
|
} catch (loadError) {
|
|
2181
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2062
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2182
2063
|
setError(message);
|
|
2183
2064
|
} finally {
|
|
2184
2065
|
setIsLoading(false);
|
|
2185
2066
|
}
|
|
2186
2067
|
};
|
|
2187
|
-
void
|
|
2068
|
+
void loadSwap();
|
|
2188
2069
|
}, [id, navigate]);
|
|
2189
|
-
const
|
|
2070
|
+
const handleCancelExchange = async () => {
|
|
2190
2071
|
if (!id) {
|
|
2191
2072
|
return;
|
|
2192
2073
|
}
|
|
2193
2074
|
try {
|
|
2194
|
-
|
|
2075
|
+
setIsCancelling(true);
|
|
2195
2076
|
setUpdateError(null);
|
|
2196
2077
|
setUpdateSuccess(false);
|
|
2197
|
-
const response = await fetch(`/admin/
|
|
2078
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2198
2079
|
method: "POST",
|
|
2199
2080
|
headers: {
|
|
2200
2081
|
"Content-Type": "application/json"
|
|
2201
2082
|
},
|
|
2202
|
-
credentials: "include"
|
|
2203
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2083
|
+
credentials: "include"
|
|
2204
2084
|
});
|
|
2205
2085
|
if (!response.ok) {
|
|
2206
2086
|
const message = await response.text();
|
|
2207
|
-
throw new Error(message || "Unable to
|
|
2087
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2208
2088
|
}
|
|
2209
2089
|
const payload = await response.json();
|
|
2210
|
-
|
|
2090
|
+
setSwap(payload.swap);
|
|
2211
2091
|
setUpdateSuccess(true);
|
|
2212
2092
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2213
|
-
const detailResponse = await fetch(`/admin/
|
|
2093
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2214
2094
|
credentials: "include"
|
|
2215
2095
|
});
|
|
2216
2096
|
if (detailResponse.ok) {
|
|
2217
2097
|
const detailPayload = await detailResponse.json();
|
|
2218
|
-
|
|
2098
|
+
setSwap(detailPayload.swap);
|
|
2099
|
+
setOrder(detailPayload.order || null);
|
|
2219
2100
|
}
|
|
2220
|
-
} catch (
|
|
2221
|
-
const message =
|
|
2101
|
+
} catch (cancelErr) {
|
|
2102
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2222
2103
|
setUpdateError(message);
|
|
2223
2104
|
} finally {
|
|
2224
|
-
|
|
2105
|
+
setIsCancelling(false);
|
|
2225
2106
|
}
|
|
2226
2107
|
};
|
|
2108
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2109
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2110
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2111
|
+
);
|
|
2227
2112
|
if (isLoading) {
|
|
2228
|
-
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
|
|
2113
|
+
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..." }) }) }) });
|
|
2229
2114
|
}
|
|
2230
|
-
if (error || !
|
|
2115
|
+
if (error || !swap) {
|
|
2231
2116
|
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: [
|
|
2232
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2233
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
2117
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2118
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2234
2119
|
] }) }) });
|
|
2235
2120
|
}
|
|
2236
|
-
const statusHistory = ((
|
|
2121
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2237
2122
|
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: [
|
|
2238
2123
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2239
2124
|
/* @__PURE__ */ jsxs(
|
|
@@ -2241,7 +2126,7 @@ const ReturnDetailPage = () => {
|
|
|
2241
2126
|
{
|
|
2242
2127
|
variant: "transparent",
|
|
2243
2128
|
size: "small",
|
|
2244
|
-
onClick: () => navigate("/
|
|
2129
|
+
onClick: () => navigate("/swaps"),
|
|
2245
2130
|
className: "w-fit",
|
|
2246
2131
|
children: [
|
|
2247
2132
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2251,81 +2136,67 @@ const ReturnDetailPage = () => {
|
|
|
2251
2136
|
),
|
|
2252
2137
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2253
2138
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2254
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2255
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2139
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
2140
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2256
2141
|
] }),
|
|
2257
2142
|
/* @__PURE__ */ jsx(
|
|
2258
2143
|
Badge,
|
|
2259
2144
|
{
|
|
2260
2145
|
size: "small",
|
|
2261
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2262
|
-
children:
|
|
2146
|
+
className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
|
|
2147
|
+
children: swap.status.replace(/_/g, " ")
|
|
2263
2148
|
}
|
|
2264
2149
|
)
|
|
2265
2150
|
] })
|
|
2266
2151
|
] }),
|
|
2267
|
-
|
|
2152
|
+
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2268
2153
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2269
2154
|
Button,
|
|
2270
2155
|
{
|
|
2271
2156
|
variant: "danger",
|
|
2272
|
-
onClick:
|
|
2273
|
-
disabled:
|
|
2274
|
-
isLoading:
|
|
2275
|
-
children: "
|
|
2157
|
+
onClick: handleCancelExchange,
|
|
2158
|
+
disabled: isCancelling,
|
|
2159
|
+
isLoading: isCancelling,
|
|
2160
|
+
children: "Cancel Exchange"
|
|
2276
2161
|
}
|
|
2277
2162
|
) }),
|
|
2278
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2279
|
-
] }),
|
|
2280
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2281
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2282
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2283
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2284
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2285
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2286
|
-
] }),
|
|
2287
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2288
|
-
Button,
|
|
2289
|
-
{
|
|
2290
|
-
variant: "secondary",
|
|
2291
|
-
onClick: () => {
|
|
2292
|
-
window.open(
|
|
2293
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
2294
|
-
"_blank"
|
|
2295
|
-
);
|
|
2296
|
-
},
|
|
2297
|
-
children: "View order"
|
|
2298
|
-
}
|
|
2299
|
-
) })
|
|
2300
|
-
] })
|
|
2163
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2301
2164
|
] }),
|
|
2302
2165
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2303
2166
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2304
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
2167
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2305
2168
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2306
2169
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2307
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2308
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2170
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2171
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
2309
2172
|
] }),
|
|
2310
2173
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2311
2174
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2312
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2175
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
2313
2176
|
] }),
|
|
2314
|
-
|
|
2177
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2178
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2179
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2180
|
+
] }),
|
|
2181
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2315
2182
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2316
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2183
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
2317
2184
|
] }),
|
|
2318
|
-
|
|
2185
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2319
2186
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2320
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2187
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
2321
2188
|
] }),
|
|
2322
2189
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2323
2190
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2324
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2191
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2325
2192
|
] }),
|
|
2326
2193
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2327
2194
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2328
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2195
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2196
|
+
] }),
|
|
2197
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2198
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2199
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2329
2200
|
] })
|
|
2330
2201
|
] })
|
|
2331
2202
|
] }),
|
|
@@ -2340,7 +2211,7 @@ const ReturnDetailPage = () => {
|
|
|
2340
2211
|
Badge,
|
|
2341
2212
|
{
|
|
2342
2213
|
size: "2xsmall",
|
|
2343
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2214
|
+
className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
|
|
2344
2215
|
children: entry.status.replace(/_/g, " ")
|
|
2345
2216
|
}
|
|
2346
2217
|
) }),
|
|
@@ -2355,31 +2226,31 @@ const ReturnDetailPage = () => {
|
|
|
2355
2226
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2356
2227
|
] })
|
|
2357
2228
|
] }),
|
|
2358
|
-
|
|
2229
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2359
2230
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2360
2231
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2361
2232
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2362
2233
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2363
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2234
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2364
2235
|
] }),
|
|
2365
2236
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2366
2237
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2367
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2238
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2368
2239
|
] }),
|
|
2369
2240
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2370
2241
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2371
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((
|
|
2242
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2372
2243
|
] }),
|
|
2373
|
-
|
|
2244
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2374
2245
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2375
2246
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2376
|
-
|
|
2377
|
-
(Number(
|
|
2247
|
+
order.currency_code || "$",
|
|
2248
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2378
2249
|
] })
|
|
2379
2250
|
] })
|
|
2380
2251
|
] })
|
|
2381
2252
|
] }),
|
|
2382
|
-
|
|
2253
|
+
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: [
|
|
2383
2254
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2384
2255
|
/* @__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: [
|
|
2385
2256
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2387,22 +2258,33 @@ const ReturnDetailPage = () => {
|
|
|
2387
2258
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2388
2259
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2389
2260
|
] }) }),
|
|
2390
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2261
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2391
2262
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2392
2263
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2393
2264
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2394
2265
|
] }, item.id || index)) })
|
|
2395
2266
|
] }) })
|
|
2396
2267
|
] }),
|
|
2397
|
-
|
|
2398
|
-
|
|
2268
|
+
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: [
|
|
2269
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2270
|
+
/* @__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: [
|
|
2271
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2272
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2273
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2274
|
+
] }) }),
|
|
2275
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2276
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2277
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2278
|
+
] }, item.variant_id || index)) })
|
|
2279
|
+
] }) })
|
|
2280
|
+
] })
|
|
2399
2281
|
] }) });
|
|
2400
2282
|
};
|
|
2401
|
-
const config$
|
|
2402
|
-
label: "
|
|
2403
|
-
icon:
|
|
2283
|
+
const config$2 = defineRouteConfig({
|
|
2284
|
+
label: "Swap Details",
|
|
2285
|
+
icon: ArrowPath
|
|
2404
2286
|
});
|
|
2405
|
-
const getStatusBadgeClass = (status) => {
|
|
2287
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
2406
2288
|
const statusLower = status.toLowerCase();
|
|
2407
2289
|
if (statusLower === "requested") {
|
|
2408
2290
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2413,109 +2295,105 @@ const getStatusBadgeClass = (status) => {
|
|
|
2413
2295
|
if (statusLower === "rejected") {
|
|
2414
2296
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2415
2297
|
}
|
|
2298
|
+
if (statusLower === "received") {
|
|
2299
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2300
|
+
}
|
|
2301
|
+
if (statusLower === "refunded") {
|
|
2302
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2303
|
+
}
|
|
2416
2304
|
if (statusLower === "completed") {
|
|
2417
2305
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2418
2306
|
}
|
|
2419
|
-
if (statusLower === "cancelled"
|
|
2307
|
+
if (statusLower === "cancelled") {
|
|
2420
2308
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2421
2309
|
}
|
|
2422
|
-
if (statusLower === "pending") {
|
|
2423
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2424
|
-
}
|
|
2425
2310
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2426
2311
|
};
|
|
2427
|
-
const
|
|
2428
|
-
var _a, _b
|
|
2312
|
+
const ReturnDetailPage = () => {
|
|
2313
|
+
var _a, _b;
|
|
2429
2314
|
const navigate = useNavigate();
|
|
2430
2315
|
const { id } = useParams();
|
|
2431
|
-
const [
|
|
2432
|
-
const [order, setOrder] = useState(null);
|
|
2316
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
2433
2317
|
const [isLoading, setIsLoading] = useState(true);
|
|
2434
|
-
useState(false);
|
|
2435
|
-
const [isCancelling, setIsCancelling] = useState(false);
|
|
2318
|
+
const [isRejecting, setIsRejecting] = useState(false);
|
|
2436
2319
|
const [error, setError] = useState(null);
|
|
2437
2320
|
const [updateError, setUpdateError] = useState(null);
|
|
2438
2321
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2439
2322
|
useEffect(() => {
|
|
2440
2323
|
if (!id) {
|
|
2441
|
-
navigate("/
|
|
2324
|
+
navigate("/returns");
|
|
2442
2325
|
return;
|
|
2443
2326
|
}
|
|
2444
|
-
const
|
|
2327
|
+
const loadReturn = async () => {
|
|
2445
2328
|
try {
|
|
2446
2329
|
setIsLoading(true);
|
|
2447
2330
|
setError(null);
|
|
2448
|
-
const response = await fetch(`/admin/
|
|
2331
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
2449
2332
|
credentials: "include"
|
|
2450
2333
|
});
|
|
2451
2334
|
if (!response.ok) {
|
|
2452
2335
|
const message = await response.text();
|
|
2453
|
-
throw new Error(message || "Unable to load
|
|
2336
|
+
throw new Error(message || "Unable to load return order");
|
|
2454
2337
|
}
|
|
2455
2338
|
const payload = await response.json();
|
|
2456
|
-
|
|
2457
|
-
setOrder(payload.order || null);
|
|
2339
|
+
setReturnOrder(payload.return);
|
|
2458
2340
|
} catch (loadError) {
|
|
2459
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2341
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
2460
2342
|
setError(message);
|
|
2461
2343
|
} finally {
|
|
2462
2344
|
setIsLoading(false);
|
|
2463
2345
|
}
|
|
2464
2346
|
};
|
|
2465
|
-
void
|
|
2347
|
+
void loadReturn();
|
|
2466
2348
|
}, [id, navigate]);
|
|
2467
|
-
const
|
|
2349
|
+
const handleReject = async () => {
|
|
2468
2350
|
if (!id) {
|
|
2469
2351
|
return;
|
|
2470
2352
|
}
|
|
2471
2353
|
try {
|
|
2472
|
-
|
|
2354
|
+
setIsRejecting(true);
|
|
2473
2355
|
setUpdateError(null);
|
|
2474
2356
|
setUpdateSuccess(false);
|
|
2475
|
-
const response = await fetch(`/admin/
|
|
2357
|
+
const response = await fetch(`/admin/returns/${id}/reject`, {
|
|
2476
2358
|
method: "POST",
|
|
2477
2359
|
headers: {
|
|
2478
2360
|
"Content-Type": "application/json"
|
|
2479
2361
|
},
|
|
2480
|
-
credentials: "include"
|
|
2362
|
+
credentials: "include",
|
|
2363
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2481
2364
|
});
|
|
2482
2365
|
if (!response.ok) {
|
|
2483
2366
|
const message = await response.text();
|
|
2484
|
-
throw new Error(message || "Unable to
|
|
2367
|
+
throw new Error(message || "Unable to reject return");
|
|
2485
2368
|
}
|
|
2486
2369
|
const payload = await response.json();
|
|
2487
|
-
|
|
2370
|
+
setReturnOrder(payload.return);
|
|
2488
2371
|
setUpdateSuccess(true);
|
|
2489
2372
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2490
|
-
const detailResponse = await fetch(`/admin/
|
|
2373
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
2491
2374
|
credentials: "include"
|
|
2492
2375
|
});
|
|
2493
2376
|
if (detailResponse.ok) {
|
|
2494
2377
|
const detailPayload = await detailResponse.json();
|
|
2495
|
-
|
|
2496
|
-
setOrder(detailPayload.order || null);
|
|
2378
|
+
setReturnOrder(detailPayload.return);
|
|
2497
2379
|
}
|
|
2498
|
-
} catch (
|
|
2499
|
-
const message =
|
|
2380
|
+
} catch (updateErr) {
|
|
2381
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
2500
2382
|
setUpdateError(message);
|
|
2501
2383
|
} finally {
|
|
2502
|
-
|
|
2384
|
+
setIsRejecting(false);
|
|
2503
2385
|
}
|
|
2504
2386
|
};
|
|
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
2387
|
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
|
|
2388
|
+
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 return order..." }) }) }) });
|
|
2511
2389
|
}
|
|
2512
|
-
if (error || !
|
|
2390
|
+
if (error || !returnOrder) {
|
|
2513
2391
|
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 || "
|
|
2515
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
2392
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
2393
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2516
2394
|
] }) }) });
|
|
2517
2395
|
}
|
|
2518
|
-
const statusHistory = ((
|
|
2396
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
2519
2397
|
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
2398
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2521
2399
|
/* @__PURE__ */ jsxs(
|
|
@@ -2523,7 +2401,7 @@ const SwapDetailPage = () => {
|
|
|
2523
2401
|
{
|
|
2524
2402
|
variant: "transparent",
|
|
2525
2403
|
size: "small",
|
|
2526
|
-
onClick: () => navigate("/
|
|
2404
|
+
onClick: () => navigate("/returns"),
|
|
2527
2405
|
className: "w-fit",
|
|
2528
2406
|
children: [
|
|
2529
2407
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2533,67 +2411,81 @@ const SwapDetailPage = () => {
|
|
|
2533
2411
|
),
|
|
2534
2412
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2535
2413
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2536
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2537
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2414
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
2415
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
2538
2416
|
] }),
|
|
2539
2417
|
/* @__PURE__ */ jsx(
|
|
2540
2418
|
Badge,
|
|
2541
2419
|
{
|
|
2542
2420
|
size: "small",
|
|
2543
|
-
className: `uppercase ${getStatusBadgeClass(
|
|
2544
|
-
children:
|
|
2421
|
+
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
2422
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2423
|
+
}
|
|
2424
|
+
)
|
|
2425
|
+
] })
|
|
2426
|
+
] }),
|
|
2427
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2428
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2429
|
+
Button,
|
|
2430
|
+
{
|
|
2431
|
+
variant: "danger",
|
|
2432
|
+
onClick: handleReject,
|
|
2433
|
+
disabled: isRejecting,
|
|
2434
|
+
isLoading: isRejecting,
|
|
2435
|
+
children: "Reject (Cancel) Return"
|
|
2436
|
+
}
|
|
2437
|
+
) }),
|
|
2438
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
2439
|
+
] }),
|
|
2440
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2441
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2442
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2443
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2444
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2445
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2446
|
+
] }),
|
|
2447
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2448
|
+
Button,
|
|
2449
|
+
{
|
|
2450
|
+
variant: "secondary",
|
|
2451
|
+
onClick: () => {
|
|
2452
|
+
window.open(
|
|
2453
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
2454
|
+
"_blank"
|
|
2455
|
+
);
|
|
2456
|
+
},
|
|
2457
|
+
children: "View order"
|
|
2545
2458
|
}
|
|
2546
|
-
)
|
|
2459
|
+
) })
|
|
2547
2460
|
] })
|
|
2548
2461
|
] }),
|
|
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
2462
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2563
2463
|
/* @__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: "
|
|
2464
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2565
2465
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2566
2466
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2567
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2568
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2467
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2468
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2569
2469
|
] }),
|
|
2570
2470
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2571
2471
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2572
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2573
|
-
] }),
|
|
2574
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2575
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2576
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2472
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
2577
2473
|
] }),
|
|
2578
|
-
|
|
2474
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2579
2475
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2580
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2476
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
2581
2477
|
] }),
|
|
2582
|
-
|
|
2478
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2583
2479
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2584
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2480
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
2585
2481
|
] }),
|
|
2586
2482
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2587
2483
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2588
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2484
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2589
2485
|
] }),
|
|
2590
2486
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2591
2487
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2592
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2593
|
-
] }),
|
|
2594
|
-
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2595
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2596
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2488
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2597
2489
|
] })
|
|
2598
2490
|
] })
|
|
2599
2491
|
] }),
|
|
@@ -2608,7 +2500,7 @@ const SwapDetailPage = () => {
|
|
|
2608
2500
|
Badge,
|
|
2609
2501
|
{
|
|
2610
2502
|
size: "2xsmall",
|
|
2611
|
-
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
2503
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
2612
2504
|
children: entry.status.replace(/_/g, " ")
|
|
2613
2505
|
}
|
|
2614
2506
|
) }),
|
|
@@ -2623,31 +2515,31 @@ const SwapDetailPage = () => {
|
|
|
2623
2515
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2624
2516
|
] })
|
|
2625
2517
|
] }),
|
|
2626
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2518
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2627
2519
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2628
2520
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2629
2521
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2630
2522
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2631
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2523
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2632
2524
|
] }),
|
|
2633
2525
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2634
2526
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2635
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2527
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2636
2528
|
] }),
|
|
2637
2529
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2638
2530
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2639
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((
|
|
2531
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2640
2532
|
] }),
|
|
2641
|
-
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2533
|
+
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2642
2534
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2643
2535
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2644
|
-
order.currency_code || "$",
|
|
2645
|
-
(Number(order.total) / 100).toFixed(2)
|
|
2536
|
+
returnOrder.order.currency_code || "$",
|
|
2537
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2646
2538
|
] })
|
|
2647
2539
|
] })
|
|
2648
2540
|
] })
|
|
2649
2541
|
] }),
|
|
2650
|
-
|
|
2542
|
+
returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2651
2543
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2652
2544
|
/* @__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
2545
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2655,31 +2547,139 @@ const SwapDetailPage = () => {
|
|
|
2655
2547
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2656
2548
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2657
2549
|
] }) }),
|
|
2658
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2550
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2659
2551
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2660
2552
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2661
2553
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2662
2554
|
] }, item.id || index)) })
|
|
2663
2555
|
] }) })
|
|
2664
2556
|
] }),
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2557
|
+
updateError && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: updateError }) }),
|
|
2558
|
+
updateSuccess && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
|
|
2559
|
+
] }) });
|
|
2560
|
+
};
|
|
2561
|
+
const config$1 = defineRouteConfig({
|
|
2562
|
+
label: "Return Order Details",
|
|
2563
|
+
icon: CheckCircle
|
|
2564
|
+
});
|
|
2565
|
+
const getStatusBadgeClass = (status) => {
|
|
2566
|
+
const s2 = status.toLowerCase();
|
|
2567
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2568
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2569
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2570
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2571
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2572
|
+
};
|
|
2573
|
+
const PaymentDetailPage = () => {
|
|
2574
|
+
var _a;
|
|
2575
|
+
const navigate = useNavigate();
|
|
2576
|
+
const params = useParams();
|
|
2577
|
+
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2578
|
+
const [detail, setDetail] = useState(null);
|
|
2579
|
+
const [loading, setLoading] = useState(!!id);
|
|
2580
|
+
const [error, setError] = useState(null);
|
|
2581
|
+
useEffect(() => {
|
|
2582
|
+
if (!id) {
|
|
2583
|
+
setLoading(false);
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
let cancelled = false;
|
|
2587
|
+
setLoading(true);
|
|
2588
|
+
setError(null);
|
|
2589
|
+
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
2590
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2591
|
+
return res.json();
|
|
2592
|
+
}).then((data) => {
|
|
2593
|
+
if (!cancelled) setDetail(data);
|
|
2594
|
+
}).catch((e) => {
|
|
2595
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2596
|
+
}).finally(() => {
|
|
2597
|
+
if (!cancelled) setLoading(false);
|
|
2598
|
+
});
|
|
2599
|
+
return () => {
|
|
2600
|
+
cancelled = true;
|
|
2601
|
+
};
|
|
2602
|
+
}, [id]);
|
|
2603
|
+
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
2604
|
+
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
2605
|
+
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
2606
|
+
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
2607
|
+
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: [
|
|
2608
|
+
/* @__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: [
|
|
2609
|
+
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
2610
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
|
|
2611
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
2612
|
+
] }) }),
|
|
2613
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2614
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2615
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
|
|
2616
|
+
] }) : 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: [
|
|
2617
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2618
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2619
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
|
|
2620
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsx(
|
|
2621
|
+
Button,
|
|
2622
|
+
{
|
|
2623
|
+
variant: "transparent",
|
|
2624
|
+
size: "small",
|
|
2625
|
+
onClick: () => navigate(`/orders/${detail.order_id}`),
|
|
2626
|
+
children: detail.order_id
|
|
2627
|
+
}
|
|
2628
|
+
) : /* @__PURE__ */ jsx(Text, { children: "—" }) })
|
|
2629
|
+
] }),
|
|
2630
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2631
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2632
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: displayAmount })
|
|
2633
|
+
] }),
|
|
2634
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2635
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2636
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.provider_id })
|
|
2637
|
+
] }),
|
|
2638
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2639
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2640
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2641
|
+
Badge,
|
|
2642
|
+
{
|
|
2643
|
+
size: "2xsmall",
|
|
2644
|
+
className: `uppercase ${getStatusBadgeClass(displayStatus)}`,
|
|
2645
|
+
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
2646
|
+
}
|
|
2647
|
+
) })
|
|
2648
|
+
] }),
|
|
2649
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2650
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
2651
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
2652
|
+
] }),
|
|
2653
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2654
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
2655
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
2656
|
+
] }),
|
|
2657
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2658
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
2659
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
2660
|
+
] }),
|
|
2661
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2662
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
2663
|
+
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
2664
|
+
year: "numeric",
|
|
2665
|
+
month: "short",
|
|
2666
|
+
day: "numeric",
|
|
2667
|
+
hour: "numeric",
|
|
2668
|
+
minute: "2-digit",
|
|
2669
|
+
hour12: true
|
|
2670
|
+
}) })
|
|
2671
|
+
] })
|
|
2672
|
+
] }) }),
|
|
2673
|
+
Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2674
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
|
|
2675
|
+
/* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
|
|
2676
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
|
|
2677
|
+
] }) : null
|
|
2678
2678
|
] }) });
|
|
2679
2679
|
};
|
|
2680
2680
|
const config = defineRouteConfig({
|
|
2681
|
-
label: "
|
|
2682
|
-
icon:
|
|
2681
|
+
label: "Payment details",
|
|
2682
|
+
icon: CreditCard
|
|
2683
2683
|
});
|
|
2684
2684
|
const i18nTranslations0 = {};
|
|
2685
2685
|
const widgetModule = { widgets: [
|
|
@@ -2699,43 +2699,49 @@ const routeModule = {
|
|
|
2699
2699
|
path: "/refunds"
|
|
2700
2700
|
},
|
|
2701
2701
|
{
|
|
2702
|
-
Component:
|
|
2703
|
-
path: "/
|
|
2702
|
+
Component: SwapsPage,
|
|
2703
|
+
path: "/swaps"
|
|
2704
2704
|
},
|
|
2705
2705
|
{
|
|
2706
2706
|
Component: ReturnsPage,
|
|
2707
2707
|
path: "/returns"
|
|
2708
2708
|
},
|
|
2709
2709
|
{
|
|
2710
|
-
Component:
|
|
2711
|
-
path: "/
|
|
2710
|
+
Component: PaymentsPage,
|
|
2711
|
+
path: "/payments"
|
|
2712
2712
|
},
|
|
2713
2713
|
{
|
|
2714
2714
|
Component: RefundDetailPage,
|
|
2715
2715
|
path: "/refunds/: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: PaymentDetailPage,
|
|
2727
|
+
path: "/payments/:id"
|
|
2728
2728
|
}
|
|
2729
2729
|
]
|
|
2730
2730
|
};
|
|
2731
2731
|
const menuItemModule = {
|
|
2732
2732
|
menuItems: [
|
|
2733
2733
|
{
|
|
2734
|
-
label: config$
|
|
2735
|
-
icon: config$
|
|
2734
|
+
label: config$4.label,
|
|
2735
|
+
icon: config$4.icon,
|
|
2736
2736
|
path: "/payments",
|
|
2737
2737
|
nested: void 0
|
|
2738
2738
|
},
|
|
2739
|
+
{
|
|
2740
|
+
label: config$5.label,
|
|
2741
|
+
icon: config$5.icon,
|
|
2742
|
+
path: "/returns",
|
|
2743
|
+
nested: void 0
|
|
2744
|
+
},
|
|
2739
2745
|
{
|
|
2740
2746
|
label: config$7.label,
|
|
2741
2747
|
icon: config$7.icon,
|
|
@@ -2743,15 +2749,21 @@ const menuItemModule = {
|
|
|
2743
2749
|
nested: void 0
|
|
2744
2750
|
},
|
|
2745
2751
|
{
|
|
2746
|
-
label: config$
|
|
2747
|
-
icon: config$
|
|
2748
|
-
path: "/
|
|
2752
|
+
label: config$6.label,
|
|
2753
|
+
icon: config$6.icon,
|
|
2754
|
+
path: "/swaps",
|
|
2749
2755
|
nested: void 0
|
|
2750
2756
|
},
|
|
2751
2757
|
{
|
|
2752
|
-
label: config
|
|
2753
|
-
icon: config
|
|
2754
|
-
path: "/
|
|
2758
|
+
label: config.label,
|
|
2759
|
+
icon: config.icon,
|
|
2760
|
+
path: "/payments/:id",
|
|
2761
|
+
nested: void 0
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
label: config$1.label,
|
|
2765
|
+
icon: config$1.icon,
|
|
2766
|
+
path: "/returns/:id",
|
|
2755
2767
|
nested: void 0
|
|
2756
2768
|
},
|
|
2757
2769
|
{
|
|
@@ -2763,20 +2775,8 @@ const menuItemModule = {
|
|
|
2763
2775
|
{
|
|
2764
2776
|
label: config$2.label,
|
|
2765
2777
|
icon: config$2.icon,
|
|
2766
|
-
path: "/payments/:id",
|
|
2767
|
-
nested: void 0
|
|
2768
|
-
},
|
|
2769
|
-
{
|
|
2770
|
-
label: config.label,
|
|
2771
|
-
icon: config.icon,
|
|
2772
2778
|
path: "/swaps/:id",
|
|
2773
2779
|
nested: void 0
|
|
2774
|
-
},
|
|
2775
|
-
{
|
|
2776
|
-
label: config$1.label,
|
|
2777
|
-
icon: config$1.icon,
|
|
2778
|
-
path: "/returns/:id",
|
|
2779
|
-
nested: void 0
|
|
2780
2780
|
}
|
|
2781
2781
|
]
|
|
2782
2782
|
};
|