order-management 0.0.111 → 0.0.112
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 +499 -499
- package/.medusa/server/src/admin/index.mjs +499 -499
- package/package.json +1 -1
|
@@ -2420,247 +2420,6 @@ const useDebounce$2 = (value, delay) => {
|
|
|
2420
2420
|
return debouncedValue;
|
|
2421
2421
|
};
|
|
2422
2422
|
const getStatusBadgeClass$6 = (status) => {
|
|
2423
|
-
const statusLower = status.toLowerCase();
|
|
2424
|
-
if (statusLower === "requested") {
|
|
2425
|
-
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2426
|
-
}
|
|
2427
|
-
if (statusLower === "received") {
|
|
2428
|
-
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2429
|
-
}
|
|
2430
|
-
if (statusLower === "requires_action") {
|
|
2431
|
-
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2432
|
-
}
|
|
2433
|
-
if (statusLower === "completed") {
|
|
2434
|
-
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2435
|
-
}
|
|
2436
|
-
if (statusLower === "canceled") {
|
|
2437
|
-
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2438
|
-
}
|
|
2439
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2440
|
-
};
|
|
2441
|
-
const ReturnsPage = () => {
|
|
2442
|
-
const navigate = reactRouterDom.useNavigate();
|
|
2443
|
-
const [items, setItems] = react.useState([]);
|
|
2444
|
-
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
2445
|
-
const [createdByFilter, setCreatedByFilter] = react.useState("all");
|
|
2446
|
-
const [searchQuery, setSearchQuery] = react.useState("");
|
|
2447
|
-
const debouncedSearchQuery = useDebounce$2(searchQuery, 300);
|
|
2448
|
-
const [isLoading, setIsLoading] = react.useState(true);
|
|
2449
|
-
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
2450
|
-
const [error, setError] = react.useState(null);
|
|
2451
|
-
const [offset, setOffset] = react.useState(0);
|
|
2452
|
-
const [count, setCount] = react.useState(0);
|
|
2453
|
-
const limit = 50;
|
|
2454
|
-
const loadReturns = react.useCallback(
|
|
2455
|
-
async (nextOffset, replace = false) => {
|
|
2456
|
-
try {
|
|
2457
|
-
if (replace) {
|
|
2458
|
-
setIsLoading(true);
|
|
2459
|
-
} else {
|
|
2460
|
-
setIsFetchingMore(true);
|
|
2461
|
-
}
|
|
2462
|
-
setError(null);
|
|
2463
|
-
const params = new URLSearchParams();
|
|
2464
|
-
params.set("limit", String(limit));
|
|
2465
|
-
params.set("offset", String(nextOffset));
|
|
2466
|
-
if (statusFilter !== "all") {
|
|
2467
|
-
params.set("status", statusFilter);
|
|
2468
|
-
}
|
|
2469
|
-
if (debouncedSearchQuery.trim()) {
|
|
2470
|
-
params.set("q", debouncedSearchQuery.trim());
|
|
2471
|
-
}
|
|
2472
|
-
if (createdByFilter !== "all") {
|
|
2473
|
-
params.set("created_by", createdByFilter);
|
|
2474
|
-
}
|
|
2475
|
-
params.set("order", "created_at");
|
|
2476
|
-
const response = await fetch(
|
|
2477
|
-
`/admin/return?${params.toString()}`,
|
|
2478
|
-
{ credentials: "include" }
|
|
2479
|
-
);
|
|
2480
|
-
if (!response.ok) {
|
|
2481
|
-
const message = await response.text();
|
|
2482
|
-
throw new Error(message || "Unable to load return orders");
|
|
2483
|
-
}
|
|
2484
|
-
const payload = await response.json();
|
|
2485
|
-
setCount(payload.count ?? 0);
|
|
2486
|
-
setOffset(nextOffset + (payload.returns?.length ?? 0));
|
|
2487
|
-
setItems(
|
|
2488
|
-
(prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
|
|
2489
|
-
);
|
|
2490
|
-
} catch (loadError) {
|
|
2491
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
|
|
2492
|
-
setError(message);
|
|
2493
|
-
} finally {
|
|
2494
|
-
setIsLoading(false);
|
|
2495
|
-
setIsFetchingMore(false);
|
|
2496
|
-
}
|
|
2497
|
-
},
|
|
2498
|
-
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
2499
|
-
);
|
|
2500
|
-
react.useEffect(() => {
|
|
2501
|
-
void loadReturns(0, true);
|
|
2502
|
-
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadReturns]);
|
|
2503
|
-
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
2504
|
-
const availableStatuses = react.useMemo(() => {
|
|
2505
|
-
const statuses = /* @__PURE__ */ new Set();
|
|
2506
|
-
items.forEach((item) => statuses.add(item.status));
|
|
2507
|
-
return Array.from(statuses).sort();
|
|
2508
|
-
}, [items]);
|
|
2509
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
2510
|
-
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2511
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2512
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
|
|
2513
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
|
|
2514
|
-
] }),
|
|
2515
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
|
|
2516
|
-
] }),
|
|
2517
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2518
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2519
|
-
ui.Input,
|
|
2520
|
-
{
|
|
2521
|
-
placeholder: "Search by return ID, order ID, or customer email",
|
|
2522
|
-
value: searchQuery,
|
|
2523
|
-
onChange: (event) => setSearchQuery(event.target.value),
|
|
2524
|
-
className: "md:max-w-sm"
|
|
2525
|
-
}
|
|
2526
|
-
),
|
|
2527
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
2528
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2529
|
-
"select",
|
|
2530
|
-
{
|
|
2531
|
-
value: createdByFilter,
|
|
2532
|
-
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
2533
|
-
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",
|
|
2534
|
-
children: [
|
|
2535
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
|
|
2536
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
|
|
2537
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
|
|
2538
|
-
]
|
|
2539
|
-
}
|
|
2540
|
-
),
|
|
2541
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2542
|
-
"select",
|
|
2543
|
-
{
|
|
2544
|
-
value: statusFilter,
|
|
2545
|
-
onChange: (event) => setStatusFilter(event.target.value),
|
|
2546
|
-
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",
|
|
2547
|
-
children: [
|
|
2548
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
|
|
2549
|
-
availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
2550
|
-
]
|
|
2551
|
-
}
|
|
2552
|
-
)
|
|
2553
|
-
] })
|
|
2554
|
-
] }),
|
|
2555
|
-
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2556
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2557
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2558
|
-
ui.Button,
|
|
2559
|
-
{
|
|
2560
|
-
variant: "secondary",
|
|
2561
|
-
onClick: () => loadReturns(0, true),
|
|
2562
|
-
children: "Try again"
|
|
2563
|
-
}
|
|
2564
|
-
) })
|
|
2565
|
-
] }) : null,
|
|
2566
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
2567
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
|
|
2568
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
|
|
2569
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2570
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2571
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
|
|
2572
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
2573
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
|
|
2574
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
2575
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
|
|
2576
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
2577
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
2578
|
-
] }) }),
|
|
2579
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2580
|
-
"tr",
|
|
2581
|
-
{
|
|
2582
|
-
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
2583
|
-
onClick: () => navigate(`/returns/${returnOrder.id}`),
|
|
2584
|
-
children: [
|
|
2585
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
|
|
2586
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
|
|
2587
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
|
|
2588
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2589
|
-
ui.Badge,
|
|
2590
|
-
{
|
|
2591
|
-
size: "2xsmall",
|
|
2592
|
-
className: `uppercase ${getStatusBadgeClass$6(returnOrder.status)}`,
|
|
2593
|
-
children: returnOrder.status.replace(/_/g, " ")
|
|
2594
|
-
}
|
|
2595
|
-
) }),
|
|
2596
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
2597
|
-
const calc = returnOrder.refund;
|
|
2598
|
-
if (calc?.is_processed && calc.final_refund_amount != null) {
|
|
2599
|
-
return formatRefundCurrency(
|
|
2600
|
-
calc.final_refund_amount,
|
|
2601
|
-
calc.currency_code || returnOrder.currency_code
|
|
2602
|
-
);
|
|
2603
|
-
}
|
|
2604
|
-
if (calc) {
|
|
2605
|
-
return "Pending";
|
|
2606
|
-
}
|
|
2607
|
-
if (returnOrder.refund_amount == null) {
|
|
2608
|
-
return "—";
|
|
2609
|
-
}
|
|
2610
|
-
return formatRefundCurrency(
|
|
2611
|
-
Number(returnOrder.refund_amount),
|
|
2612
|
-
returnOrder.currency_code
|
|
2613
|
-
);
|
|
2614
|
-
})() }),
|
|
2615
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
|
|
2616
|
-
year: "numeric",
|
|
2617
|
-
month: "short",
|
|
2618
|
-
day: "numeric",
|
|
2619
|
-
hour: "numeric",
|
|
2620
|
-
minute: "2-digit",
|
|
2621
|
-
hour12: true
|
|
2622
|
-
}) }),
|
|
2623
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2624
|
-
ui.Button,
|
|
2625
|
-
{
|
|
2626
|
-
variant: "transparent",
|
|
2627
|
-
size: "small",
|
|
2628
|
-
onClick: (e) => {
|
|
2629
|
-
e.stopPropagation();
|
|
2630
|
-
navigate(`/app/orders/${returnOrder.order_id}`);
|
|
2631
|
-
},
|
|
2632
|
-
children: "Go to order"
|
|
2633
|
-
}
|
|
2634
|
-
) })
|
|
2635
|
-
]
|
|
2636
|
-
},
|
|
2637
|
-
returnOrder.id
|
|
2638
|
-
)) })
|
|
2639
|
-
] }) }),
|
|
2640
|
-
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2641
|
-
ui.Button,
|
|
2642
|
-
{
|
|
2643
|
-
variant: "secondary",
|
|
2644
|
-
isLoading: isFetchingMore,
|
|
2645
|
-
onClick: () => loadReturns(offset, false),
|
|
2646
|
-
children: "Load more"
|
|
2647
|
-
}
|
|
2648
|
-
) }) : null
|
|
2649
|
-
] }) });
|
|
2650
|
-
};
|
|
2651
|
-
const config$7 = adminSdk.defineRouteConfig({
|
|
2652
|
-
label: "Return Orders",
|
|
2653
|
-
icon: icons.ArrowPath
|
|
2654
|
-
});
|
|
2655
|
-
const useDebounce$1 = (value, delay) => {
|
|
2656
|
-
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
2657
|
-
react.useEffect(() => {
|
|
2658
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
2659
|
-
return () => clearTimeout(handler);
|
|
2660
|
-
}, [value, delay]);
|
|
2661
|
-
return debouncedValue;
|
|
2662
|
-
};
|
|
2663
|
-
const getStatusBadgeClass$5 = (status) => {
|
|
2664
2423
|
const s2 = status.toLowerCase();
|
|
2665
2424
|
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2666
2425
|
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
@@ -2672,12 +2431,12 @@ const RefundsPage = () => {
|
|
|
2672
2431
|
const navigate = reactRouterDom.useNavigate();
|
|
2673
2432
|
const [items, setItems] = react.useState([]);
|
|
2674
2433
|
const [orderIdSearch, setOrderIdSearch] = react.useState("");
|
|
2675
|
-
const debouncedOrderId = useDebounce$
|
|
2434
|
+
const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
|
|
2676
2435
|
const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
|
|
2677
2436
|
const [providerSearch, setProviderSearch] = react.useState("");
|
|
2678
|
-
const debouncedProvider = useDebounce$
|
|
2437
|
+
const debouncedProvider = useDebounce$2(providerSearch, 300);
|
|
2679
2438
|
const [currencySearch, setCurrencySearch] = react.useState("");
|
|
2680
|
-
const debouncedCurrency = useDebounce$
|
|
2439
|
+
const debouncedCurrency = useDebounce$2(currencySearch, 300);
|
|
2681
2440
|
const [dateFrom, setDateFrom] = react.useState("");
|
|
2682
2441
|
const [dateTo, setDateTo] = react.useState("");
|
|
2683
2442
|
const [amountMin, setAmountMin] = react.useState("");
|
|
@@ -2889,47 +2648,288 @@ const RefundsPage = () => {
|
|
|
2889
2648
|
ui.Badge,
|
|
2890
2649
|
{
|
|
2891
2650
|
size: "2xsmall",
|
|
2892
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
2893
|
-
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
2651
|
+
className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
|
|
2652
|
+
children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
|
|
2653
|
+
}
|
|
2654
|
+
) }),
|
|
2655
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
|
|
2657
|
+
month: "short",
|
|
2658
|
+
day: "numeric",
|
|
2659
|
+
hour: "numeric",
|
|
2660
|
+
minute: "2-digit",
|
|
2661
|
+
hour12: true
|
|
2662
|
+
}) }),
|
|
2663
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
2664
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2665
|
+
ui.Button,
|
|
2666
|
+
{
|
|
2667
|
+
variant: "transparent",
|
|
2668
|
+
size: "small",
|
|
2669
|
+
onClick: (e) => {
|
|
2670
|
+
e.stopPropagation();
|
|
2671
|
+
navigate(`/refunds/${r.refund_id}`);
|
|
2672
|
+
},
|
|
2673
|
+
children: "Details"
|
|
2674
|
+
}
|
|
2675
|
+
),
|
|
2676
|
+
r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2677
|
+
ui.Button,
|
|
2678
|
+
{
|
|
2679
|
+
variant: "transparent",
|
|
2680
|
+
size: "small",
|
|
2681
|
+
onClick: (e) => {
|
|
2682
|
+
e.stopPropagation();
|
|
2683
|
+
navigate(`/orders/${r.order_id}`);
|
|
2684
|
+
},
|
|
2685
|
+
children: "Order"
|
|
2686
|
+
}
|
|
2687
|
+
) : null
|
|
2688
|
+
] }) })
|
|
2689
|
+
]
|
|
2690
|
+
},
|
|
2691
|
+
r.refund_id
|
|
2692
|
+
)) })
|
|
2693
|
+
] }) }),
|
|
2694
|
+
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2695
|
+
ui.Button,
|
|
2696
|
+
{
|
|
2697
|
+
variant: "secondary",
|
|
2698
|
+
isLoading: isFetchingMore,
|
|
2699
|
+
onClick: () => loadRefunds(offset, false),
|
|
2700
|
+
children: "Load more"
|
|
2701
|
+
}
|
|
2702
|
+
) }) : null
|
|
2703
|
+
] }) });
|
|
2704
|
+
};
|
|
2705
|
+
const config$7 = adminSdk.defineRouteConfig({
|
|
2706
|
+
label: "Refunds",
|
|
2707
|
+
icon: icons.Receipt
|
|
2708
|
+
});
|
|
2709
|
+
const useDebounce$1 = (value, delay) => {
|
|
2710
|
+
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
2711
|
+
react.useEffect(() => {
|
|
2712
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
2713
|
+
return () => clearTimeout(handler);
|
|
2714
|
+
}, [value, delay]);
|
|
2715
|
+
return debouncedValue;
|
|
2716
|
+
};
|
|
2717
|
+
const getStatusBadgeClass$5 = (status) => {
|
|
2718
|
+
const statusLower = status.toLowerCase();
|
|
2719
|
+
if (statusLower === "requested") {
|
|
2720
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
2721
|
+
}
|
|
2722
|
+
if (statusLower === "received") {
|
|
2723
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
2724
|
+
}
|
|
2725
|
+
if (statusLower === "requires_action") {
|
|
2726
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
2727
|
+
}
|
|
2728
|
+
if (statusLower === "completed") {
|
|
2729
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
2730
|
+
}
|
|
2731
|
+
if (statusLower === "canceled") {
|
|
2732
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
2733
|
+
}
|
|
2734
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
2735
|
+
};
|
|
2736
|
+
const ReturnsPage = () => {
|
|
2737
|
+
const navigate = reactRouterDom.useNavigate();
|
|
2738
|
+
const [items, setItems] = react.useState([]);
|
|
2739
|
+
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
2740
|
+
const [createdByFilter, setCreatedByFilter] = react.useState("all");
|
|
2741
|
+
const [searchQuery, setSearchQuery] = react.useState("");
|
|
2742
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
2743
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
2744
|
+
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
2745
|
+
const [error, setError] = react.useState(null);
|
|
2746
|
+
const [offset, setOffset] = react.useState(0);
|
|
2747
|
+
const [count, setCount] = react.useState(0);
|
|
2748
|
+
const limit = 50;
|
|
2749
|
+
const loadReturns = react.useCallback(
|
|
2750
|
+
async (nextOffset, replace = false) => {
|
|
2751
|
+
try {
|
|
2752
|
+
if (replace) {
|
|
2753
|
+
setIsLoading(true);
|
|
2754
|
+
} else {
|
|
2755
|
+
setIsFetchingMore(true);
|
|
2756
|
+
}
|
|
2757
|
+
setError(null);
|
|
2758
|
+
const params = new URLSearchParams();
|
|
2759
|
+
params.set("limit", String(limit));
|
|
2760
|
+
params.set("offset", String(nextOffset));
|
|
2761
|
+
if (statusFilter !== "all") {
|
|
2762
|
+
params.set("status", statusFilter);
|
|
2763
|
+
}
|
|
2764
|
+
if (debouncedSearchQuery.trim()) {
|
|
2765
|
+
params.set("q", debouncedSearchQuery.trim());
|
|
2766
|
+
}
|
|
2767
|
+
if (createdByFilter !== "all") {
|
|
2768
|
+
params.set("created_by", createdByFilter);
|
|
2769
|
+
}
|
|
2770
|
+
params.set("order", "created_at");
|
|
2771
|
+
const response = await fetch(
|
|
2772
|
+
`/admin/return?${params.toString()}`,
|
|
2773
|
+
{ credentials: "include" }
|
|
2774
|
+
);
|
|
2775
|
+
if (!response.ok) {
|
|
2776
|
+
const message = await response.text();
|
|
2777
|
+
throw new Error(message || "Unable to load return orders");
|
|
2778
|
+
}
|
|
2779
|
+
const payload = await response.json();
|
|
2780
|
+
setCount(payload.count ?? 0);
|
|
2781
|
+
setOffset(nextOffset + (payload.returns?.length ?? 0));
|
|
2782
|
+
setItems(
|
|
2783
|
+
(prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
|
|
2784
|
+
);
|
|
2785
|
+
} catch (loadError) {
|
|
2786
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
|
|
2787
|
+
setError(message);
|
|
2788
|
+
} finally {
|
|
2789
|
+
setIsLoading(false);
|
|
2790
|
+
setIsFetchingMore(false);
|
|
2791
|
+
}
|
|
2792
|
+
},
|
|
2793
|
+
[statusFilter, createdByFilter, debouncedSearchQuery]
|
|
2794
|
+
);
|
|
2795
|
+
react.useEffect(() => {
|
|
2796
|
+
void loadReturns(0, true);
|
|
2797
|
+
}, [statusFilter, createdByFilter, debouncedSearchQuery, loadReturns]);
|
|
2798
|
+
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
2799
|
+
const availableStatuses = react.useMemo(() => {
|
|
2800
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
2801
|
+
items.forEach((item) => statuses.add(item.status));
|
|
2802
|
+
return Array.from(statuses).sort();
|
|
2803
|
+
}, [items]);
|
|
2804
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
2805
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2806
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2807
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
|
|
2808
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
|
|
2809
|
+
] }),
|
|
2810
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
|
|
2811
|
+
] }),
|
|
2812
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
2813
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2814
|
+
ui.Input,
|
|
2815
|
+
{
|
|
2816
|
+
placeholder: "Search by return ID, order ID, or customer email",
|
|
2817
|
+
value: searchQuery,
|
|
2818
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
2819
|
+
className: "md:max-w-sm"
|
|
2820
|
+
}
|
|
2821
|
+
),
|
|
2822
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
2823
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2824
|
+
"select",
|
|
2825
|
+
{
|
|
2826
|
+
value: createdByFilter,
|
|
2827
|
+
onChange: (event) => setCreatedByFilter(event.target.value),
|
|
2828
|
+
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",
|
|
2829
|
+
children: [
|
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All (Created by)" }),
|
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "customer", children: "Customer" }),
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "admin", children: "Admin" })
|
|
2833
|
+
]
|
|
2834
|
+
}
|
|
2835
|
+
),
|
|
2836
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2837
|
+
"select",
|
|
2838
|
+
{
|
|
2839
|
+
value: statusFilter,
|
|
2840
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
2841
|
+
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",
|
|
2842
|
+
children: [
|
|
2843
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
|
|
2844
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
2845
|
+
]
|
|
2846
|
+
}
|
|
2847
|
+
)
|
|
2848
|
+
] })
|
|
2849
|
+
] }),
|
|
2850
|
+
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
2851
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
2852
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2853
|
+
ui.Button,
|
|
2854
|
+
{
|
|
2855
|
+
variant: "secondary",
|
|
2856
|
+
onClick: () => loadReturns(0, true),
|
|
2857
|
+
children: "Try again"
|
|
2858
|
+
}
|
|
2859
|
+
) })
|
|
2860
|
+
] }) : null,
|
|
2861
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
2862
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
|
|
2863
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
|
|
2864
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
2865
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2866
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
|
|
2867
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
2868
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
|
|
2869
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
2870
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
|
|
2871
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
2872
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
2873
|
+
] }) }),
|
|
2874
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2875
|
+
"tr",
|
|
2876
|
+
{
|
|
2877
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
2878
|
+
onClick: () => navigate(`/returns/${returnOrder.id}`),
|
|
2879
|
+
children: [
|
|
2880
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
|
|
2881
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
|
|
2882
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
|
|
2883
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2884
|
+
ui.Badge,
|
|
2885
|
+
{
|
|
2886
|
+
size: "2xsmall",
|
|
2887
|
+
className: `uppercase ${getStatusBadgeClass$5(returnOrder.status)}`,
|
|
2888
|
+
children: returnOrder.status.replace(/_/g, " ")
|
|
2894
2889
|
}
|
|
2895
2890
|
) }),
|
|
2896
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "
|
|
2897
|
-
|
|
2891
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
2892
|
+
const calc = returnOrder.refund;
|
|
2893
|
+
if (calc?.is_processed && calc.final_refund_amount != null) {
|
|
2894
|
+
return formatRefundCurrency(
|
|
2895
|
+
calc.final_refund_amount,
|
|
2896
|
+
calc.currency_code || returnOrder.currency_code
|
|
2897
|
+
);
|
|
2898
|
+
}
|
|
2899
|
+
if (calc) {
|
|
2900
|
+
return "Pending";
|
|
2901
|
+
}
|
|
2902
|
+
if (returnOrder.refund_amount == null) {
|
|
2903
|
+
return "—";
|
|
2904
|
+
}
|
|
2905
|
+
return formatRefundCurrency(
|
|
2906
|
+
Number(returnOrder.refund_amount),
|
|
2907
|
+
returnOrder.currency_code
|
|
2908
|
+
);
|
|
2909
|
+
})() }),
|
|
2910
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
|
|
2911
|
+
year: "numeric",
|
|
2898
2912
|
month: "short",
|
|
2899
2913
|
day: "numeric",
|
|
2900
2914
|
hour: "numeric",
|
|
2901
2915
|
minute: "2-digit",
|
|
2902
2916
|
hour12: true
|
|
2903
2917
|
}) }),
|
|
2904
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
),
|
|
2917
|
-
r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2918
|
-
ui.Button,
|
|
2919
|
-
{
|
|
2920
|
-
variant: "transparent",
|
|
2921
|
-
size: "small",
|
|
2922
|
-
onClick: (e) => {
|
|
2923
|
-
e.stopPropagation();
|
|
2924
|
-
navigate(`/orders/${r.order_id}`);
|
|
2925
|
-
},
|
|
2926
|
-
children: "Order"
|
|
2927
|
-
}
|
|
2928
|
-
) : null
|
|
2929
|
-
] }) })
|
|
2918
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2919
|
+
ui.Button,
|
|
2920
|
+
{
|
|
2921
|
+
variant: "transparent",
|
|
2922
|
+
size: "small",
|
|
2923
|
+
onClick: (e) => {
|
|
2924
|
+
e.stopPropagation();
|
|
2925
|
+
navigate(`/app/orders/${returnOrder.order_id}`);
|
|
2926
|
+
},
|
|
2927
|
+
children: "Go to order"
|
|
2928
|
+
}
|
|
2929
|
+
) })
|
|
2930
2930
|
]
|
|
2931
2931
|
},
|
|
2932
|
-
|
|
2932
|
+
returnOrder.id
|
|
2933
2933
|
)) })
|
|
2934
2934
|
] }) }),
|
|
2935
2935
|
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2937,15 +2937,15 @@ const RefundsPage = () => {
|
|
|
2937
2937
|
{
|
|
2938
2938
|
variant: "secondary",
|
|
2939
2939
|
isLoading: isFetchingMore,
|
|
2940
|
-
onClick: () =>
|
|
2940
|
+
onClick: () => loadReturns(offset, false),
|
|
2941
2941
|
children: "Load more"
|
|
2942
2942
|
}
|
|
2943
2943
|
) }) : null
|
|
2944
2944
|
] }) });
|
|
2945
2945
|
};
|
|
2946
2946
|
const config$6 = adminSdk.defineRouteConfig({
|
|
2947
|
-
label: "
|
|
2948
|
-
icon: icons.
|
|
2947
|
+
label: "Return Orders",
|
|
2948
|
+
icon: icons.ArrowPath
|
|
2949
2949
|
});
|
|
2950
2950
|
const useDebounce = (value, delay) => {
|
|
2951
2951
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
@@ -4032,11 +4032,202 @@ const PaymentDetailPage = () => {
|
|
|
4032
4032
|
] }) : null
|
|
4033
4033
|
] }) });
|
|
4034
4034
|
};
|
|
4035
|
-
const config$3 = adminSdk.defineRouteConfig({
|
|
4036
|
-
label: "Payment details",
|
|
4037
|
-
icon: icons.CreditCard
|
|
4035
|
+
const config$3 = adminSdk.defineRouteConfig({
|
|
4036
|
+
label: "Payment details",
|
|
4037
|
+
icon: icons.CreditCard
|
|
4038
|
+
});
|
|
4039
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
4040
|
+
const s2 = status.toLowerCase();
|
|
4041
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4042
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4043
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
4044
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4045
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
4046
|
+
};
|
|
4047
|
+
const formatAmount = (value) => {
|
|
4048
|
+
return String(value);
|
|
4049
|
+
};
|
|
4050
|
+
const RefundDetailPage = () => {
|
|
4051
|
+
const navigate = reactRouterDom.useNavigate();
|
|
4052
|
+
const params = reactRouterDom.useParams();
|
|
4053
|
+
const id = params?.id?.trim();
|
|
4054
|
+
const [detail, setDetail] = react.useState(null);
|
|
4055
|
+
const [loading, setLoading] = react.useState(!!id);
|
|
4056
|
+
const [error, setError] = react.useState(null);
|
|
4057
|
+
const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
|
|
4058
|
+
react.useEffect(() => {
|
|
4059
|
+
if (!id) {
|
|
4060
|
+
setLoading(false);
|
|
4061
|
+
return;
|
|
4062
|
+
}
|
|
4063
|
+
let cancelled = false;
|
|
4064
|
+
setLoading(true);
|
|
4065
|
+
setError(null);
|
|
4066
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
4067
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
4068
|
+
return res.json();
|
|
4069
|
+
}).then((data) => {
|
|
4070
|
+
if (!cancelled) setDetail(data);
|
|
4071
|
+
}).catch((e) => {
|
|
4072
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
4073
|
+
}).finally(() => {
|
|
4074
|
+
if (!cancelled) setLoading(false);
|
|
4075
|
+
});
|
|
4076
|
+
return () => {
|
|
4077
|
+
cancelled = true;
|
|
4078
|
+
};
|
|
4079
|
+
}, [id]);
|
|
4080
|
+
const paymentStatus = detail?.payment?.status ?? "—";
|
|
4081
|
+
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
4082
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
4083
|
+
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4084
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
4085
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
|
|
4086
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
4087
|
+
] }) }),
|
|
4088
|
+
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
4089
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
4090
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
4091
|
+
] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
4092
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4093
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
4094
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4095
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4096
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
4097
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
4098
|
+
] }),
|
|
4099
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
4101
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
4102
|
+
] }),
|
|
4103
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4104
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
4105
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
4106
|
+
] }),
|
|
4107
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4108
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
4109
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
4110
|
+
year: "numeric",
|
|
4111
|
+
month: "short",
|
|
4112
|
+
day: "numeric",
|
|
4113
|
+
hour: "numeric",
|
|
4114
|
+
minute: "2-digit",
|
|
4115
|
+
hour12: true
|
|
4116
|
+
}) })
|
|
4117
|
+
] }),
|
|
4118
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4119
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
4120
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
4121
|
+
] }) : null
|
|
4122
|
+
] })
|
|
4123
|
+
] }),
|
|
4124
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4125
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
4126
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4127
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4128
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
4129
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
4130
|
+
] }),
|
|
4131
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4132
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
4133
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
4134
|
+
] }),
|
|
4135
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4136
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
4137
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
4138
|
+
] }),
|
|
4139
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4140
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
4141
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
4142
|
+
] }),
|
|
4143
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4144
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
4145
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4146
|
+
ui.Badge,
|
|
4147
|
+
{
|
|
4148
|
+
size: "2xsmall",
|
|
4149
|
+
className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
|
|
4150
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
4151
|
+
}
|
|
4152
|
+
) })
|
|
4153
|
+
] }),
|
|
4154
|
+
detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4155
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4156
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
4157
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
4158
|
+
] }),
|
|
4159
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4160
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
4161
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
4162
|
+
] }),
|
|
4163
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4164
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
4165
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
|
|
4166
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
4167
|
+
"%"
|
|
4168
|
+
] })
|
|
4169
|
+
] })
|
|
4170
|
+
] }) : null
|
|
4171
|
+
] })
|
|
4172
|
+
] }),
|
|
4173
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4174
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
4175
|
+
detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4176
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4177
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
4178
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4179
|
+
ui.Button,
|
|
4180
|
+
{
|
|
4181
|
+
variant: "transparent",
|
|
4182
|
+
size: "small",
|
|
4183
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
4184
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
4185
|
+
}
|
|
4186
|
+
) })
|
|
4187
|
+
] }),
|
|
4188
|
+
detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4189
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
4190
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
4191
|
+
] }) : null,
|
|
4192
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4193
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
4194
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
4195
|
+
] }) : null,
|
|
4196
|
+
detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4197
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
4198
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
|
|
4199
|
+
] }) : null,
|
|
4200
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4201
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
4202
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
4203
|
+
] }) : null
|
|
4204
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
4205
|
+
] }),
|
|
4206
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4207
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4208
|
+
"button",
|
|
4209
|
+
{
|
|
4210
|
+
type: "button",
|
|
4211
|
+
className: "flex w-full items-center justify-between text-left",
|
|
4212
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
4213
|
+
"aria-expanded": gatewayExpanded,
|
|
4214
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
4215
|
+
children: [
|
|
4216
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
4217
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
4218
|
+
]
|
|
4219
|
+
}
|
|
4220
|
+
),
|
|
4221
|
+
gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
4222
|
+
] })
|
|
4223
|
+
] }) : null
|
|
4224
|
+
] }) });
|
|
4225
|
+
};
|
|
4226
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
4227
|
+
label: "Refund details",
|
|
4228
|
+
icon: icons.Receipt
|
|
4038
4229
|
});
|
|
4039
|
-
const getStatusBadgeClass$
|
|
4230
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
4040
4231
|
const statusLower = status.toLowerCase();
|
|
4041
4232
|
if (statusLower === "requested") {
|
|
4042
4233
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -4169,7 +4360,7 @@ const ReturnDetailPage = () => {
|
|
|
4169
4360
|
ui.Badge,
|
|
4170
4361
|
{
|
|
4171
4362
|
size: "small",
|
|
4172
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4363
|
+
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
4173
4364
|
children: returnOrder.status.replace(/_/g, " ")
|
|
4174
4365
|
}
|
|
4175
4366
|
)
|
|
@@ -4252,7 +4443,7 @@ const ReturnDetailPage = () => {
|
|
|
4252
4443
|
ui.Badge,
|
|
4253
4444
|
{
|
|
4254
4445
|
size: "2xsmall",
|
|
4255
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4446
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
4256
4447
|
children: entry.status.replace(/_/g, " ")
|
|
4257
4448
|
}
|
|
4258
4449
|
) }),
|
|
@@ -4314,201 +4505,10 @@ const ReturnDetailPage = () => {
|
|
|
4314
4505
|
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
|
|
4315
4506
|
] }) });
|
|
4316
4507
|
};
|
|
4317
|
-
const config$
|
|
4508
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
4318
4509
|
label: "Return Order Details",
|
|
4319
4510
|
icon: icons.CheckCircle
|
|
4320
4511
|
});
|
|
4321
|
-
const getStatusBadgeClass$1 = (status) => {
|
|
4322
|
-
const s2 = status.toLowerCase();
|
|
4323
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4324
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4325
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
4326
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4327
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
4328
|
-
};
|
|
4329
|
-
const formatAmount = (value) => {
|
|
4330
|
-
return String(value);
|
|
4331
|
-
};
|
|
4332
|
-
const RefundDetailPage = () => {
|
|
4333
|
-
const navigate = reactRouterDom.useNavigate();
|
|
4334
|
-
const params = reactRouterDom.useParams();
|
|
4335
|
-
const id = params?.id?.trim();
|
|
4336
|
-
const [detail, setDetail] = react.useState(null);
|
|
4337
|
-
const [loading, setLoading] = react.useState(!!id);
|
|
4338
|
-
const [error, setError] = react.useState(null);
|
|
4339
|
-
const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
|
|
4340
|
-
react.useEffect(() => {
|
|
4341
|
-
if (!id) {
|
|
4342
|
-
setLoading(false);
|
|
4343
|
-
return;
|
|
4344
|
-
}
|
|
4345
|
-
let cancelled = false;
|
|
4346
|
-
setLoading(true);
|
|
4347
|
-
setError(null);
|
|
4348
|
-
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
4349
|
-
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
4350
|
-
return res.json();
|
|
4351
|
-
}).then((data) => {
|
|
4352
|
-
if (!cancelled) setDetail(data);
|
|
4353
|
-
}).catch((e) => {
|
|
4354
|
-
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
4355
|
-
}).finally(() => {
|
|
4356
|
-
if (!cancelled) setLoading(false);
|
|
4357
|
-
});
|
|
4358
|
-
return () => {
|
|
4359
|
-
cancelled = true;
|
|
4360
|
-
};
|
|
4361
|
-
}, [id]);
|
|
4362
|
-
const paymentStatus = detail?.payment?.status ?? "—";
|
|
4363
|
-
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
4364
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
4365
|
-
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4366
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
4367
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
|
|
4368
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
4369
|
-
] }) }),
|
|
4370
|
-
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
4371
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
4372
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
4373
|
-
] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
4374
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4375
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
4376
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4377
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4378
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
4379
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
4380
|
-
] }),
|
|
4381
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4382
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
4383
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
4384
|
-
] }),
|
|
4385
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4386
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
4387
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
4388
|
-
] }),
|
|
4389
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4390
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
4391
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
4392
|
-
year: "numeric",
|
|
4393
|
-
month: "short",
|
|
4394
|
-
day: "numeric",
|
|
4395
|
-
hour: "numeric",
|
|
4396
|
-
minute: "2-digit",
|
|
4397
|
-
hour12: true
|
|
4398
|
-
}) })
|
|
4399
|
-
] }),
|
|
4400
|
-
detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4401
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
4402
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
4403
|
-
] }) : null
|
|
4404
|
-
] })
|
|
4405
|
-
] }),
|
|
4406
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4407
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
4408
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4409
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4410
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
4411
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
4412
|
-
] }),
|
|
4413
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4414
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
4415
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
4416
|
-
] }),
|
|
4417
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4418
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
4419
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
4420
|
-
] }),
|
|
4421
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4422
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
4423
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
4424
|
-
] }),
|
|
4425
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4426
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
4427
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4428
|
-
ui.Badge,
|
|
4429
|
-
{
|
|
4430
|
-
size: "2xsmall",
|
|
4431
|
-
className: `uppercase ${getStatusBadgeClass$1(paymentStatus)}`,
|
|
4432
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
4433
|
-
}
|
|
4434
|
-
) })
|
|
4435
|
-
] }),
|
|
4436
|
-
detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4437
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4438
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
4439
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
4440
|
-
] }),
|
|
4441
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4442
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
4443
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
4444
|
-
] }),
|
|
4445
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4446
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
4447
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
|
|
4448
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
4449
|
-
"%"
|
|
4450
|
-
] })
|
|
4451
|
-
] })
|
|
4452
|
-
] }) : null
|
|
4453
|
-
] })
|
|
4454
|
-
] }),
|
|
4455
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4456
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
4457
|
-
detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4458
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4459
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
4460
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4461
|
-
ui.Button,
|
|
4462
|
-
{
|
|
4463
|
-
variant: "transparent",
|
|
4464
|
-
size: "small",
|
|
4465
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
4466
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
4467
|
-
}
|
|
4468
|
-
) })
|
|
4469
|
-
] }),
|
|
4470
|
-
detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4471
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
4472
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
4473
|
-
] }) : null,
|
|
4474
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4475
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
4476
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
4477
|
-
] }) : null,
|
|
4478
|
-
detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4479
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
4480
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
|
|
4481
|
-
] }) : null,
|
|
4482
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4483
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
4484
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
4485
|
-
] }) : null
|
|
4486
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
4487
|
-
] }),
|
|
4488
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4489
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4490
|
-
"button",
|
|
4491
|
-
{
|
|
4492
|
-
type: "button",
|
|
4493
|
-
className: "flex w-full items-center justify-between text-left",
|
|
4494
|
-
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
4495
|
-
"aria-expanded": gatewayExpanded,
|
|
4496
|
-
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
4497
|
-
children: [
|
|
4498
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
4499
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
4500
|
-
]
|
|
4501
|
-
}
|
|
4502
|
-
),
|
|
4503
|
-
gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
4504
|
-
] })
|
|
4505
|
-
] }) : null
|
|
4506
|
-
] }) });
|
|
4507
|
-
};
|
|
4508
|
-
const config$1 = adminSdk.defineRouteConfig({
|
|
4509
|
-
label: "Refund details",
|
|
4510
|
-
icon: icons.Receipt
|
|
4511
|
-
});
|
|
4512
4512
|
const getStatusBadgeClass = (status) => {
|
|
4513
4513
|
const statusLower = status.toLowerCase();
|
|
4514
4514
|
if (statusLower === "requested") {
|
|
@@ -4813,13 +4813,13 @@ const routeModule = {
|
|
|
4813
4813
|
handle: { label: config$8.label, translationNs: config$8.translationNs }
|
|
4814
4814
|
},
|
|
4815
4815
|
{
|
|
4816
|
-
Component:
|
|
4817
|
-
path: "/
|
|
4816
|
+
Component: RefundsPage,
|
|
4817
|
+
path: "/refunds",
|
|
4818
4818
|
handle: { label: config$7.label, translationNs: config$7.translationNs }
|
|
4819
4819
|
},
|
|
4820
4820
|
{
|
|
4821
|
-
Component:
|
|
4822
|
-
path: "/
|
|
4821
|
+
Component: ReturnsPage,
|
|
4822
|
+
path: "/returns",
|
|
4823
4823
|
handle: { label: config$6.label, translationNs: config$6.translationNs }
|
|
4824
4824
|
},
|
|
4825
4825
|
{
|
|
@@ -4838,13 +4838,13 @@ const routeModule = {
|
|
|
4838
4838
|
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
4839
4839
|
},
|
|
4840
4840
|
{
|
|
4841
|
-
Component:
|
|
4842
|
-
path: "/
|
|
4841
|
+
Component: RefundDetailPage,
|
|
4842
|
+
path: "/refunds/:id",
|
|
4843
4843
|
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
4844
4844
|
},
|
|
4845
4845
|
{
|
|
4846
|
-
Component:
|
|
4847
|
-
path: "/
|
|
4846
|
+
Component: ReturnDetailPage,
|
|
4847
|
+
path: "/returns/:id",
|
|
4848
4848
|
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
4849
4849
|
},
|
|
4850
4850
|
{
|
|
@@ -4864,14 +4864,6 @@ const menuItemModule = {
|
|
|
4864
4864
|
rank: void 0,
|
|
4865
4865
|
translationNs: void 0
|
|
4866
4866
|
},
|
|
4867
|
-
{
|
|
4868
|
-
label: config$6.label,
|
|
4869
|
-
icon: config$6.icon,
|
|
4870
|
-
path: "/refunds",
|
|
4871
|
-
nested: void 0,
|
|
4872
|
-
rank: void 0,
|
|
4873
|
-
translationNs: void 0
|
|
4874
|
-
},
|
|
4875
4867
|
{
|
|
4876
4868
|
label: config$8.label,
|
|
4877
4869
|
icon: config$8.icon,
|
|
@@ -4883,23 +4875,23 @@ const menuItemModule = {
|
|
|
4883
4875
|
{
|
|
4884
4876
|
label: config$7.label,
|
|
4885
4877
|
icon: config$7.icon,
|
|
4886
|
-
path: "/
|
|
4878
|
+
path: "/refunds",
|
|
4887
4879
|
nested: void 0,
|
|
4888
4880
|
rank: void 0,
|
|
4889
4881
|
translationNs: void 0
|
|
4890
4882
|
},
|
|
4891
4883
|
{
|
|
4892
|
-
label: config$
|
|
4893
|
-
icon: config$
|
|
4894
|
-
path: "/
|
|
4884
|
+
label: config$6.label,
|
|
4885
|
+
icon: config$6.icon,
|
|
4886
|
+
path: "/returns",
|
|
4895
4887
|
nested: void 0,
|
|
4896
4888
|
rank: void 0,
|
|
4897
4889
|
translationNs: void 0
|
|
4898
4890
|
},
|
|
4899
4891
|
{
|
|
4900
|
-
label: config$
|
|
4901
|
-
icon: config$
|
|
4902
|
-
path: "/
|
|
4892
|
+
label: config$5.label,
|
|
4893
|
+
icon: config$5.icon,
|
|
4894
|
+
path: "/swaps",
|
|
4903
4895
|
nested: void 0,
|
|
4904
4896
|
rank: void 0,
|
|
4905
4897
|
translationNs: void 0
|
|
@@ -4915,6 +4907,14 @@ const menuItemModule = {
|
|
|
4915
4907
|
{
|
|
4916
4908
|
label: config$2.label,
|
|
4917
4909
|
icon: config$2.icon,
|
|
4910
|
+
path: "/refunds/:id",
|
|
4911
|
+
nested: void 0,
|
|
4912
|
+
rank: void 0,
|
|
4913
|
+
translationNs: void 0
|
|
4914
|
+
},
|
|
4915
|
+
{
|
|
4916
|
+
label: config$1.label,
|
|
4917
|
+
icon: config$1.icon,
|
|
4918
4918
|
path: "/returns/:id",
|
|
4919
4919
|
nested: void 0,
|
|
4920
4920
|
rank: void 0,
|