order-management 0.0.88 → 0.0.90
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 +590 -590
- package/.medusa/server/src/admin/index.mjs +591 -591
- package/.medusa/server/src/api/store/guest-orders/route.js +3 -5
- package/.medusa/server/src/helpers/index.js +2 -1
- package/.medusa/server/src/helpers/order-line-presentation.js +72 -0
- package/.medusa/server/src/workflows/steps/retrieve-order-step.js +6 -1
- package/.medusa/server/src/workflows/steps/transform-order-to-cart-step.js +4 -3
- 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, ArrowPath,
|
|
5
|
+
import { CashSolid, PencilSquareSolid, Trash, Receipt, ArrowPath, CheckCircle, ArrowLeft, CreditCard } 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();
|
|
@@ -1392,206 +1392,6 @@ const useDebounce$1 = (value, delay) => {
|
|
|
1392
1392
|
return debouncedValue;
|
|
1393
1393
|
};
|
|
1394
1394
|
const getStatusBadgeClass$5 = (status) => {
|
|
1395
|
-
const s2 = status.toLowerCase();
|
|
1396
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1397
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1398
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
1399
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
1400
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
1401
|
-
};
|
|
1402
|
-
const PaymentsPage = () => {
|
|
1403
|
-
const navigate = useNavigate();
|
|
1404
|
-
const [items, setItems] = useState([]);
|
|
1405
|
-
const [statusFilter, setStatusFilter] = useState("all");
|
|
1406
|
-
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
1407
|
-
const debouncedOrderId = useDebounce$1(orderIdSearch, 300);
|
|
1408
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
1409
|
-
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1410
|
-
const [error, setError] = useState(null);
|
|
1411
|
-
const [offset, setOffset] = useState(0);
|
|
1412
|
-
const [count, setCount] = useState(0);
|
|
1413
|
-
const limit = 50;
|
|
1414
|
-
const loadTransactions = useCallback(
|
|
1415
|
-
async (nextOffset, replace) => {
|
|
1416
|
-
try {
|
|
1417
|
-
if (replace) setIsLoading(true);
|
|
1418
|
-
else setIsFetchingMore(true);
|
|
1419
|
-
setError(null);
|
|
1420
|
-
const params = new URLSearchParams();
|
|
1421
|
-
params.set("limit", String(limit));
|
|
1422
|
-
params.set("offset", String(nextOffset));
|
|
1423
|
-
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
1424
|
-
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
1425
|
-
const response = await fetch(
|
|
1426
|
-
`/admin/payment-transactions?${params.toString()}`,
|
|
1427
|
-
{ credentials: "include" }
|
|
1428
|
-
);
|
|
1429
|
-
if (!response.ok) {
|
|
1430
|
-
const text = await response.text();
|
|
1431
|
-
throw new Error(text || "Failed to load payment transactions");
|
|
1432
|
-
}
|
|
1433
|
-
const payload = await response.json();
|
|
1434
|
-
const list = payload.transactions ?? [];
|
|
1435
|
-
setCount(payload.count ?? 0);
|
|
1436
|
-
setOffset(nextOffset + list.length);
|
|
1437
|
-
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
1438
|
-
} catch (e) {
|
|
1439
|
-
setError(e instanceof Error ? e.message : "Failed to load");
|
|
1440
|
-
} finally {
|
|
1441
|
-
setIsLoading(false);
|
|
1442
|
-
setIsFetchingMore(false);
|
|
1443
|
-
}
|
|
1444
|
-
},
|
|
1445
|
-
[statusFilter, debouncedOrderId]
|
|
1446
|
-
);
|
|
1447
|
-
useEffect(() => {
|
|
1448
|
-
void loadTransactions(0, true);
|
|
1449
|
-
}, [loadTransactions]);
|
|
1450
|
-
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
1451
|
-
const displayStatus = (t) => {
|
|
1452
|
-
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
1453
|
-
return s2 !== "" ? s2 : "—";
|
|
1454
|
-
};
|
|
1455
|
-
const displayAmount = (t) => {
|
|
1456
|
-
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
1457
|
-
return `${code} ${Number(t.amount)}`;
|
|
1458
|
-
};
|
|
1459
|
-
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: [
|
|
1460
|
-
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1461
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1462
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
1463
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
1464
|
-
] }),
|
|
1465
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
1466
|
-
] }),
|
|
1467
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
1468
|
-
/* @__PURE__ */ jsx(
|
|
1469
|
-
Input,
|
|
1470
|
-
{
|
|
1471
|
-
placeholder: "Search by Order ID",
|
|
1472
|
-
value: orderIdSearch,
|
|
1473
|
-
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
1474
|
-
className: "md:max-w-sm",
|
|
1475
|
-
"aria-label": "Search by order ID"
|
|
1476
|
-
}
|
|
1477
|
-
),
|
|
1478
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
1479
|
-
"select",
|
|
1480
|
-
{
|
|
1481
|
-
value: statusFilter,
|
|
1482
|
-
onChange: (e) => setStatusFilter(e.target.value),
|
|
1483
|
-
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",
|
|
1484
|
-
"aria-label": "Filter by status",
|
|
1485
|
-
children: [
|
|
1486
|
-
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
1487
|
-
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
1488
|
-
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
1489
|
-
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
1490
|
-
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
1491
|
-
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
1492
|
-
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
1493
|
-
]
|
|
1494
|
-
}
|
|
1495
|
-
) })
|
|
1496
|
-
] }),
|
|
1497
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
1498
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
1499
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
1500
|
-
] }) : null,
|
|
1501
|
-
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: [
|
|
1502
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
1503
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
1504
|
-
] }) : /* @__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: [
|
|
1505
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1506
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
1507
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
1508
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
1509
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
1510
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
1511
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
1512
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
1513
|
-
] }) }),
|
|
1514
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
1515
|
-
"tr",
|
|
1516
|
-
{
|
|
1517
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
1518
|
-
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
1519
|
-
children: [
|
|
1520
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
1521
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
1522
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
1523
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
1524
|
-
Badge,
|
|
1525
|
-
{
|
|
1526
|
-
size: "2xsmall",
|
|
1527
|
-
className: `uppercase ${getStatusBadgeClass$5(displayStatus(t))}`,
|
|
1528
|
-
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
1529
|
-
}
|
|
1530
|
-
) }),
|
|
1531
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
1532
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
1533
|
-
year: "numeric",
|
|
1534
|
-
month: "short",
|
|
1535
|
-
day: "numeric",
|
|
1536
|
-
hour: "numeric",
|
|
1537
|
-
minute: "2-digit",
|
|
1538
|
-
hour12: true
|
|
1539
|
-
}) }),
|
|
1540
|
-
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
1541
|
-
/* @__PURE__ */ jsx(
|
|
1542
|
-
Button,
|
|
1543
|
-
{
|
|
1544
|
-
variant: "transparent",
|
|
1545
|
-
size: "small",
|
|
1546
|
-
onClick: (e) => {
|
|
1547
|
-
e.stopPropagation();
|
|
1548
|
-
navigate(`/payments/${t.payment_session_id}`);
|
|
1549
|
-
},
|
|
1550
|
-
children: "View details"
|
|
1551
|
-
}
|
|
1552
|
-
),
|
|
1553
|
-
t.order_id ? /* @__PURE__ */ jsx(
|
|
1554
|
-
Button,
|
|
1555
|
-
{
|
|
1556
|
-
variant: "transparent",
|
|
1557
|
-
size: "small",
|
|
1558
|
-
onClick: (e) => {
|
|
1559
|
-
e.stopPropagation();
|
|
1560
|
-
navigate(`/orders/${t.order_id}`);
|
|
1561
|
-
},
|
|
1562
|
-
children: "Order"
|
|
1563
|
-
}
|
|
1564
|
-
) : null
|
|
1565
|
-
] })
|
|
1566
|
-
]
|
|
1567
|
-
},
|
|
1568
|
-
t.payment_session_id
|
|
1569
|
-
)) })
|
|
1570
|
-
] }) }),
|
|
1571
|
-
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
1572
|
-
Button,
|
|
1573
|
-
{
|
|
1574
|
-
variant: "secondary",
|
|
1575
|
-
isLoading: isFetchingMore,
|
|
1576
|
-
onClick: () => loadTransactions(offset, false),
|
|
1577
|
-
children: "Load more"
|
|
1578
|
-
}
|
|
1579
|
-
) }) : null
|
|
1580
|
-
] }) });
|
|
1581
|
-
};
|
|
1582
|
-
const config$5 = defineRouteConfig({
|
|
1583
|
-
label: "Payments",
|
|
1584
|
-
icon: CreditCard
|
|
1585
|
-
});
|
|
1586
|
-
const useDebounce = (value, delay) => {
|
|
1587
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1588
|
-
useEffect(() => {
|
|
1589
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1590
|
-
return () => clearTimeout(handler);
|
|
1591
|
-
}, [value, delay]);
|
|
1592
|
-
return debouncedValue;
|
|
1593
|
-
};
|
|
1594
|
-
const getStatusBadgeClass$4 = (status) => {
|
|
1595
1395
|
const statusLower = status.toLowerCase();
|
|
1596
1396
|
if (statusLower === "requested") {
|
|
1597
1397
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -1616,7 +1416,7 @@ const SwapsPage = () => {
|
|
|
1616
1416
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
1617
1417
|
const [createdByFilter, setCreatedByFilter] = useState("all");
|
|
1618
1418
|
const [searchQuery, setSearchQuery] = useState("");
|
|
1619
|
-
const debouncedSearchQuery = useDebounce(searchQuery, 300);
|
|
1419
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
1620
1420
|
const [isLoading, setIsLoading] = useState(true);
|
|
1621
1421
|
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
1622
1422
|
const [error, setError] = useState(null);
|
|
@@ -1759,7 +1559,7 @@ const SwapsPage = () => {
|
|
|
1759
1559
|
Badge,
|
|
1760
1560
|
{
|
|
1761
1561
|
size: "2xsmall",
|
|
1762
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1562
|
+
className: `uppercase ${getStatusBadgeClass$5(swap.status)}`,
|
|
1763
1563
|
children: swap.status.replace(/_/g, " ")
|
|
1764
1564
|
}
|
|
1765
1565
|
) }),
|
|
@@ -1809,11 +1609,11 @@ const SwapsPage = () => {
|
|
|
1809
1609
|
) }) : null
|
|
1810
1610
|
] }) });
|
|
1811
1611
|
};
|
|
1812
|
-
const config$
|
|
1612
|
+
const config$5 = defineRouteConfig({
|
|
1813
1613
|
label: "Exchanges",
|
|
1814
1614
|
icon: ArrowPath
|
|
1815
1615
|
});
|
|
1816
|
-
const getStatusBadgeClass$
|
|
1616
|
+
const getStatusBadgeClass$4 = (status) => {
|
|
1817
1617
|
const s2 = status.toLowerCase();
|
|
1818
1618
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1819
1619
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -1924,7 +1724,7 @@ const RefundDetailPage = () => {
|
|
|
1924
1724
|
Badge,
|
|
1925
1725
|
{
|
|
1926
1726
|
size: "2xsmall",
|
|
1927
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
1727
|
+
className: `uppercase ${getStatusBadgeClass$4(paymentStatus)}`,
|
|
1928
1728
|
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
1929
1729
|
}
|
|
1930
1730
|
) })
|
|
@@ -2001,11 +1801,11 @@ const RefundDetailPage = () => {
|
|
|
2001
1801
|
] }) : null
|
|
2002
1802
|
] }) });
|
|
2003
1803
|
};
|
|
2004
|
-
const config$
|
|
1804
|
+
const config$4 = defineRouteConfig({
|
|
2005
1805
|
label: "Refund details",
|
|
2006
1806
|
icon: Receipt
|
|
2007
1807
|
});
|
|
2008
|
-
const getStatusBadgeClass$
|
|
1808
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
2009
1809
|
const statusLower = status.toLowerCase();
|
|
2010
1810
|
if (statusLower === "requested") {
|
|
2011
1811
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2016,109 +1816,105 @@ const getStatusBadgeClass$2 = (status) => {
|
|
|
2016
1816
|
if (statusLower === "rejected") {
|
|
2017
1817
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2018
1818
|
}
|
|
1819
|
+
if (statusLower === "received") {
|
|
1820
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
1821
|
+
}
|
|
1822
|
+
if (statusLower === "refunded") {
|
|
1823
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
1824
|
+
}
|
|
2019
1825
|
if (statusLower === "completed") {
|
|
2020
1826
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2021
1827
|
}
|
|
2022
|
-
if (statusLower === "cancelled"
|
|
1828
|
+
if (statusLower === "cancelled") {
|
|
2023
1829
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2024
1830
|
}
|
|
2025
|
-
if (statusLower === "pending") {
|
|
2026
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2027
|
-
}
|
|
2028
1831
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2029
1832
|
};
|
|
2030
|
-
const
|
|
2031
|
-
var _a, _b
|
|
1833
|
+
const ReturnDetailPage = () => {
|
|
1834
|
+
var _a, _b;
|
|
2032
1835
|
const navigate = useNavigate();
|
|
2033
1836
|
const { id } = useParams();
|
|
2034
|
-
const [
|
|
2035
|
-
const [order, setOrder] = useState(null);
|
|
1837
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
2036
1838
|
const [isLoading, setIsLoading] = useState(true);
|
|
2037
|
-
useState(false);
|
|
2038
|
-
const [isCancelling, setIsCancelling] = useState(false);
|
|
1839
|
+
const [isRejecting, setIsRejecting] = useState(false);
|
|
2039
1840
|
const [error, setError] = useState(null);
|
|
2040
1841
|
const [updateError, setUpdateError] = useState(null);
|
|
2041
1842
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2042
1843
|
useEffect(() => {
|
|
2043
1844
|
if (!id) {
|
|
2044
|
-
navigate("/
|
|
1845
|
+
navigate("/returns");
|
|
2045
1846
|
return;
|
|
2046
1847
|
}
|
|
2047
|
-
const
|
|
1848
|
+
const loadReturn = async () => {
|
|
2048
1849
|
try {
|
|
2049
1850
|
setIsLoading(true);
|
|
2050
1851
|
setError(null);
|
|
2051
|
-
const response = await fetch(`/admin/
|
|
1852
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
2052
1853
|
credentials: "include"
|
|
2053
1854
|
});
|
|
2054
1855
|
if (!response.ok) {
|
|
2055
1856
|
const message = await response.text();
|
|
2056
|
-
throw new Error(message || "Unable to load
|
|
1857
|
+
throw new Error(message || "Unable to load return order");
|
|
2057
1858
|
}
|
|
2058
1859
|
const payload = await response.json();
|
|
2059
|
-
|
|
2060
|
-
setOrder(payload.order || null);
|
|
1860
|
+
setReturnOrder(payload.return);
|
|
2061
1861
|
} catch (loadError) {
|
|
2062
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
1862
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
2063
1863
|
setError(message);
|
|
2064
1864
|
} finally {
|
|
2065
1865
|
setIsLoading(false);
|
|
2066
1866
|
}
|
|
2067
1867
|
};
|
|
2068
|
-
void
|
|
1868
|
+
void loadReturn();
|
|
2069
1869
|
}, [id, navigate]);
|
|
2070
|
-
const
|
|
1870
|
+
const handleReject = async () => {
|
|
2071
1871
|
if (!id) {
|
|
2072
1872
|
return;
|
|
2073
1873
|
}
|
|
2074
1874
|
try {
|
|
2075
|
-
|
|
1875
|
+
setIsRejecting(true);
|
|
2076
1876
|
setUpdateError(null);
|
|
2077
1877
|
setUpdateSuccess(false);
|
|
2078
|
-
const response = await fetch(`/admin/
|
|
1878
|
+
const response = await fetch(`/admin/returns/${id}/reject`, {
|
|
2079
1879
|
method: "POST",
|
|
2080
1880
|
headers: {
|
|
2081
1881
|
"Content-Type": "application/json"
|
|
2082
1882
|
},
|
|
2083
|
-
credentials: "include"
|
|
1883
|
+
credentials: "include",
|
|
1884
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2084
1885
|
});
|
|
2085
1886
|
if (!response.ok) {
|
|
2086
1887
|
const message = await response.text();
|
|
2087
|
-
throw new Error(message || "Unable to
|
|
1888
|
+
throw new Error(message || "Unable to reject return");
|
|
2088
1889
|
}
|
|
2089
1890
|
const payload = await response.json();
|
|
2090
|
-
|
|
1891
|
+
setReturnOrder(payload.return);
|
|
2091
1892
|
setUpdateSuccess(true);
|
|
2092
1893
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2093
|
-
const detailResponse = await fetch(`/admin/
|
|
1894
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
2094
1895
|
credentials: "include"
|
|
2095
1896
|
});
|
|
2096
1897
|
if (detailResponse.ok) {
|
|
2097
1898
|
const detailPayload = await detailResponse.json();
|
|
2098
|
-
|
|
2099
|
-
setOrder(detailPayload.order || null);
|
|
1899
|
+
setReturnOrder(detailPayload.return);
|
|
2100
1900
|
}
|
|
2101
|
-
} catch (
|
|
2102
|
-
const message =
|
|
1901
|
+
} catch (updateErr) {
|
|
1902
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
|
|
2103
1903
|
setUpdateError(message);
|
|
2104
1904
|
} finally {
|
|
2105
|
-
|
|
1905
|
+
setIsRejecting(false);
|
|
2106
1906
|
}
|
|
2107
1907
|
};
|
|
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
|
-
);
|
|
2112
1908
|
if (isLoading) {
|
|
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
|
|
1909
|
+
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..." }) }) }) });
|
|
2114
1910
|
}
|
|
2115
|
-
if (error || !
|
|
1911
|
+
if (error || !returnOrder) {
|
|
2116
1912
|
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: [
|
|
2117
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2118
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
1913
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
1914
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
2119
1915
|
] }) }) });
|
|
2120
1916
|
}
|
|
2121
|
-
const statusHistory = ((
|
|
1917
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
2122
1918
|
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: [
|
|
2123
1919
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2124
1920
|
/* @__PURE__ */ jsxs(
|
|
@@ -2126,7 +1922,7 @@ const SwapDetailPage = () => {
|
|
|
2126
1922
|
{
|
|
2127
1923
|
variant: "transparent",
|
|
2128
1924
|
size: "small",
|
|
2129
|
-
onClick: () => navigate("/
|
|
1925
|
+
onClick: () => navigate("/returns"),
|
|
2130
1926
|
className: "w-fit",
|
|
2131
1927
|
children: [
|
|
2132
1928
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2136,67 +1932,81 @@ const SwapDetailPage = () => {
|
|
|
2136
1932
|
),
|
|
2137
1933
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2138
1934
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2139
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2140
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
1935
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
1936
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
2141
1937
|
] }),
|
|
2142
1938
|
/* @__PURE__ */ jsx(
|
|
2143
1939
|
Badge,
|
|
2144
1940
|
{
|
|
2145
1941
|
size: "small",
|
|
2146
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2147
|
-
children:
|
|
1942
|
+
className: `uppercase ${getStatusBadgeClass$3(returnOrder.status)}`,
|
|
1943
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2148
1944
|
}
|
|
2149
1945
|
)
|
|
2150
1946
|
] })
|
|
2151
1947
|
] }),
|
|
2152
|
-
|
|
1948
|
+
returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2153
1949
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2154
1950
|
Button,
|
|
2155
1951
|
{
|
|
2156
1952
|
variant: "danger",
|
|
2157
|
-
onClick:
|
|
2158
|
-
disabled:
|
|
2159
|
-
isLoading:
|
|
2160
|
-
children: "Cancel
|
|
1953
|
+
onClick: handleReject,
|
|
1954
|
+
disabled: isRejecting,
|
|
1955
|
+
isLoading: isRejecting,
|
|
1956
|
+
children: "Reject (Cancel) Return"
|
|
2161
1957
|
}
|
|
2162
1958
|
) }),
|
|
2163
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
1959
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
|
|
1960
|
+
] }),
|
|
1961
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1962
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
1963
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1964
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1965
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
1966
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
1967
|
+
] }),
|
|
1968
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
1969
|
+
Button,
|
|
1970
|
+
{
|
|
1971
|
+
variant: "secondary",
|
|
1972
|
+
onClick: () => {
|
|
1973
|
+
window.open(
|
|
1974
|
+
`/app/orders/${returnOrder.order_id}`,
|
|
1975
|
+
"_blank"
|
|
1976
|
+
);
|
|
1977
|
+
},
|
|
1978
|
+
children: "View order"
|
|
1979
|
+
}
|
|
1980
|
+
) })
|
|
1981
|
+
] })
|
|
2164
1982
|
] }),
|
|
2165
1983
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2166
1984
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2167
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
1985
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
|
|
2168
1986
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2169
1987
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2170
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2171
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1988
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
1989
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2172
1990
|
] }),
|
|
2173
1991
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2174
1992
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2175
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2176
|
-
] }),
|
|
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)}` : "—" })
|
|
1993
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
2180
1994
|
] }),
|
|
2181
|
-
|
|
1995
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2182
1996
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2183
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1997
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
2184
1998
|
] }),
|
|
2185
|
-
|
|
1999
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2186
2000
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2187
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2001
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
2188
2002
|
] }),
|
|
2189
2003
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2190
2004
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2191
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2005
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
2192
2006
|
] }),
|
|
2193
2007
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2194
2008
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2195
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
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 })
|
|
2009
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
2200
2010
|
] })
|
|
2201
2011
|
] })
|
|
2202
2012
|
] }),
|
|
@@ -2211,7 +2021,7 @@ const SwapDetailPage = () => {
|
|
|
2211
2021
|
Badge,
|
|
2212
2022
|
{
|
|
2213
2023
|
size: "2xsmall",
|
|
2214
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2024
|
+
className: `uppercase ${getStatusBadgeClass$3(entry.status)}`,
|
|
2215
2025
|
children: entry.status.replace(/_/g, " ")
|
|
2216
2026
|
}
|
|
2217
2027
|
) }),
|
|
@@ -2226,31 +2036,31 @@ const SwapDetailPage = () => {
|
|
|
2226
2036
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2227
2037
|
] })
|
|
2228
2038
|
] }),
|
|
2229
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2039
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2230
2040
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2231
2041
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2232
2042
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2233
2043
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2234
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2044
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
2235
2045
|
] }),
|
|
2236
2046
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2237
2047
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2238
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2048
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
2239
2049
|
] }),
|
|
2240
2050
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2241
2051
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2242
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((
|
|
2052
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
|
|
2243
2053
|
] }),
|
|
2244
|
-
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2054
|
+
returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2245
2055
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2246
2056
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2247
|
-
order.currency_code || "$",
|
|
2248
|
-
(Number(order.total) / 100).toFixed(2)
|
|
2057
|
+
returnOrder.order.currency_code || "$",
|
|
2058
|
+
(Number(returnOrder.order.total) / 100).toFixed(2)
|
|
2249
2059
|
] })
|
|
2250
2060
|
] })
|
|
2251
2061
|
] })
|
|
2252
2062
|
] }),
|
|
2253
|
-
|
|
2063
|
+
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: [
|
|
2254
2064
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2255
2065
|
/* @__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: [
|
|
2256
2066
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2258,152 +2068,22 @@ const SwapDetailPage = () => {
|
|
|
2258
2068
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2259
2069
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2260
2070
|
] }) }),
|
|
2261
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2071
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2262
2072
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2263
2073
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2264
2074
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2265
2075
|
] }, item.id || index)) })
|
|
2266
2076
|
] }) })
|
|
2267
2077
|
] }),
|
|
2268
|
-
|
|
2269
|
-
|
|
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
|
-
] })
|
|
2281
|
-
] }) });
|
|
2282
|
-
};
|
|
2283
|
-
const config$2 = defineRouteConfig({
|
|
2284
|
-
label: "Swap Details",
|
|
2285
|
-
icon: ArrowPath
|
|
2286
|
-
});
|
|
2287
|
-
const getStatusBadgeClass$1 = (status) => {
|
|
2288
|
-
const s2 = status.toLowerCase();
|
|
2289
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2290
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2291
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2292
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2293
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2294
|
-
};
|
|
2295
|
-
const PaymentDetailPage = () => {
|
|
2296
|
-
var _a;
|
|
2297
|
-
const navigate = useNavigate();
|
|
2298
|
-
const params = useParams();
|
|
2299
|
-
const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
|
|
2300
|
-
const [detail, setDetail] = useState(null);
|
|
2301
|
-
const [loading, setLoading] = useState(!!id);
|
|
2302
|
-
const [error, setError] = useState(null);
|
|
2303
|
-
useEffect(() => {
|
|
2304
|
-
if (!id) {
|
|
2305
|
-
setLoading(false);
|
|
2306
|
-
return;
|
|
2307
|
-
}
|
|
2308
|
-
let cancelled = false;
|
|
2309
|
-
setLoading(true);
|
|
2310
|
-
setError(null);
|
|
2311
|
-
fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
|
|
2312
|
-
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
2313
|
-
return res.json();
|
|
2314
|
-
}).then((data) => {
|
|
2315
|
-
if (!cancelled) setDetail(data);
|
|
2316
|
-
}).catch((e) => {
|
|
2317
|
-
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
2318
|
-
}).finally(() => {
|
|
2319
|
-
if (!cancelled) setLoading(false);
|
|
2320
|
-
});
|
|
2321
|
-
return () => {
|
|
2322
|
-
cancelled = true;
|
|
2323
|
-
};
|
|
2324
|
-
}, [id]);
|
|
2325
|
-
const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
|
|
2326
|
-
const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
|
|
2327
|
-
const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
|
|
2328
|
-
const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
|
|
2329
|
-
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: [
|
|
2330
|
-
/* @__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: [
|
|
2331
|
-
/* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
|
|
2332
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
|
|
2333
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
|
|
2334
|
-
] }) }),
|
|
2335
|
-
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2336
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2337
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
|
|
2338
|
-
] }) : 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: [
|
|
2339
|
-
/* @__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: [
|
|
2340
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2341
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
|
|
2342
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsx(
|
|
2343
|
-
Button,
|
|
2344
|
-
{
|
|
2345
|
-
variant: "transparent",
|
|
2346
|
-
size: "small",
|
|
2347
|
-
onClick: () => navigate(`/orders/${detail.order_id}`),
|
|
2348
|
-
children: detail.order_id
|
|
2349
|
-
}
|
|
2350
|
-
) : /* @__PURE__ */ jsx(Text, { children: "—" }) })
|
|
2351
|
-
] }),
|
|
2352
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2353
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
2354
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: displayAmount })
|
|
2355
|
-
] }),
|
|
2356
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2357
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
2358
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.provider_id })
|
|
2359
|
-
] }),
|
|
2360
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2361
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
2362
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
2363
|
-
Badge,
|
|
2364
|
-
{
|
|
2365
|
-
size: "2xsmall",
|
|
2366
|
-
className: `uppercase ${getStatusBadgeClass$1(displayStatus)}`,
|
|
2367
|
-
children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
|
|
2368
|
-
}
|
|
2369
|
-
) })
|
|
2370
|
-
] }),
|
|
2371
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2372
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
|
|
2373
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: sessionStatusRaw })
|
|
2374
|
-
] }),
|
|
2375
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2376
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
|
|
2377
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: paymentStatusRaw })
|
|
2378
|
-
] }),
|
|
2379
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2380
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
|
|
2381
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
|
|
2382
|
-
] }),
|
|
2383
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2384
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
|
|
2385
|
-
/* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
|
|
2386
|
-
year: "numeric",
|
|
2387
|
-
month: "short",
|
|
2388
|
-
day: "numeric",
|
|
2389
|
-
hour: "numeric",
|
|
2390
|
-
minute: "2-digit",
|
|
2391
|
-
hour12: true
|
|
2392
|
-
}) })
|
|
2393
|
-
] })
|
|
2394
|
-
] }) }),
|
|
2395
|
-
Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
2396
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
|
|
2397
|
-
/* @__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) })
|
|
2398
|
-
] }) : /* @__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." }) })
|
|
2399
|
-
] }) : null
|
|
2078
|
+
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 }) }),
|
|
2079
|
+
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" }) })
|
|
2400
2080
|
] }) });
|
|
2401
2081
|
};
|
|
2402
|
-
const config$
|
|
2403
|
-
label: "
|
|
2404
|
-
icon:
|
|
2082
|
+
const config$3 = defineRouteConfig({
|
|
2083
|
+
label: "Return Order Details",
|
|
2084
|
+
icon: CheckCircle
|
|
2405
2085
|
});
|
|
2406
|
-
const getStatusBadgeClass = (status) => {
|
|
2086
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
2407
2087
|
const statusLower = status.toLowerCase();
|
|
2408
2088
|
if (statusLower === "requested") {
|
|
2409
2089
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -2414,105 +2094,109 @@ const getStatusBadgeClass = (status) => {
|
|
|
2414
2094
|
if (statusLower === "rejected") {
|
|
2415
2095
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2416
2096
|
}
|
|
2417
|
-
if (statusLower === "received") {
|
|
2418
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2419
|
-
}
|
|
2420
|
-
if (statusLower === "refunded") {
|
|
2421
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2422
|
-
}
|
|
2423
2097
|
if (statusLower === "completed") {
|
|
2424
2098
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2425
2099
|
}
|
|
2426
|
-
if (statusLower === "cancelled") {
|
|
2100
|
+
if (statusLower === "cancelled" || statusLower === "canceled") {
|
|
2427
2101
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2428
2102
|
}
|
|
2103
|
+
if (statusLower === "pending") {
|
|
2104
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2105
|
+
}
|
|
2429
2106
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2430
2107
|
};
|
|
2431
|
-
const
|
|
2432
|
-
var _a, _b;
|
|
2108
|
+
const SwapDetailPage = () => {
|
|
2109
|
+
var _a, _b, _c;
|
|
2433
2110
|
const navigate = useNavigate();
|
|
2434
2111
|
const { id } = useParams();
|
|
2435
|
-
const [
|
|
2112
|
+
const [swap, setSwap] = useState(null);
|
|
2113
|
+
const [order, setOrder] = useState(null);
|
|
2436
2114
|
const [isLoading, setIsLoading] = useState(true);
|
|
2437
|
-
|
|
2115
|
+
useState(false);
|
|
2116
|
+
const [isCancelling, setIsCancelling] = useState(false);
|
|
2438
2117
|
const [error, setError] = useState(null);
|
|
2439
2118
|
const [updateError, setUpdateError] = useState(null);
|
|
2440
2119
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
2441
2120
|
useEffect(() => {
|
|
2442
2121
|
if (!id) {
|
|
2443
|
-
navigate("/
|
|
2122
|
+
navigate("/swaps");
|
|
2444
2123
|
return;
|
|
2445
2124
|
}
|
|
2446
|
-
const
|
|
2125
|
+
const loadSwap = async () => {
|
|
2447
2126
|
try {
|
|
2448
2127
|
setIsLoading(true);
|
|
2449
2128
|
setError(null);
|
|
2450
|
-
const response = await fetch(`/admin/
|
|
2129
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
2451
2130
|
credentials: "include"
|
|
2452
2131
|
});
|
|
2453
2132
|
if (!response.ok) {
|
|
2454
2133
|
const message = await response.text();
|
|
2455
|
-
throw new Error(message || "Unable to load
|
|
2134
|
+
throw new Error(message || "Unable to load swap");
|
|
2456
2135
|
}
|
|
2457
2136
|
const payload = await response.json();
|
|
2458
|
-
|
|
2137
|
+
setSwap(payload.swap);
|
|
2138
|
+
setOrder(payload.order || null);
|
|
2459
2139
|
} catch (loadError) {
|
|
2460
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
2140
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
2461
2141
|
setError(message);
|
|
2462
2142
|
} finally {
|
|
2463
2143
|
setIsLoading(false);
|
|
2464
2144
|
}
|
|
2465
2145
|
};
|
|
2466
|
-
void
|
|
2146
|
+
void loadSwap();
|
|
2467
2147
|
}, [id, navigate]);
|
|
2468
|
-
const
|
|
2148
|
+
const handleCancelExchange = async () => {
|
|
2469
2149
|
if (!id) {
|
|
2470
2150
|
return;
|
|
2471
2151
|
}
|
|
2472
2152
|
try {
|
|
2473
|
-
|
|
2153
|
+
setIsCancelling(true);
|
|
2474
2154
|
setUpdateError(null);
|
|
2475
2155
|
setUpdateSuccess(false);
|
|
2476
|
-
const response = await fetch(`/admin/
|
|
2156
|
+
const response = await fetch(`/admin/swaps/${id}/cancel`, {
|
|
2477
2157
|
method: "POST",
|
|
2478
2158
|
headers: {
|
|
2479
2159
|
"Content-Type": "application/json"
|
|
2480
2160
|
},
|
|
2481
|
-
credentials: "include"
|
|
2482
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
2161
|
+
credentials: "include"
|
|
2483
2162
|
});
|
|
2484
2163
|
if (!response.ok) {
|
|
2485
2164
|
const message = await response.text();
|
|
2486
|
-
throw new Error(message || "Unable to
|
|
2165
|
+
throw new Error(message || "Unable to cancel exchange");
|
|
2487
2166
|
}
|
|
2488
2167
|
const payload = await response.json();
|
|
2489
|
-
|
|
2168
|
+
setSwap(payload.swap);
|
|
2490
2169
|
setUpdateSuccess(true);
|
|
2491
2170
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
2492
|
-
const detailResponse = await fetch(`/admin/
|
|
2171
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
2493
2172
|
credentials: "include"
|
|
2494
2173
|
});
|
|
2495
2174
|
if (detailResponse.ok) {
|
|
2496
2175
|
const detailPayload = await detailResponse.json();
|
|
2497
|
-
|
|
2176
|
+
setSwap(detailPayload.swap);
|
|
2177
|
+
setOrder(detailPayload.order || null);
|
|
2498
2178
|
}
|
|
2499
|
-
} catch (
|
|
2500
|
-
const message =
|
|
2179
|
+
} catch (cancelErr) {
|
|
2180
|
+
const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
|
|
2501
2181
|
setUpdateError(message);
|
|
2502
2182
|
} finally {
|
|
2503
|
-
|
|
2183
|
+
setIsCancelling(false);
|
|
2504
2184
|
}
|
|
2505
2185
|
};
|
|
2186
|
+
const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
|
|
2187
|
+
const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
|
|
2188
|
+
((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
|
|
2189
|
+
);
|
|
2506
2190
|
if (isLoading) {
|
|
2507
|
-
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
|
|
2191
|
+
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..." }) }) }) });
|
|
2508
2192
|
}
|
|
2509
|
-
if (error || !
|
|
2193
|
+
if (error || !swap) {
|
|
2510
2194
|
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: [
|
|
2511
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
2512
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
2195
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
2196
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
2513
2197
|
] }) }) });
|
|
2514
2198
|
}
|
|
2515
|
-
const statusHistory = ((
|
|
2199
|
+
const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
|
|
2516
2200
|
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: [
|
|
2517
2201
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
2518
2202
|
/* @__PURE__ */ jsxs(
|
|
@@ -2520,7 +2204,7 @@ const ReturnDetailPage = () => {
|
|
|
2520
2204
|
{
|
|
2521
2205
|
variant: "transparent",
|
|
2522
2206
|
size: "small",
|
|
2523
|
-
onClick: () => navigate("/
|
|
2207
|
+
onClick: () => navigate("/swaps"),
|
|
2524
2208
|
className: "w-fit",
|
|
2525
2209
|
children: [
|
|
2526
2210
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -2530,81 +2214,67 @@ const ReturnDetailPage = () => {
|
|
|
2530
2214
|
),
|
|
2531
2215
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
2532
2216
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2533
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
2534
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2217
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
|
|
2218
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
2535
2219
|
] }),
|
|
2536
2220
|
/* @__PURE__ */ jsx(
|
|
2537
2221
|
Badge,
|
|
2538
2222
|
{
|
|
2539
2223
|
size: "small",
|
|
2540
|
-
className: `uppercase ${getStatusBadgeClass(
|
|
2541
|
-
children:
|
|
2224
|
+
className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
|
|
2225
|
+
children: swap.status.replace(/_/g, " ")
|
|
2542
2226
|
}
|
|
2543
2227
|
)
|
|
2544
2228
|
] })
|
|
2545
2229
|
] }),
|
|
2546
|
-
|
|
2230
|
+
canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2547
2231
|
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
|
|
2548
2232
|
Button,
|
|
2549
2233
|
{
|
|
2550
2234
|
variant: "danger",
|
|
2551
|
-
onClick:
|
|
2552
|
-
disabled:
|
|
2553
|
-
isLoading:
|
|
2554
|
-
children: "
|
|
2235
|
+
onClick: handleCancelExchange,
|
|
2236
|
+
disabled: isCancelling,
|
|
2237
|
+
isLoading: isCancelling,
|
|
2238
|
+
children: "Cancel Exchange"
|
|
2555
2239
|
}
|
|
2556
2240
|
) }),
|
|
2557
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
2558
|
-
] }),
|
|
2559
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2560
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
2561
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2562
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2563
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
2564
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
2565
|
-
] }),
|
|
2566
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2567
|
-
Button,
|
|
2568
|
-
{
|
|
2569
|
-
variant: "secondary",
|
|
2570
|
-
onClick: () => {
|
|
2571
|
-
window.open(
|
|
2572
|
-
`/app/orders/${returnOrder.order_id}`,
|
|
2573
|
-
"_blank"
|
|
2574
|
-
);
|
|
2575
|
-
},
|
|
2576
|
-
children: "View order"
|
|
2577
|
-
}
|
|
2578
|
-
) })
|
|
2579
|
-
] })
|
|
2241
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
|
|
2580
2242
|
] }),
|
|
2581
2243
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
2582
2244
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2583
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
2245
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
2584
2246
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2585
2247
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2586
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
2587
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2248
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2249
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
2588
2250
|
] }),
|
|
2589
2251
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2590
2252
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
2591
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2253
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
2592
2254
|
] }),
|
|
2593
|
-
|
|
2255
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2256
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
2257
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
2258
|
+
] }),
|
|
2259
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
2594
2260
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
2595
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2261
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
2596
2262
|
] }),
|
|
2597
|
-
|
|
2263
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
2598
2264
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
2599
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2265
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
2600
2266
|
] }),
|
|
2601
2267
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2602
2268
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
2603
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2269
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
2604
2270
|
] }),
|
|
2605
2271
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2606
2272
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
2607
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
2273
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
2274
|
+
] }),
|
|
2275
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
2276
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
2277
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
2608
2278
|
] })
|
|
2609
2279
|
] })
|
|
2610
2280
|
] }),
|
|
@@ -2619,7 +2289,7 @@ const ReturnDetailPage = () => {
|
|
|
2619
2289
|
Badge,
|
|
2620
2290
|
{
|
|
2621
2291
|
size: "2xsmall",
|
|
2622
|
-
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
2292
|
+
className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
|
|
2623
2293
|
children: entry.status.replace(/_/g, " ")
|
|
2624
2294
|
}
|
|
2625
2295
|
) }),
|
|
@@ -2634,31 +2304,31 @@ const ReturnDetailPage = () => {
|
|
|
2634
2304
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
2635
2305
|
] })
|
|
2636
2306
|
] }),
|
|
2637
|
-
|
|
2307
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
2638
2308
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
2639
2309
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2640
2310
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2641
2311
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
2642
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2312
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
2643
2313
|
] }),
|
|
2644
2314
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2645
2315
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
2646
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
2316
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
2647
2317
|
] }),
|
|
2648
2318
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2649
2319
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
2650
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((
|
|
2320
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
|
|
2651
2321
|
] }),
|
|
2652
|
-
|
|
2322
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
2653
2323
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
2654
2324
|
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
2655
|
-
|
|
2656
|
-
(Number(
|
|
2325
|
+
order.currency_code || "$",
|
|
2326
|
+
(Number(order.total) / 100).toFixed(2)
|
|
2657
2327
|
] })
|
|
2658
2328
|
] })
|
|
2659
2329
|
] })
|
|
2660
2330
|
] }),
|
|
2661
|
-
|
|
2331
|
+
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: [
|
|
2662
2332
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
2663
2333
|
/* @__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: [
|
|
2664
2334
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
@@ -2666,117 +2336,447 @@ const ReturnDetailPage = () => {
|
|
|
2666
2336
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
2667
2337
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
2668
2338
|
] }) }),
|
|
2669
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
2339
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2670
2340
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
2671
2341
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
2672
2342
|
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
2673
2343
|
] }, item.id || index)) })
|
|
2674
2344
|
] }) })
|
|
2675
2345
|
] }),
|
|
2676
|
-
|
|
2677
|
-
|
|
2346
|
+
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: [
|
|
2347
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
2348
|
+
/* @__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: [
|
|
2349
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2350
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
2351
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
2352
|
+
] }) }),
|
|
2353
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
2354
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
2355
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
2356
|
+
] }, item.variant_id || index)) })
|
|
2357
|
+
] }) })
|
|
2358
|
+
] })
|
|
2678
2359
|
] }) });
|
|
2679
2360
|
};
|
|
2680
|
-
const config = defineRouteConfig({
|
|
2681
|
-
label: "
|
|
2682
|
-
icon:
|
|
2361
|
+
const config$2 = defineRouteConfig({
|
|
2362
|
+
label: "Swap Details",
|
|
2363
|
+
icon: ArrowPath
|
|
2683
2364
|
});
|
|
2684
|
-
const
|
|
2685
|
-
const
|
|
2686
|
-
{
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
},
|
|
2690
|
-
|
|
2691
|
-
Component: OrderRefundContextWidget,
|
|
2692
|
-
zone: ["order.details.after"]
|
|
2693
|
-
}
|
|
2694
|
-
] };
|
|
2695
|
-
const routeModule = {
|
|
2696
|
-
routes: [
|
|
2697
|
-
{
|
|
2698
|
-
Component: RefundsPage,
|
|
2699
|
-
path: "/refunds"
|
|
2700
|
-
},
|
|
2701
|
-
{
|
|
2702
|
-
Component: ReturnsPage,
|
|
2703
|
-
path: "/returns"
|
|
2704
|
-
},
|
|
2705
|
-
{
|
|
2706
|
-
Component: PaymentsPage,
|
|
2707
|
-
path: "/payments"
|
|
2708
|
-
},
|
|
2709
|
-
{
|
|
2710
|
-
Component: SwapsPage,
|
|
2711
|
-
path: "/swaps"
|
|
2712
|
-
},
|
|
2713
|
-
{
|
|
2714
|
-
Component: RefundDetailPage,
|
|
2715
|
-
path: "/refunds/:id"
|
|
2716
|
-
},
|
|
2717
|
-
{
|
|
2718
|
-
Component: SwapDetailPage,
|
|
2719
|
-
path: "/swaps/:id"
|
|
2720
|
-
},
|
|
2721
|
-
{
|
|
2722
|
-
Component: PaymentDetailPage,
|
|
2723
|
-
path: "/payments/:id"
|
|
2724
|
-
},
|
|
2725
|
-
{
|
|
2726
|
-
Component: ReturnDetailPage,
|
|
2727
|
-
path: "/returns/:id"
|
|
2728
|
-
}
|
|
2729
|
-
]
|
|
2365
|
+
const useDebounce = (value, delay) => {
|
|
2366
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
2367
|
+
useEffect(() => {
|
|
2368
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
2369
|
+
return () => clearTimeout(handler);
|
|
2370
|
+
}, [value, delay]);
|
|
2371
|
+
return debouncedValue;
|
|
2730
2372
|
};
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2373
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
2374
|
+
const s2 = status.toLowerCase();
|
|
2375
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2376
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2377
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2378
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2379
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2380
|
+
};
|
|
2381
|
+
const PaymentsPage = () => {
|
|
2382
|
+
const navigate = useNavigate();
|
|
2383
|
+
const [items, setItems] = useState([]);
|
|
2384
|
+
const [statusFilter, setStatusFilter] = useState("all");
|
|
2385
|
+
const [orderIdSearch, setOrderIdSearch] = useState("");
|
|
2386
|
+
const debouncedOrderId = useDebounce(orderIdSearch, 300);
|
|
2387
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
2388
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
2389
|
+
const [error, setError] = useState(null);
|
|
2390
|
+
const [offset, setOffset] = useState(0);
|
|
2391
|
+
const [count, setCount] = useState(0);
|
|
2392
|
+
const limit = 50;
|
|
2393
|
+
const loadTransactions = useCallback(
|
|
2394
|
+
async (nextOffset, replace) => {
|
|
2395
|
+
try {
|
|
2396
|
+
if (replace) setIsLoading(true);
|
|
2397
|
+
else setIsFetchingMore(true);
|
|
2398
|
+
setError(null);
|
|
2399
|
+
const params = new URLSearchParams();
|
|
2400
|
+
params.set("limit", String(limit));
|
|
2401
|
+
params.set("offset", String(nextOffset));
|
|
2402
|
+
if (statusFilter !== "all") params.set("status", statusFilter);
|
|
2403
|
+
if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
|
|
2404
|
+
const response = await fetch(
|
|
2405
|
+
`/admin/payment-transactions?${params.toString()}`,
|
|
2406
|
+
{ credentials: "include" }
|
|
2407
|
+
);
|
|
2408
|
+
if (!response.ok) {
|
|
2409
|
+
const text = await response.text();
|
|
2410
|
+
throw new Error(text || "Failed to load payment transactions");
|
|
2411
|
+
}
|
|
2412
|
+
const payload = await response.json();
|
|
2413
|
+
const list = payload.transactions ?? [];
|
|
2414
|
+
setCount(payload.count ?? 0);
|
|
2415
|
+
setOffset(nextOffset + list.length);
|
|
2416
|
+
setItems((prev) => replace ? list : [...prev, ...list]);
|
|
2417
|
+
} catch (e) {
|
|
2418
|
+
setError(e instanceof Error ? e.message : "Failed to load");
|
|
2419
|
+
} finally {
|
|
2420
|
+
setIsLoading(false);
|
|
2421
|
+
setIsFetchingMore(false);
|
|
2422
|
+
}
|
|
2423
|
+
},
|
|
2424
|
+
[statusFilter, debouncedOrderId]
|
|
2425
|
+
);
|
|
2426
|
+
useEffect(() => {
|
|
2427
|
+
void loadTransactions(0, true);
|
|
2428
|
+
}, [loadTransactions]);
|
|
2429
|
+
const hasMore = useMemo(() => offset < count, [offset, count]);
|
|
2430
|
+
const displayStatus = (t) => {
|
|
2431
|
+
const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
|
|
2432
|
+
return s2 !== "" ? s2 : "—";
|
|
2433
|
+
};
|
|
2434
|
+
const displayAmount = (t) => {
|
|
2435
|
+
const code = (t.currency_code ?? "USD").toUpperCase();
|
|
2436
|
+
return `${code} ${Number(t.amount)}`;
|
|
2437
|
+
};
|
|
2438
|
+
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: [
|
|
2439
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2440
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2441
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
|
|
2442
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
|
|
2443
|
+
] }),
|
|
2444
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
|
|
2445
|
+
] }),
|
|
2446
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2447
|
+
/* @__PURE__ */ jsx(
|
|
2448
|
+
Input,
|
|
2449
|
+
{
|
|
2450
|
+
placeholder: "Search by Order ID",
|
|
2451
|
+
value: orderIdSearch,
|
|
2452
|
+
onChange: (e) => setOrderIdSearch(e.target.value),
|
|
2453
|
+
className: "md:max-w-sm",
|
|
2454
|
+
"aria-label": "Search by order ID"
|
|
2455
|
+
}
|
|
2456
|
+
),
|
|
2457
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
|
|
2458
|
+
"select",
|
|
2459
|
+
{
|
|
2460
|
+
value: statusFilter,
|
|
2461
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
2462
|
+
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",
|
|
2463
|
+
"aria-label": "Filter by status",
|
|
2464
|
+
children: [
|
|
2465
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
|
|
2466
|
+
/* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
|
|
2467
|
+
/* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
|
|
2468
|
+
/* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
|
|
2469
|
+
/* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
|
|
2470
|
+
/* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
|
|
2471
|
+
/* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
|
|
2472
|
+
]
|
|
2473
|
+
}
|
|
2474
|
+
) })
|
|
2475
|
+
] }),
|
|
2476
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2477
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2478
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
|
|
2479
|
+
] }) : null,
|
|
2480
|
+
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: [
|
|
2481
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
|
|
2482
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
|
|
2483
|
+
] }) : /* @__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: [
|
|
2484
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2485
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
2486
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
|
|
2487
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
|
|
2488
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
2489
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
|
|
2490
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
2491
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
2492
|
+
] }) }),
|
|
2493
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
|
|
2494
|
+
"tr",
|
|
2495
|
+
{
|
|
2496
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
2497
|
+
onClick: () => navigate(`/payments/${t.payment_session_id}`),
|
|
2498
|
+
children: [
|
|
2499
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
|
|
2500
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
|
|
2501
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
|
|
2502
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
|
|
2503
|
+
Badge,
|
|
2504
|
+
{
|
|
2505
|
+
size: "2xsmall",
|
|
2506
|
+
className: `uppercase ${getStatusBadgeClass$1(displayStatus(t))}`,
|
|
2507
|
+
children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
|
|
2508
|
+
}
|
|
2509
|
+
) }),
|
|
2510
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
|
|
2511
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
|
|
2512
|
+
year: "numeric",
|
|
2513
|
+
month: "short",
|
|
2514
|
+
day: "numeric",
|
|
2515
|
+
hour: "numeric",
|
|
2516
|
+
minute: "2-digit",
|
|
2517
|
+
hour12: true
|
|
2518
|
+
}) }),
|
|
2519
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
|
|
2520
|
+
/* @__PURE__ */ jsx(
|
|
2521
|
+
Button,
|
|
2522
|
+
{
|
|
2523
|
+
variant: "transparent",
|
|
2524
|
+
size: "small",
|
|
2525
|
+
onClick: (e) => {
|
|
2526
|
+
e.stopPropagation();
|
|
2527
|
+
navigate(`/payments/${t.payment_session_id}`);
|
|
2528
|
+
},
|
|
2529
|
+
children: "View details"
|
|
2530
|
+
}
|
|
2531
|
+
),
|
|
2532
|
+
t.order_id ? /* @__PURE__ */ jsx(
|
|
2533
|
+
Button,
|
|
2534
|
+
{
|
|
2535
|
+
variant: "transparent",
|
|
2536
|
+
size: "small",
|
|
2537
|
+
onClick: (e) => {
|
|
2538
|
+
e.stopPropagation();
|
|
2539
|
+
navigate(`/orders/${t.order_id}`);
|
|
2540
|
+
},
|
|
2541
|
+
children: "Order"
|
|
2542
|
+
}
|
|
2543
|
+
) : null
|
|
2544
|
+
] })
|
|
2545
|
+
]
|
|
2546
|
+
},
|
|
2547
|
+
t.payment_session_id
|
|
2548
|
+
)) })
|
|
2549
|
+
] }) }),
|
|
2550
|
+
hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
2551
|
+
Button,
|
|
2552
|
+
{
|
|
2553
|
+
variant: "secondary",
|
|
2554
|
+
isLoading: isFetchingMore,
|
|
2555
|
+
onClick: () => loadTransactions(offset, false),
|
|
2556
|
+
children: "Load more"
|
|
2557
|
+
}
|
|
2558
|
+
) }) : null
|
|
2559
|
+
] }) });
|
|
2560
|
+
};
|
|
2561
|
+
const config$1 = defineRouteConfig({
|
|
2562
|
+
label: "Payments",
|
|
2563
|
+
icon: CreditCard
|
|
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
|
+
] }) });
|
|
2679
|
+
};
|
|
2680
|
+
const config = defineRouteConfig({
|
|
2681
|
+
label: "Payment details",
|
|
2682
|
+
icon: CreditCard
|
|
2683
|
+
});
|
|
2684
|
+
const i18nTranslations0 = {};
|
|
2685
|
+
const widgetModule = { widgets: [
|
|
2686
|
+
{
|
|
2687
|
+
Component: OrderGiftItemsWidget,
|
|
2688
|
+
zone: ["order.details.side.after"]
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
Component: OrderRefundContextWidget,
|
|
2692
|
+
zone: ["order.details.after"]
|
|
2693
|
+
}
|
|
2694
|
+
] };
|
|
2695
|
+
const routeModule = {
|
|
2696
|
+
routes: [
|
|
2697
|
+
{
|
|
2698
|
+
Component: RefundsPage,
|
|
2699
|
+
path: "/refunds"
|
|
2750
2700
|
},
|
|
2751
2701
|
{
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
path: "/swaps",
|
|
2755
|
-
nested: void 0
|
|
2702
|
+
Component: ReturnsPage,
|
|
2703
|
+
path: "/returns"
|
|
2756
2704
|
},
|
|
2757
2705
|
{
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2706
|
+
Component: SwapsPage,
|
|
2707
|
+
path: "/swaps"
|
|
2708
|
+
},
|
|
2709
|
+
{
|
|
2710
|
+
Component: RefundDetailPage,
|
|
2711
|
+
path: "/refunds/:id"
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
Component: ReturnDetailPage,
|
|
2715
|
+
path: "/returns/:id"
|
|
2716
|
+
},
|
|
2717
|
+
{
|
|
2718
|
+
Component: SwapDetailPage,
|
|
2719
|
+
path: "/swaps/:id"
|
|
2720
|
+
},
|
|
2721
|
+
{
|
|
2722
|
+
Component: PaymentsPage,
|
|
2723
|
+
path: "/payments"
|
|
2724
|
+
},
|
|
2725
|
+
{
|
|
2726
|
+
Component: PaymentDetailPage,
|
|
2727
|
+
path: "/payments/:id"
|
|
2728
|
+
}
|
|
2729
|
+
]
|
|
2730
|
+
};
|
|
2731
|
+
const menuItemModule = {
|
|
2732
|
+
menuItems: [
|
|
2733
|
+
{
|
|
2734
|
+
label: config$6.label,
|
|
2735
|
+
icon: config$6.icon,
|
|
2736
|
+
path: "/returns",
|
|
2761
2737
|
nested: void 0
|
|
2762
2738
|
},
|
|
2763
2739
|
{
|
|
2764
2740
|
label: config$1.label,
|
|
2765
2741
|
icon: config$1.icon,
|
|
2766
|
-
path: "/payments
|
|
2742
|
+
path: "/payments",
|
|
2767
2743
|
nested: void 0
|
|
2768
2744
|
},
|
|
2769
2745
|
{
|
|
2770
|
-
label: config$
|
|
2771
|
-
icon: config$
|
|
2772
|
-
path: "/
|
|
2746
|
+
label: config$7.label,
|
|
2747
|
+
icon: config$7.icon,
|
|
2748
|
+
path: "/refunds",
|
|
2749
|
+
nested: void 0
|
|
2750
|
+
},
|
|
2751
|
+
{
|
|
2752
|
+
label: config$5.label,
|
|
2753
|
+
icon: config$5.icon,
|
|
2754
|
+
path: "/swaps",
|
|
2773
2755
|
nested: void 0
|
|
2774
2756
|
},
|
|
2775
2757
|
{
|
|
2776
2758
|
label: config$3.label,
|
|
2777
2759
|
icon: config$3.icon,
|
|
2760
|
+
path: "/returns/:id",
|
|
2761
|
+
nested: void 0
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
label: config$4.label,
|
|
2765
|
+
icon: config$4.icon,
|
|
2778
2766
|
path: "/refunds/:id",
|
|
2779
2767
|
nested: void 0
|
|
2768
|
+
},
|
|
2769
|
+
{
|
|
2770
|
+
label: config.label,
|
|
2771
|
+
icon: config.icon,
|
|
2772
|
+
path: "/payments/:id",
|
|
2773
|
+
nested: void 0
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
label: config$2.label,
|
|
2777
|
+
icon: config$2.icon,
|
|
2778
|
+
path: "/swaps/:id",
|
|
2779
|
+
nested: void 0
|
|
2780
2780
|
}
|
|
2781
2781
|
]
|
|
2782
2782
|
};
|