order-management 0.0.98 → 0.0.99

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.
@@ -5,7 +5,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
5
5
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
6
6
  import { useState, useEffect, useRef, useMemo, useCallback } from "react";
7
7
  import { Text, Container, Heading, Badge, Button, Label, Select, Textarea, Popover, clx, Input, Copy, Skeleton, Tooltip, toast } from "@medusajs/ui";
8
- import { CashSolid, PencilSquareSolid, Trash, ChevronDownMini, Check, ArrowPath, InformationCircle, ChevronRightMini, MagnifierAlert, ExclamationCircle, Receipt, CreditCard, ArrowLeft, ClockSolid, SquareTwoStack, ShieldCheck, CheckCircle } from "@medusajs/icons";
8
+ import { CashSolid, PencilSquareSolid, Trash, ChevronDownMini, Check, ArrowPath, InformationCircle, ChevronRightMini, MagnifierAlert, ExclamationCircle, CreditCard, Receipt, ArrowLeft, ClockSolid, SquareTwoStack, ShieldCheck, CheckCircle } from "@medusajs/icons";
9
9
  import { useNavigate, useLocation, useSearchParams, useParams } from "react-router-dom";
10
10
  function roundRectPath(ctx, x, y, w, h, r) {
11
11
  ctx.beginPath();
@@ -2246,16 +2246,216 @@ const getStatusBadgeClass$7 = (status) => {
2246
2246
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2247
2247
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2248
2248
  };
2249
- const RefundsPage = () => {
2249
+ const PaymentsPage = () => {
2250
2250
  const navigate = useNavigate();
2251
2251
  const [items, setItems] = useState([]);
2252
+ const [statusFilter, setStatusFilter] = useState("all");
2252
2253
  const [orderIdSearch, setOrderIdSearch] = useState("");
2253
2254
  const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
2255
+ const [isLoading, setIsLoading] = useState(true);
2256
+ const [isFetchingMore, setIsFetchingMore] = useState(false);
2257
+ const [error, setError] = useState(null);
2258
+ const [offset, setOffset] = useState(0);
2259
+ const [count, setCount] = useState(0);
2260
+ const limit = 50;
2261
+ const loadTransactions = useCallback(
2262
+ async (nextOffset, replace) => {
2263
+ try {
2264
+ if (replace) setIsLoading(true);
2265
+ else setIsFetchingMore(true);
2266
+ setError(null);
2267
+ const params = new URLSearchParams();
2268
+ params.set("limit", String(limit));
2269
+ params.set("offset", String(nextOffset));
2270
+ if (statusFilter !== "all") params.set("status", statusFilter);
2271
+ if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2272
+ const response = await fetch(
2273
+ `/admin/payment-transactions?${params.toString()}`,
2274
+ { credentials: "include" }
2275
+ );
2276
+ if (!response.ok) {
2277
+ const text = await response.text();
2278
+ throw new Error(text || "Failed to load payment transactions");
2279
+ }
2280
+ const payload = await response.json();
2281
+ const list = payload.transactions ?? [];
2282
+ setCount(payload.count ?? 0);
2283
+ setOffset(nextOffset + list.length);
2284
+ setItems((prev) => replace ? list : [...prev, ...list]);
2285
+ } catch (e) {
2286
+ setError(e instanceof Error ? e.message : "Failed to load");
2287
+ } finally {
2288
+ setIsLoading(false);
2289
+ setIsFetchingMore(false);
2290
+ }
2291
+ },
2292
+ [statusFilter, debouncedOrderId]
2293
+ );
2294
+ useEffect(() => {
2295
+ void loadTransactions(0, true);
2296
+ }, [loadTransactions]);
2297
+ const hasMore = useMemo(() => offset < count, [offset, count]);
2298
+ const displayStatus = (t) => {
2299
+ const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2300
+ return s2 !== "" ? s2 : "—";
2301
+ };
2302
+ const displayAmount = (t) => {
2303
+ const code = (t.currency_code ?? "USD").toUpperCase();
2304
+ return `${code} ${Number(t.amount)}`;
2305
+ };
2306
+ 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: [
2307
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2308
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
2309
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
2310
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2311
+ ] }),
2312
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2313
+ ] }),
2314
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2315
+ /* @__PURE__ */ jsx(
2316
+ Input,
2317
+ {
2318
+ placeholder: "Search by Order ID",
2319
+ value: orderIdSearch,
2320
+ onChange: (e) => setOrderIdSearch(e.target.value),
2321
+ className: "md:max-w-sm",
2322
+ "aria-label": "Search by order ID"
2323
+ }
2324
+ ),
2325
+ /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
2326
+ "select",
2327
+ {
2328
+ value: statusFilter,
2329
+ onChange: (e) => setStatusFilter(e.target.value),
2330
+ 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",
2331
+ "aria-label": "Filter by status",
2332
+ children: [
2333
+ /* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
2334
+ /* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
2335
+ /* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
2336
+ /* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
2337
+ /* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
2338
+ /* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
2339
+ /* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
2340
+ ]
2341
+ }
2342
+ ) })
2343
+ ] }),
2344
+ error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2345
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2346
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2347
+ ] }) : null,
2348
+ 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: [
2349
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2350
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2351
+ ] }) : /* @__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: [
2352
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
2353
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2354
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2355
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2356
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2357
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2358
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2359
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2360
+ ] }) }),
2361
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
2362
+ "tr",
2363
+ {
2364
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2365
+ onClick: () => navigate(`/payments/${t.payment_session_id}`),
2366
+ children: [
2367
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2368
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2369
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2370
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
2371
+ Badge,
2372
+ {
2373
+ size: "2xsmall",
2374
+ className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
2375
+ children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2376
+ }
2377
+ ) }),
2378
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2379
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2380
+ year: "numeric",
2381
+ month: "short",
2382
+ day: "numeric",
2383
+ hour: "numeric",
2384
+ minute: "2-digit",
2385
+ hour12: true
2386
+ }) }),
2387
+ /* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
2388
+ /* @__PURE__ */ jsx(
2389
+ Button,
2390
+ {
2391
+ variant: "transparent",
2392
+ size: "small",
2393
+ onClick: (e) => {
2394
+ e.stopPropagation();
2395
+ navigate(`/payments/${t.payment_session_id}`);
2396
+ },
2397
+ children: "View details"
2398
+ }
2399
+ ),
2400
+ t.order_id ? /* @__PURE__ */ jsx(
2401
+ Button,
2402
+ {
2403
+ variant: "transparent",
2404
+ size: "small",
2405
+ onClick: (e) => {
2406
+ e.stopPropagation();
2407
+ navigate(`/orders/${t.order_id}`);
2408
+ },
2409
+ children: "Order"
2410
+ }
2411
+ ) : null
2412
+ ] })
2413
+ ]
2414
+ },
2415
+ t.payment_session_id
2416
+ )) })
2417
+ ] }) }),
2418
+ hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
2419
+ Button,
2420
+ {
2421
+ variant: "secondary",
2422
+ isLoading: isFetchingMore,
2423
+ onClick: () => loadTransactions(offset, false),
2424
+ children: "Load more"
2425
+ }
2426
+ ) }) : null
2427
+ ] }) });
2428
+ };
2429
+ const config$7 = defineRouteConfig({
2430
+ label: "Payments",
2431
+ icon: CreditCard
2432
+ });
2433
+ const useDebounce$2 = (value, delay) => {
2434
+ const [debouncedValue, setDebouncedValue] = useState(value);
2435
+ useEffect(() => {
2436
+ const handler = setTimeout(() => setDebouncedValue(value), delay);
2437
+ return () => clearTimeout(handler);
2438
+ }, [value, delay]);
2439
+ return debouncedValue;
2440
+ };
2441
+ const getStatusBadgeClass$6 = (status) => {
2442
+ const s2 = status.toLowerCase();
2443
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2444
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2445
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2446
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2447
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2448
+ };
2449
+ const RefundsPage = () => {
2450
+ const navigate = useNavigate();
2451
+ const [items, setItems] = useState([]);
2452
+ const [orderIdSearch, setOrderIdSearch] = useState("");
2453
+ const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
2254
2454
  const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
2255
2455
  const [providerSearch, setProviderSearch] = useState("");
2256
- const debouncedProvider = useDebounce$3(providerSearch, 300);
2456
+ const debouncedProvider = useDebounce$2(providerSearch, 300);
2257
2457
  const [currencySearch, setCurrencySearch] = useState("");
2258
- const debouncedCurrency = useDebounce$3(currencySearch, 300);
2458
+ const debouncedCurrency = useDebounce$2(currencySearch, 300);
2259
2459
  const [dateFrom, setDateFrom] = useState("");
2260
2460
  const [dateTo, setDateTo] = useState("");
2261
2461
  const [amountMin, setAmountMin] = useState("");
@@ -2467,7 +2667,7 @@ const RefundsPage = () => {
2467
2667
  Badge,
2468
2668
  {
2469
2669
  size: "2xsmall",
2470
- className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
2670
+ className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
2471
2671
  children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
2472
2672
  }
2473
2673
  ) }),
@@ -2521,11 +2721,11 @@ const RefundsPage = () => {
2521
2721
  ) }) : null
2522
2722
  ] }) });
2523
2723
  };
2524
- const config$7 = defineRouteConfig({
2724
+ const config$6 = defineRouteConfig({
2525
2725
  label: "Refunds",
2526
2726
  icon: Receipt
2527
2727
  });
2528
- const useDebounce$2 = (value, delay) => {
2728
+ const useDebounce$1 = (value, delay) => {
2529
2729
  const [debouncedValue, setDebouncedValue] = useState(value);
2530
2730
  useEffect(() => {
2531
2731
  const handler = setTimeout(() => setDebouncedValue(value), delay);
@@ -2533,247 +2733,47 @@ const useDebounce$2 = (value, delay) => {
2533
2733
  }, [value, delay]);
2534
2734
  return debouncedValue;
2535
2735
  };
2536
- const getStatusBadgeClass$6 = (status) => {
2537
- const s2 = status.toLowerCase();
2538
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
2539
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2540
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
2541
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2736
+ const getStatusBadgeClass$5 = (status) => {
2737
+ const statusLower = status.toLowerCase();
2738
+ if (statusLower === "requested") {
2739
+ return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2740
+ }
2741
+ if (statusLower === "received") {
2742
+ return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2743
+ }
2744
+ if (statusLower === "requires_action") {
2745
+ return "bg-ui-tag-red-bg text-ui-tag-red-text";
2746
+ }
2747
+ if (statusLower === "completed") {
2748
+ return "bg-ui-tag-green-bg text-ui-tag-green-text";
2749
+ }
2750
+ if (statusLower === "canceled") {
2751
+ return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
2752
+ }
2542
2753
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2543
2754
  };
2544
- const PaymentsPage = () => {
2755
+ const ReturnsPage = () => {
2545
2756
  const navigate = useNavigate();
2546
2757
  const [items, setItems] = useState([]);
2547
2758
  const [statusFilter, setStatusFilter] = useState("all");
2548
- const [orderIdSearch, setOrderIdSearch] = useState("");
2549
- const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
2759
+ const [createdByFilter, setCreatedByFilter] = useState("all");
2760
+ const [searchQuery, setSearchQuery] = useState("");
2761
+ const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
2550
2762
  const [isLoading, setIsLoading] = useState(true);
2551
2763
  const [isFetchingMore, setIsFetchingMore] = useState(false);
2552
2764
  const [error, setError] = useState(null);
2553
2765
  const [offset, setOffset] = useState(0);
2554
2766
  const [count, setCount] = useState(0);
2555
2767
  const limit = 50;
2556
- const loadTransactions = useCallback(
2557
- async (nextOffset, replace) => {
2768
+ const loadReturns = useCallback(
2769
+ async (nextOffset, replace = false) => {
2770
+ var _a;
2558
2771
  try {
2559
- if (replace) setIsLoading(true);
2560
- else setIsFetchingMore(true);
2561
- setError(null);
2562
- const params = new URLSearchParams();
2563
- params.set("limit", String(limit));
2564
- params.set("offset", String(nextOffset));
2565
- if (statusFilter !== "all") params.set("status", statusFilter);
2566
- if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2567
- const response = await fetch(
2568
- `/admin/payment-transactions?${params.toString()}`,
2569
- { credentials: "include" }
2570
- );
2571
- if (!response.ok) {
2572
- const text = await response.text();
2573
- throw new Error(text || "Failed to load payment transactions");
2574
- }
2575
- const payload = await response.json();
2576
- const list = payload.transactions ?? [];
2577
- setCount(payload.count ?? 0);
2578
- setOffset(nextOffset + list.length);
2579
- setItems((prev) => replace ? list : [...prev, ...list]);
2580
- } catch (e) {
2581
- setError(e instanceof Error ? e.message : "Failed to load");
2582
- } finally {
2583
- setIsLoading(false);
2584
- setIsFetchingMore(false);
2585
- }
2586
- },
2587
- [statusFilter, debouncedOrderId]
2588
- );
2589
- useEffect(() => {
2590
- void loadTransactions(0, true);
2591
- }, [loadTransactions]);
2592
- const hasMore = useMemo(() => offset < count, [offset, count]);
2593
- const displayStatus = (t) => {
2594
- const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2595
- return s2 !== "" ? s2 : "—";
2596
- };
2597
- const displayAmount = (t) => {
2598
- const code = (t.currency_code ?? "USD").toUpperCase();
2599
- return `${code} ${Number(t.amount)}`;
2600
- };
2601
- 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: [
2602
- /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2603
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
2604
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
2605
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2606
- ] }),
2607
- /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2608
- ] }),
2609
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2610
- /* @__PURE__ */ jsx(
2611
- Input,
2612
- {
2613
- placeholder: "Search by Order ID",
2614
- value: orderIdSearch,
2615
- onChange: (e) => setOrderIdSearch(e.target.value),
2616
- className: "md:max-w-sm",
2617
- "aria-label": "Search by order ID"
2618
- }
2619
- ),
2620
- /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
2621
- "select",
2622
- {
2623
- value: statusFilter,
2624
- onChange: (e) => setStatusFilter(e.target.value),
2625
- 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",
2626
- "aria-label": "Filter by status",
2627
- children: [
2628
- /* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
2629
- /* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
2630
- /* @__PURE__ */ jsx("option", { value: "requires_more", children: "Requires more" }),
2631
- /* @__PURE__ */ jsx("option", { value: "error", children: "Error" }),
2632
- /* @__PURE__ */ jsx("option", { value: "canceled", children: "Canceled" }),
2633
- /* @__PURE__ */ jsx("option", { value: "authorized", children: "Authorized" }),
2634
- /* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
2635
- ]
2636
- }
2637
- ) })
2638
- ] }),
2639
- error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2640
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2641
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2642
- ] }) : null,
2643
- 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: [
2644
- /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2645
- /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2646
- ] }) : /* @__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: [
2647
- /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
2648
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2649
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2650
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2651
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2652
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2653
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2654
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2655
- ] }) }),
2656
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
2657
- "tr",
2658
- {
2659
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2660
- onClick: () => navigate(`/payments/${t.payment_session_id}`),
2661
- children: [
2662
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2663
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2664
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2665
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
2666
- Badge,
2667
- {
2668
- size: "2xsmall",
2669
- className: `uppercase ${getStatusBadgeClass$6(displayStatus(t))}`,
2670
- children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2671
- }
2672
- ) }),
2673
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2674
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2675
- year: "numeric",
2676
- month: "short",
2677
- day: "numeric",
2678
- hour: "numeric",
2679
- minute: "2-digit",
2680
- hour12: true
2681
- }) }),
2682
- /* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
2683
- /* @__PURE__ */ jsx(
2684
- Button,
2685
- {
2686
- variant: "transparent",
2687
- size: "small",
2688
- onClick: (e) => {
2689
- e.stopPropagation();
2690
- navigate(`/payments/${t.payment_session_id}`);
2691
- },
2692
- children: "View details"
2693
- }
2694
- ),
2695
- t.order_id ? /* @__PURE__ */ jsx(
2696
- Button,
2697
- {
2698
- variant: "transparent",
2699
- size: "small",
2700
- onClick: (e) => {
2701
- e.stopPropagation();
2702
- navigate(`/orders/${t.order_id}`);
2703
- },
2704
- children: "Order"
2705
- }
2706
- ) : null
2707
- ] })
2708
- ]
2709
- },
2710
- t.payment_session_id
2711
- )) })
2712
- ] }) }),
2713
- hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
2714
- Button,
2715
- {
2716
- variant: "secondary",
2717
- isLoading: isFetchingMore,
2718
- onClick: () => loadTransactions(offset, false),
2719
- children: "Load more"
2720
- }
2721
- ) }) : null
2722
- ] }) });
2723
- };
2724
- const config$6 = defineRouteConfig({
2725
- label: "Payments",
2726
- icon: CreditCard
2727
- });
2728
- const useDebounce$1 = (value, delay) => {
2729
- const [debouncedValue, setDebouncedValue] = useState(value);
2730
- useEffect(() => {
2731
- const handler = setTimeout(() => setDebouncedValue(value), delay);
2732
- return () => clearTimeout(handler);
2733
- }, [value, delay]);
2734
- return debouncedValue;
2735
- };
2736
- const getStatusBadgeClass$5 = (status) => {
2737
- const statusLower = status.toLowerCase();
2738
- if (statusLower === "requested") {
2739
- return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2740
- }
2741
- if (statusLower === "received") {
2742
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
2743
- }
2744
- if (statusLower === "requires_action") {
2745
- return "bg-ui-tag-red-bg text-ui-tag-red-text";
2746
- }
2747
- if (statusLower === "completed") {
2748
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
2749
- }
2750
- if (statusLower === "canceled") {
2751
- return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
2752
- }
2753
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2754
- };
2755
- const ReturnsPage = () => {
2756
- const navigate = useNavigate();
2757
- const [items, setItems] = useState([]);
2758
- const [statusFilter, setStatusFilter] = useState("all");
2759
- const [createdByFilter, setCreatedByFilter] = useState("all");
2760
- const [searchQuery, setSearchQuery] = useState("");
2761
- const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
2762
- const [isLoading, setIsLoading] = useState(true);
2763
- const [isFetchingMore, setIsFetchingMore] = useState(false);
2764
- const [error, setError] = useState(null);
2765
- const [offset, setOffset] = useState(0);
2766
- const [count, setCount] = useState(0);
2767
- const limit = 50;
2768
- const loadReturns = useCallback(
2769
- async (nextOffset, replace = false) => {
2770
- var _a;
2771
- try {
2772
- if (replace) {
2773
- setIsLoading(true);
2774
- } else {
2775
- setIsFetchingMore(true);
2776
- }
2772
+ if (replace) {
2773
+ setIsLoading(true);
2774
+ } else {
2775
+ setIsFetchingMore(true);
2776
+ }
2777
2777
  setError(null);
2778
2778
  const params = new URLSearchParams();
2779
2779
  params.set("limit", String(limit));
@@ -3949,18 +3949,14 @@ const getStatusBadgeClass$3 = (status) => {
3949
3949
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
3950
3950
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
3951
3951
  };
3952
- const formatAmount = (value) => {
3953
- return String(value);
3954
- };
3955
- const RefundDetailPage = () => {
3956
- var _a, _b, _c;
3952
+ const PaymentDetailPage = () => {
3953
+ var _a;
3957
3954
  const navigate = useNavigate();
3958
3955
  const params = useParams();
3959
3956
  const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
3960
3957
  const [detail, setDetail] = useState(null);
3961
3958
  const [loading, setLoading] = useState(!!id);
3962
3959
  const [error, setError] = useState(null);
3963
- const [gatewayExpanded, setGatewayExpanded] = useState(false);
3964
3960
  useEffect(() => {
3965
3961
  if (!id) {
3966
3962
  setLoading(false);
@@ -3969,7 +3965,7 @@ const RefundDetailPage = () => {
3969
3965
  let cancelled = false;
3970
3966
  setLoading(true);
3971
3967
  setError(null);
3972
- fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
3968
+ fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
3973
3969
  if (!res.ok) throw new Error(res.statusText || "Failed to load");
3974
3970
  return res.json();
3975
3971
  }).then((data) => {
@@ -3983,207 +3979,19 @@ const RefundDetailPage = () => {
3983
3979
  cancelled = true;
3984
3980
  };
3985
3981
  }, [id]);
3986
- const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
3987
- const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
3982
+ const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
3983
+ const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
3984
+ const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
3985
+ const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
3988
3986
  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: [
3989
3987
  /* @__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: [
3990
- /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
3991
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
3992
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
3988
+ /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
3989
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
3990
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
3993
3991
  ] }) }),
3994
3992
  error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
3995
3993
  /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
3996
- /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
3997
- ] }) : 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: [
3998
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
3999
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
4000
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4001
- /* @__PURE__ */ jsxs("div", { children: [
4002
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
4003
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
4004
- ] }),
4005
- /* @__PURE__ */ jsxs("div", { children: [
4006
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
4007
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
4008
- ] }),
4009
- /* @__PURE__ */ jsxs("div", { children: [
4010
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
4011
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
4012
- ] }),
4013
- /* @__PURE__ */ jsxs("div", { children: [
4014
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
4015
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
4016
- year: "numeric",
4017
- month: "short",
4018
- day: "numeric",
4019
- hour: "numeric",
4020
- minute: "2-digit",
4021
- hour12: true
4022
- }) })
4023
- ] }),
4024
- detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
4025
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
4026
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
4027
- ] }) : null
4028
- ] })
4029
- ] }),
4030
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4031
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
4032
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4033
- /* @__PURE__ */ jsxs("div", { children: [
4034
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
4035
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
4036
- ] }),
4037
- /* @__PURE__ */ jsxs("div", { children: [
4038
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
4039
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
4040
- ] }),
4041
- /* @__PURE__ */ jsxs("div", { children: [
4042
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
4043
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
4044
- ] }),
4045
- /* @__PURE__ */ jsxs("div", { children: [
4046
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
4047
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
4048
- ] }),
4049
- /* @__PURE__ */ jsxs("div", { children: [
4050
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
4051
- /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4052
- Badge,
4053
- {
4054
- size: "2xsmall",
4055
- className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
4056
- children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
4057
- }
4058
- ) })
4059
- ] }),
4060
- detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
4061
- /* @__PURE__ */ jsxs("div", { children: [
4062
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
4063
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
4064
- ] }),
4065
- /* @__PURE__ */ jsxs("div", { children: [
4066
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
4067
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
4068
- ] }),
4069
- /* @__PURE__ */ jsxs("div", { children: [
4070
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
4071
- /* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
4072
- detail.computed.refund_percentage.toFixed(1),
4073
- "%"
4074
- ] })
4075
- ] })
4076
- ] }) : null
4077
- ] })
4078
- ] }),
4079
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4080
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
4081
- detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4082
- /* @__PURE__ */ jsxs("div", { children: [
4083
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
4084
- /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4085
- Button,
4086
- {
4087
- variant: "transparent",
4088
- size: "small",
4089
- onClick: () => navigate(`/orders/${detail.order.order_id}`),
4090
- children: detail.order.order_number ?? detail.order.order_id
4091
- }
4092
- ) })
4093
- ] }),
4094
- detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
4095
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
4096
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
4097
- ] }) : null,
4098
- detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
4099
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
4100
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
4101
- ] }) : null,
4102
- detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
4103
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
4104
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
4105
- ] }) : null,
4106
- detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
4107
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
4108
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
4109
- ] }) : null
4110
- ] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
4111
- ] }),
4112
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4113
- /* @__PURE__ */ jsxs(
4114
- "button",
4115
- {
4116
- type: "button",
4117
- className: "flex w-full items-center justify-between text-left",
4118
- onClick: () => setGatewayExpanded((prev) => !prev),
4119
- "aria-expanded": gatewayExpanded,
4120
- "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
4121
- children: [
4122
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
4123
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
4124
- ]
4125
- }
4126
- ),
4127
- gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
4128
- ] })
4129
- ] }) : null
4130
- ] }) });
4131
- };
4132
- const config$3 = defineRouteConfig({
4133
- label: "Refund details",
4134
- icon: Receipt
4135
- });
4136
- const getStatusBadgeClass$2 = (status) => {
4137
- const s2 = status.toLowerCase();
4138
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4139
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4140
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
4141
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4142
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4143
- };
4144
- const PaymentDetailPage = () => {
4145
- var _a;
4146
- const navigate = useNavigate();
4147
- const params = useParams();
4148
- const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
4149
- const [detail, setDetail] = useState(null);
4150
- const [loading, setLoading] = useState(!!id);
4151
- const [error, setError] = useState(null);
4152
- useEffect(() => {
4153
- if (!id) {
4154
- setLoading(false);
4155
- return;
4156
- }
4157
- let cancelled = false;
4158
- setLoading(true);
4159
- setError(null);
4160
- fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
4161
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
4162
- return res.json();
4163
- }).then((data) => {
4164
- if (!cancelled) setDetail(data);
4165
- }).catch((e) => {
4166
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
4167
- }).finally(() => {
4168
- if (!cancelled) setLoading(false);
4169
- });
4170
- return () => {
4171
- cancelled = true;
4172
- };
4173
- }, [id]);
4174
- const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
4175
- const sessionStatusRaw = (detail == null ? void 0 : detail.session_status) ?? "—";
4176
- const paymentStatusRaw = (detail == null ? void 0 : detail.payment_id) != null ? (detail == null ? void 0 : detail.payment_status) ?? "—" : "—";
4177
- const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
4178
- 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: [
4179
- /* @__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: [
4180
- /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
4181
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payment session" }),
4182
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
4183
- ] }) }),
4184
- error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
4185
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
4186
- /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
3994
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
4187
3995
  ] }) : 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: [
4188
3996
  /* @__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: [
4189
3997
  /* @__PURE__ */ jsxs("div", { children: [
@@ -4212,7 +4020,7 @@ const PaymentDetailPage = () => {
4212
4020
  Badge,
4213
4021
  {
4214
4022
  size: "2xsmall",
4215
- className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
4023
+ className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
4216
4024
  children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
4217
4025
  }
4218
4026
  ) })
@@ -4248,11 +4056,11 @@ const PaymentDetailPage = () => {
4248
4056
  ] }) : null
4249
4057
  ] }) });
4250
4058
  };
4251
- const config$2 = defineRouteConfig({
4059
+ const config$3 = defineRouteConfig({
4252
4060
  label: "Payment details",
4253
4061
  icon: CreditCard
4254
4062
  });
4255
- const getStatusBadgeClass$1 = (status) => {
4063
+ const getStatusBadgeClass$2 = (status) => {
4256
4064
  const statusLower = status.toLowerCase();
4257
4065
  if (statusLower === "requested") {
4258
4066
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -4263,109 +4071,105 @@ const getStatusBadgeClass$1 = (status) => {
4263
4071
  if (statusLower === "rejected") {
4264
4072
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
4265
4073
  }
4074
+ if (statusLower === "received") {
4075
+ return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4076
+ }
4077
+ if (statusLower === "refunded") {
4078
+ return "bg-ui-tag-green-bg text-ui-tag-green-text";
4079
+ }
4266
4080
  if (statusLower === "completed") {
4267
4081
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
4268
4082
  }
4269
- if (statusLower === "cancelled" || statusLower === "canceled") {
4083
+ if (statusLower === "cancelled") {
4270
4084
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
4271
4085
  }
4272
- if (statusLower === "pending") {
4273
- return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4274
- }
4275
4086
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4276
4087
  };
4277
- const SwapDetailPage = () => {
4088
+ const ReturnDetailPage = () => {
4278
4089
  var _a, _b, _c;
4279
4090
  const navigate = useNavigate();
4280
4091
  const { id } = useParams();
4281
- const [swap, setSwap] = useState(null);
4282
- const [order, setOrder] = useState(null);
4092
+ const [returnOrder, setReturnOrder] = useState(null);
4283
4093
  const [isLoading, setIsLoading] = useState(true);
4284
- useState(false);
4285
- const [isCancelling, setIsCancelling] = useState(false);
4094
+ const [isRejecting, setIsRejecting] = useState(false);
4286
4095
  const [error, setError] = useState(null);
4287
4096
  const [updateError, setUpdateError] = useState(null);
4288
4097
  const [updateSuccess, setUpdateSuccess] = useState(false);
4289
4098
  useEffect(() => {
4290
4099
  if (!id) {
4291
- navigate("/swaps");
4100
+ navigate("/returns");
4292
4101
  return;
4293
4102
  }
4294
- const loadSwap = async () => {
4103
+ const loadReturn = async () => {
4295
4104
  try {
4296
4105
  setIsLoading(true);
4297
4106
  setError(null);
4298
- const response = await fetch(`/admin/swaps/${id}`, {
4107
+ const response = await fetch(`/admin/return/${id}`, {
4299
4108
  credentials: "include"
4300
4109
  });
4301
4110
  if (!response.ok) {
4302
4111
  const message = await response.text();
4303
- throw new Error(message || "Unable to load swap");
4112
+ throw new Error(message || "Unable to load return order");
4304
4113
  }
4305
4114
  const payload = await response.json();
4306
- setSwap(payload.swap);
4307
- setOrder(payload.order || null);
4115
+ setReturnOrder(payload.return);
4308
4116
  } catch (loadError) {
4309
- const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
4117
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
4310
4118
  setError(message);
4311
4119
  } finally {
4312
4120
  setIsLoading(false);
4313
4121
  }
4314
4122
  };
4315
- void loadSwap();
4123
+ void loadReturn();
4316
4124
  }, [id, navigate]);
4317
- const handleCancelExchange = async () => {
4125
+ const handleReject = async () => {
4318
4126
  if (!id) {
4319
4127
  return;
4320
4128
  }
4321
4129
  try {
4322
- setIsCancelling(true);
4130
+ setIsRejecting(true);
4323
4131
  setUpdateError(null);
4324
4132
  setUpdateSuccess(false);
4325
- const response = await fetch(`/admin/swaps/${id}/cancel`, {
4133
+ const response = await fetch(`/admin/return/${id}/reject`, {
4326
4134
  method: "POST",
4327
4135
  headers: {
4328
4136
  "Content-Type": "application/json"
4329
4137
  },
4330
- credentials: "include"
4138
+ credentials: "include",
4139
+ body: JSON.stringify({ reason: "Rejected by admin" })
4331
4140
  });
4332
4141
  if (!response.ok) {
4333
4142
  const message = await response.text();
4334
- throw new Error(message || "Unable to cancel exchange");
4143
+ throw new Error(message || "Unable to reject return");
4335
4144
  }
4336
4145
  const payload = await response.json();
4337
- setSwap(payload.swap);
4146
+ setReturnOrder(payload.return);
4338
4147
  setUpdateSuccess(true);
4339
4148
  setTimeout(() => setUpdateSuccess(false), 3e3);
4340
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
4149
+ const detailResponse = await fetch(`/admin/return/${id}`, {
4341
4150
  credentials: "include"
4342
4151
  });
4343
4152
  if (detailResponse.ok) {
4344
4153
  const detailPayload = await detailResponse.json();
4345
- setSwap(detailPayload.swap);
4346
- setOrder(detailPayload.order || null);
4154
+ setReturnOrder(detailPayload.return);
4347
4155
  }
4348
- } catch (cancelErr) {
4349
- const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
4156
+ } catch (updateErr) {
4157
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
4350
4158
  setUpdateError(message);
4351
4159
  } finally {
4352
- setIsCancelling(false);
4160
+ setIsRejecting(false);
4353
4161
  }
4354
4162
  };
4355
- const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
4356
- const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
4357
- ((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
4358
- );
4359
4163
  if (isLoading) {
4360
- 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..." }) }) }) });
4164
+ 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..." }) }) }) });
4361
4165
  }
4362
- if (error || !swap) {
4166
+ if (error || !returnOrder) {
4363
4167
  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: [
4364
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
4365
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
4168
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
4169
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
4366
4170
  ] }) }) });
4367
4171
  }
4368
- const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
4172
+ const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
4369
4173
  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: [
4370
4174
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
4371
4175
  /* @__PURE__ */ jsxs(
@@ -4373,7 +4177,7 @@ const SwapDetailPage = () => {
4373
4177
  {
4374
4178
  variant: "transparent",
4375
4179
  size: "small",
4376
- onClick: () => navigate("/swaps"),
4180
+ onClick: () => navigate("/returns"),
4377
4181
  className: "w-fit",
4378
4182
  children: [
4379
4183
  /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
@@ -4383,67 +4187,82 @@ const SwapDetailPage = () => {
4383
4187
  ),
4384
4188
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
4385
4189
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
4386
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
4387
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
4190
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
4191
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
4388
4192
  ] }),
4389
4193
  /* @__PURE__ */ jsx(
4390
4194
  Badge,
4391
4195
  {
4392
4196
  size: "small",
4393
- className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
4394
- children: swap.status.replace(/_/g, " ")
4197
+ className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
4198
+ children: returnOrder.status.replace(/_/g, " ")
4395
4199
  }
4396
4200
  )
4397
4201
  ] })
4398
4202
  ] }),
4399
- canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
4203
+ returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
4400
4204
  /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
4401
4205
  Button,
4402
4206
  {
4403
4207
  variant: "danger",
4404
- onClick: handleCancelExchange,
4405
- disabled: isCancelling,
4406
- isLoading: isCancelling,
4407
- children: "Cancel Exchange"
4408
- }
4409
- ) }),
4410
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
4208
+ onClick: handleReject,
4209
+ disabled: isRejecting,
4210
+ isLoading: isRejecting,
4211
+ children: "Reject (Cancel) Return"
4212
+ }
4213
+ ) }),
4214
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
4215
+ ] }),
4216
+ returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
4217
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4218
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
4219
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4220
+ /* @__PURE__ */ jsxs("div", { children: [
4221
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
4222
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
4223
+ ] }),
4224
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
4225
+ Button,
4226
+ {
4227
+ variant: "secondary",
4228
+ onClick: () => {
4229
+ window.open(
4230
+ `/app/orders/${returnOrder.order_id}`,
4231
+ "_blank"
4232
+ );
4233
+ },
4234
+ children: "View order"
4235
+ }
4236
+ ) })
4237
+ ] })
4411
4238
  ] }),
4412
4239
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
4413
4240
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4414
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
4241
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
4415
4242
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4416
4243
  /* @__PURE__ */ jsxs("div", { children: [
4417
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
4418
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
4244
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
4245
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
4419
4246
  ] }),
4420
4247
  /* @__PURE__ */ jsxs("div", { children: [
4421
4248
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
4422
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
4423
- ] }),
4424
- /* @__PURE__ */ jsxs("div", { children: [
4425
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
4426
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
4249
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
4427
4250
  ] }),
4428
- swap.reason && /* @__PURE__ */ jsxs("div", { children: [
4251
+ returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
4429
4252
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
4430
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
4253
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
4431
4254
  ] }),
4432
- swap.note && /* @__PURE__ */ jsxs("div", { children: [
4255
+ returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
4433
4256
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
4434
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
4257
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
4435
4258
  ] }),
4436
4259
  /* @__PURE__ */ jsxs("div", { children: [
4437
4260
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
4438
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
4261
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
4439
4262
  ] }),
4440
4263
  /* @__PURE__ */ jsxs("div", { children: [
4441
4264
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
4442
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
4443
- ] }),
4444
- swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
4445
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
4446
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
4265
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
4447
4266
  ] })
4448
4267
  ] })
4449
4268
  ] }),
@@ -4458,7 +4277,7 @@ const SwapDetailPage = () => {
4458
4277
  Badge,
4459
4278
  {
4460
4279
  size: "2xsmall",
4461
- className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
4280
+ className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
4462
4281
  children: entry.status.replace(/_/g, " ")
4463
4282
  }
4464
4283
  ) }),
@@ -4473,31 +4292,35 @@ const SwapDetailPage = () => {
4473
4292
  )) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
4474
4293
  ] })
4475
4294
  ] }),
4476
- order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4295
+ returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4477
4296
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
4478
4297
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4479
4298
  /* @__PURE__ */ jsxs("div", { children: [
4480
4299
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
4481
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
4300
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
4482
4301
  ] }),
4483
4302
  /* @__PURE__ */ jsxs("div", { children: [
4484
4303
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
4485
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
4304
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
4486
4305
  ] }),
4487
4306
  /* @__PURE__ */ jsxs("div", { children: [
4488
4307
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
4489
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
4308
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
4490
4309
  ] }),
4491
- order.total && /* @__PURE__ */ jsxs("div", { children: [
4310
+ /* @__PURE__ */ jsxs("div", { children: [
4311
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
4312
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = returnOrder.order.order_payment) == null ? void 0 : _c.label) || "—" })
4313
+ ] }),
4314
+ returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
4492
4315
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
4493
4316
  /* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
4494
- order.currency_code || "$",
4495
- (Number(order.total) / 100).toFixed(2)
4317
+ returnOrder.order.currency_code || "$",
4318
+ (Number(returnOrder.order.total) / 100).toFixed(2)
4496
4319
  ] })
4497
4320
  ] })
4498
4321
  ] })
4499
4322
  ] }),
4500
- 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: [
4323
+ 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: [
4501
4324
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
4502
4325
  /* @__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: [
4503
4326
  /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
@@ -4505,31 +4328,212 @@ const SwapDetailPage = () => {
4505
4328
  /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
4506
4329
  /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
4507
4330
  ] }) }),
4508
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4331
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4509
4332
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
4510
4333
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
4511
4334
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
4512
4335
  ] }, item.id || index)) })
4513
4336
  ] }) })
4514
4337
  ] }),
4515
- 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: [
4516
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
4517
- /* @__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: [
4518
- /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
4519
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
4520
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
4521
- ] }) }),
4522
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4523
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
4524
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
4525
- ] }, item.variant_id || index)) })
4526
- ] }) })
4527
- ] })
4338
+ 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 }) }),
4339
+ 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" }) })
4340
+ ] }) });
4341
+ };
4342
+ const config$2 = defineRouteConfig({
4343
+ label: "Return Order Details",
4344
+ icon: CheckCircle
4345
+ });
4346
+ const getStatusBadgeClass$1 = (status) => {
4347
+ const s2 = status.toLowerCase();
4348
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4349
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4350
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
4351
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4352
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4353
+ };
4354
+ const formatAmount = (value) => {
4355
+ return String(value);
4356
+ };
4357
+ const RefundDetailPage = () => {
4358
+ var _a, _b, _c;
4359
+ const navigate = useNavigate();
4360
+ const params = useParams();
4361
+ const id = (_a = params == null ? void 0 : params.id) == null ? void 0 : _a.trim();
4362
+ const [detail, setDetail] = useState(null);
4363
+ const [loading, setLoading] = useState(!!id);
4364
+ const [error, setError] = useState(null);
4365
+ const [gatewayExpanded, setGatewayExpanded] = useState(false);
4366
+ useEffect(() => {
4367
+ if (!id) {
4368
+ setLoading(false);
4369
+ return;
4370
+ }
4371
+ let cancelled = false;
4372
+ setLoading(true);
4373
+ setError(null);
4374
+ fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
4375
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
4376
+ return res.json();
4377
+ }).then((data) => {
4378
+ if (!cancelled) setDetail(data);
4379
+ }).catch((e) => {
4380
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
4381
+ }).finally(() => {
4382
+ if (!cancelled) setLoading(false);
4383
+ });
4384
+ return () => {
4385
+ cancelled = true;
4386
+ };
4387
+ }, [id]);
4388
+ const paymentStatus = ((_b = detail == null ? void 0 : detail.payment) == null ? void 0 : _b.status) ?? "—";
4389
+ const hasGatewayData = ((_c = detail == null ? void 0 : detail.payment) == null ? void 0 : _c.payment_data) && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
4390
+ 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: [
4391
+ /* @__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: [
4392
+ /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
4393
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
4394
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
4395
+ ] }) }),
4396
+ error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
4397
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
4398
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
4399
+ ] }) : 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: [
4400
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4401
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
4402
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4403
+ /* @__PURE__ */ jsxs("div", { children: [
4404
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
4405
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
4406
+ ] }),
4407
+ /* @__PURE__ */ jsxs("div", { children: [
4408
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
4409
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
4410
+ ] }),
4411
+ /* @__PURE__ */ jsxs("div", { children: [
4412
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
4413
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
4414
+ ] }),
4415
+ /* @__PURE__ */ jsxs("div", { children: [
4416
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
4417
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
4418
+ year: "numeric",
4419
+ month: "short",
4420
+ day: "numeric",
4421
+ hour: "numeric",
4422
+ minute: "2-digit",
4423
+ hour12: true
4424
+ }) })
4425
+ ] }),
4426
+ detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
4427
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
4428
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
4429
+ ] }) : null
4430
+ ] })
4431
+ ] }),
4432
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4433
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
4434
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4435
+ /* @__PURE__ */ jsxs("div", { children: [
4436
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
4437
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
4438
+ ] }),
4439
+ /* @__PURE__ */ jsxs("div", { children: [
4440
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
4441
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
4442
+ ] }),
4443
+ /* @__PURE__ */ jsxs("div", { children: [
4444
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
4445
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
4446
+ ] }),
4447
+ /* @__PURE__ */ jsxs("div", { children: [
4448
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
4449
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
4450
+ ] }),
4451
+ /* @__PURE__ */ jsxs("div", { children: [
4452
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
4453
+ /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4454
+ Badge,
4455
+ {
4456
+ size: "2xsmall",
4457
+ className: `uppercase ${getStatusBadgeClass$1(paymentStatus)}`,
4458
+ children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
4459
+ }
4460
+ ) })
4461
+ ] }),
4462
+ detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
4463
+ /* @__PURE__ */ jsxs("div", { children: [
4464
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
4465
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
4466
+ ] }),
4467
+ /* @__PURE__ */ jsxs("div", { children: [
4468
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
4469
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
4470
+ ] }),
4471
+ /* @__PURE__ */ jsxs("div", { children: [
4472
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
4473
+ /* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
4474
+ detail.computed.refund_percentage.toFixed(1),
4475
+ "%"
4476
+ ] })
4477
+ ] })
4478
+ ] }) : null
4479
+ ] })
4480
+ ] }),
4481
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4482
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
4483
+ detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4484
+ /* @__PURE__ */ jsxs("div", { children: [
4485
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
4486
+ /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4487
+ Button,
4488
+ {
4489
+ variant: "transparent",
4490
+ size: "small",
4491
+ onClick: () => navigate(`/orders/${detail.order.order_id}`),
4492
+ children: detail.order.order_number ?? detail.order.order_id
4493
+ }
4494
+ ) })
4495
+ ] }),
4496
+ detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
4497
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
4498
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
4499
+ ] }) : null,
4500
+ detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
4501
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
4502
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
4503
+ ] }) : null,
4504
+ detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
4505
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
4506
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
4507
+ ] }) : null,
4508
+ detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
4509
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
4510
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
4511
+ ] }) : null
4512
+ ] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
4513
+ ] }),
4514
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4515
+ /* @__PURE__ */ jsxs(
4516
+ "button",
4517
+ {
4518
+ type: "button",
4519
+ className: "flex w-full items-center justify-between text-left",
4520
+ onClick: () => setGatewayExpanded((prev) => !prev),
4521
+ "aria-expanded": gatewayExpanded,
4522
+ "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
4523
+ children: [
4524
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
4525
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
4526
+ ]
4527
+ }
4528
+ ),
4529
+ gatewayExpanded && /* @__PURE__ */ jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
4530
+ ] })
4531
+ ] }) : null
4528
4532
  ] }) });
4529
4533
  };
4530
4534
  const config$1 = defineRouteConfig({
4531
- label: "Swap Details",
4532
- icon: ArrowPath
4535
+ label: "Refund details",
4536
+ icon: Receipt
4533
4537
  });
4534
4538
  const getStatusBadgeClass = (status) => {
4535
4539
  const statusLower = status.toLowerCase();
@@ -4542,105 +4546,109 @@ const getStatusBadgeClass = (status) => {
4542
4546
  if (statusLower === "rejected") {
4543
4547
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
4544
4548
  }
4545
- if (statusLower === "received") {
4546
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4547
- }
4548
- if (statusLower === "refunded") {
4549
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
4550
- }
4551
4549
  if (statusLower === "completed") {
4552
4550
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
4553
4551
  }
4554
- if (statusLower === "cancelled") {
4552
+ if (statusLower === "cancelled" || statusLower === "canceled") {
4555
4553
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
4556
4554
  }
4555
+ if (statusLower === "pending") {
4556
+ return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4557
+ }
4557
4558
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4558
4559
  };
4559
- const ReturnDetailPage = () => {
4560
+ const SwapDetailPage = () => {
4560
4561
  var _a, _b, _c;
4561
4562
  const navigate = useNavigate();
4562
4563
  const { id } = useParams();
4563
- const [returnOrder, setReturnOrder] = useState(null);
4564
+ const [swap, setSwap] = useState(null);
4565
+ const [order, setOrder] = useState(null);
4564
4566
  const [isLoading, setIsLoading] = useState(true);
4565
- const [isRejecting, setIsRejecting] = useState(false);
4567
+ useState(false);
4568
+ const [isCancelling, setIsCancelling] = useState(false);
4566
4569
  const [error, setError] = useState(null);
4567
4570
  const [updateError, setUpdateError] = useState(null);
4568
4571
  const [updateSuccess, setUpdateSuccess] = useState(false);
4569
4572
  useEffect(() => {
4570
4573
  if (!id) {
4571
- navigate("/returns");
4574
+ navigate("/swaps");
4572
4575
  return;
4573
4576
  }
4574
- const loadReturn = async () => {
4577
+ const loadSwap = async () => {
4575
4578
  try {
4576
4579
  setIsLoading(true);
4577
4580
  setError(null);
4578
- const response = await fetch(`/admin/return/${id}`, {
4581
+ const response = await fetch(`/admin/swaps/${id}`, {
4579
4582
  credentials: "include"
4580
4583
  });
4581
4584
  if (!response.ok) {
4582
4585
  const message = await response.text();
4583
- throw new Error(message || "Unable to load return order");
4586
+ throw new Error(message || "Unable to load swap");
4584
4587
  }
4585
4588
  const payload = await response.json();
4586
- setReturnOrder(payload.return);
4589
+ setSwap(payload.swap);
4590
+ setOrder(payload.order || null);
4587
4591
  } catch (loadError) {
4588
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
4592
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
4589
4593
  setError(message);
4590
4594
  } finally {
4591
4595
  setIsLoading(false);
4592
4596
  }
4593
4597
  };
4594
- void loadReturn();
4598
+ void loadSwap();
4595
4599
  }, [id, navigate]);
4596
- const handleReject = async () => {
4600
+ const handleCancelExchange = async () => {
4597
4601
  if (!id) {
4598
4602
  return;
4599
4603
  }
4600
4604
  try {
4601
- setIsRejecting(true);
4605
+ setIsCancelling(true);
4602
4606
  setUpdateError(null);
4603
4607
  setUpdateSuccess(false);
4604
- const response = await fetch(`/admin/return/${id}/reject`, {
4608
+ const response = await fetch(`/admin/swaps/${id}/cancel`, {
4605
4609
  method: "POST",
4606
4610
  headers: {
4607
4611
  "Content-Type": "application/json"
4608
4612
  },
4609
- credentials: "include",
4610
- body: JSON.stringify({ reason: "Rejected by admin" })
4613
+ credentials: "include"
4611
4614
  });
4612
4615
  if (!response.ok) {
4613
4616
  const message = await response.text();
4614
- throw new Error(message || "Unable to reject return");
4617
+ throw new Error(message || "Unable to cancel exchange");
4615
4618
  }
4616
4619
  const payload = await response.json();
4617
- setReturnOrder(payload.return);
4620
+ setSwap(payload.swap);
4618
4621
  setUpdateSuccess(true);
4619
4622
  setTimeout(() => setUpdateSuccess(false), 3e3);
4620
- const detailResponse = await fetch(`/admin/return/${id}`, {
4623
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
4621
4624
  credentials: "include"
4622
4625
  });
4623
4626
  if (detailResponse.ok) {
4624
4627
  const detailPayload = await detailResponse.json();
4625
- setReturnOrder(detailPayload.return);
4628
+ setSwap(detailPayload.swap);
4629
+ setOrder(detailPayload.order || null);
4626
4630
  }
4627
- } catch (updateErr) {
4628
- const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
4631
+ } catch (cancelErr) {
4632
+ const message = cancelErr instanceof Error ? cancelErr.message : "Unable to cancel exchange";
4629
4633
  setUpdateError(message);
4630
4634
  } finally {
4631
- setIsRejecting(false);
4635
+ setIsCancelling(false);
4632
4636
  }
4633
4637
  };
4638
+ const isOrderExchange = Boolean(swap == null ? void 0 : swap.exchange_id);
4639
+ const canCancelExchange = isOrderExchange && swap && !["cancelled", "canceled", "completed", "declined"].includes(
4640
+ ((_a = swap.status) == null ? void 0 : _a.toLowerCase()) ?? ""
4641
+ );
4634
4642
  if (isLoading) {
4635
- 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..." }) }) }) });
4643
+ 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..." }) }) }) });
4636
4644
  }
4637
- if (error || !returnOrder) {
4645
+ if (error || !swap) {
4638
4646
  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: [
4639
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
4640
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
4647
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
4648
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
4641
4649
  ] }) }) });
4642
4650
  }
4643
- const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
4651
+ const statusHistory = ((_b = swap.metadata) == null ? void 0 : _b.status_history) || [];
4644
4652
  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: [
4645
4653
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
4646
4654
  /* @__PURE__ */ jsxs(
@@ -4648,7 +4656,7 @@ const ReturnDetailPage = () => {
4648
4656
  {
4649
4657
  variant: "transparent",
4650
4658
  size: "small",
4651
- onClick: () => navigate("/returns"),
4659
+ onClick: () => navigate("/swaps"),
4652
4660
  className: "w-fit",
4653
4661
  children: [
4654
4662
  /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
@@ -4658,82 +4666,67 @@ const ReturnDetailPage = () => {
4658
4666
  ),
4659
4667
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
4660
4668
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
4661
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
4662
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
4669
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Exchange Details" }),
4670
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
4663
4671
  ] }),
4664
4672
  /* @__PURE__ */ jsx(
4665
4673
  Badge,
4666
4674
  {
4667
4675
  size: "small",
4668
- className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
4669
- children: returnOrder.status.replace(/_/g, " ")
4676
+ className: `uppercase ${getStatusBadgeClass(swap.status)}`,
4677
+ children: swap.status.replace(/_/g, " ")
4670
4678
  }
4671
4679
  )
4672
4680
  ] })
4673
4681
  ] }),
4674
- returnOrder.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
4682
+ canCancelExchange && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
4675
4683
  /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsx(
4676
4684
  Button,
4677
4685
  {
4678
4686
  variant: "danger",
4679
- onClick: handleReject,
4680
- disabled: isRejecting,
4681
- isLoading: isRejecting,
4682
- children: "Reject (Cancel) Return"
4687
+ onClick: handleCancelExchange,
4688
+ disabled: isCancelling,
4689
+ isLoading: isCancelling,
4690
+ children: "Cancel Exchange"
4683
4691
  }
4684
4692
  ) }),
4685
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: 'Cancel this return request. Use "Mark as received" when items are received.' })
4686
- ] }),
4687
- returnOrder.refund ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: /* @__PURE__ */ jsx(RefundCalculationBlock, { refund: returnOrder.refund }) }) : null,
4688
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4689
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
4690
- /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4691
- /* @__PURE__ */ jsxs("div", { children: [
4692
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
4693
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
4694
- ] }),
4695
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
4696
- Button,
4697
- {
4698
- variant: "secondary",
4699
- onClick: () => {
4700
- window.open(
4701
- `/app/orders/${returnOrder.order_id}`,
4702
- "_blank"
4703
- );
4704
- },
4705
- children: "View order"
4706
- }
4707
- ) })
4708
- ] })
4693
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This will cancel the exchange request. The order will remain unchanged." })
4709
4694
  ] }),
4710
4695
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
4711
4696
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4712
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
4697
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
4713
4698
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4714
4699
  /* @__PURE__ */ jsxs("div", { children: [
4715
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
4716
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
4700
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
4701
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
4717
4702
  ] }),
4718
4703
  /* @__PURE__ */ jsxs("div", { children: [
4719
4704
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
4720
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
4705
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
4721
4706
  ] }),
4722
- returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
4707
+ /* @__PURE__ */ jsxs("div", { children: [
4708
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
4709
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
4710
+ ] }),
4711
+ swap.reason && /* @__PURE__ */ jsxs("div", { children: [
4723
4712
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
4724
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
4713
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
4725
4714
  ] }),
4726
- returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
4715
+ swap.note && /* @__PURE__ */ jsxs("div", { children: [
4727
4716
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
4728
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
4717
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
4729
4718
  ] }),
4730
4719
  /* @__PURE__ */ jsxs("div", { children: [
4731
4720
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
4732
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
4721
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
4733
4722
  ] }),
4734
4723
  /* @__PURE__ */ jsxs("div", { children: [
4735
4724
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
4736
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
4725
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
4726
+ ] }),
4727
+ swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
4728
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
4729
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
4737
4730
  ] })
4738
4731
  ] })
4739
4732
  ] }),
@@ -4763,35 +4756,31 @@ const ReturnDetailPage = () => {
4763
4756
  )) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
4764
4757
  ] })
4765
4758
  ] }),
4766
- returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4759
+ order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
4767
4760
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
4768
4761
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4769
4762
  /* @__PURE__ */ jsxs("div", { children: [
4770
4763
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
4771
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
4764
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
4772
4765
  ] }),
4773
4766
  /* @__PURE__ */ jsxs("div", { children: [
4774
4767
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
4775
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
4768
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
4776
4769
  ] }),
4777
4770
  /* @__PURE__ */ jsxs("div", { children: [
4778
4771
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
4779
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
4780
- ] }),
4781
- /* @__PURE__ */ jsxs("div", { children: [
4782
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Payment method" }),
4783
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = returnOrder.order.order_payment) == null ? void 0 : _c.label) || "—" })
4772
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = order.customer) == null ? void 0 : _c.email) || order.email || "—" })
4784
4773
  ] }),
4785
- returnOrder.order.total && /* @__PURE__ */ jsxs("div", { children: [
4774
+ order.total && /* @__PURE__ */ jsxs("div", { children: [
4786
4775
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
4787
4776
  /* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
4788
- returnOrder.order.currency_code || "$",
4789
- (Number(returnOrder.order.total) / 100).toFixed(2)
4777
+ order.currency_code || "$",
4778
+ (Number(order.total) / 100).toFixed(2)
4790
4779
  ] })
4791
4780
  ] })
4792
4781
  ] })
4793
4782
  ] }),
4794
- 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: [
4783
+ 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: [
4795
4784
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
4796
4785
  /* @__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: [
4797
4786
  /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
@@ -4799,20 +4788,31 @@ const ReturnDetailPage = () => {
4799
4788
  /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
4800
4789
  /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
4801
4790
  ] }) }),
4802
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4791
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4803
4792
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
4804
4793
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
4805
4794
  /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
4806
4795
  ] }, item.id || index)) })
4807
4796
  ] }) })
4808
4797
  ] }),
4809
- 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 }) }),
4810
- 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" }) })
4798
+ 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: [
4799
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
4800
+ /* @__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: [
4801
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
4802
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
4803
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
4804
+ ] }) }),
4805
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
4806
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
4807
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
4808
+ ] }, item.variant_id || index)) })
4809
+ ] }) })
4810
+ ] })
4811
4811
  ] }) });
4812
4812
  };
4813
4813
  const config = defineRouteConfig({
4814
- label: "Return Order Details",
4815
- icon: CheckCircle
4814
+ label: "Swap Details",
4815
+ icon: ArrowPath
4816
4816
  });
4817
4817
  const i18nTranslations0 = {};
4818
4818
  const widgetModule = { widgets: [
@@ -4831,14 +4831,14 @@ const routeModule = {
4831
4831
  Component: DeletedRecordsPage,
4832
4832
  path: "/deleted-records-audit"
4833
4833
  },
4834
- {
4835
- Component: RefundsPage,
4836
- path: "/refunds"
4837
- },
4838
4834
  {
4839
4835
  Component: PaymentsPage,
4840
4836
  path: "/payments"
4841
4837
  },
4838
+ {
4839
+ Component: RefundsPage,
4840
+ path: "/refunds"
4841
+ },
4842
4842
  {
4843
4843
  Component: ReturnsPage,
4844
4844
  path: "/returns"
@@ -4851,32 +4851,26 @@ const routeModule = {
4851
4851
  Component: DeletedRecordDetailPage,
4852
4852
  path: "/deleted-records-audit/:id"
4853
4853
  },
4854
- {
4855
- Component: RefundDetailPage,
4856
- path: "/refunds/:id"
4857
- },
4858
4854
  {
4859
4855
  Component: PaymentDetailPage,
4860
4856
  path: "/payments/:id"
4861
4857
  },
4862
- {
4863
- Component: SwapDetailPage,
4864
- path: "/swaps/:id"
4865
- },
4866
4858
  {
4867
4859
  Component: ReturnDetailPage,
4868
4860
  path: "/returns/:id"
4861
+ },
4862
+ {
4863
+ Component: RefundDetailPage,
4864
+ path: "/refunds/:id"
4865
+ },
4866
+ {
4867
+ Component: SwapDetailPage,
4868
+ path: "/swaps/:id"
4869
4869
  }
4870
4870
  ]
4871
4871
  };
4872
4872
  const menuItemModule = {
4873
4873
  menuItems: [
4874
- {
4875
- label: config$6.label,
4876
- icon: config$6.icon,
4877
- path: "/payments",
4878
- nested: void 0
4879
- },
4880
4874
  {
4881
4875
  label: config$8.label,
4882
4876
  icon: config$8.icon,
@@ -4884,17 +4878,23 @@ const menuItemModule = {
4884
4878
  nested: void 0
4885
4879
  },
4886
4880
  {
4887
- label: config$5.label,
4888
- icon: config$5.icon,
4889
- path: "/returns",
4881
+ label: config$7.label,
4882
+ icon: config$7.icon,
4883
+ path: "/payments",
4890
4884
  nested: void 0
4891
4885
  },
4892
4886
  {
4893
- label: config$7.label,
4894
- icon: config$7.icon,
4887
+ label: config$6.label,
4888
+ icon: config$6.icon,
4895
4889
  path: "/refunds",
4896
4890
  nested: void 0
4897
4891
  },
4892
+ {
4893
+ label: config$5.label,
4894
+ icon: config$5.icon,
4895
+ path: "/returns",
4896
+ nested: void 0
4897
+ },
4898
4898
  {
4899
4899
  label: config$4.label,
4900
4900
  icon: config$4.icon,
@@ -4902,26 +4902,26 @@ const menuItemModule = {
4902
4902
  nested: void 0
4903
4903
  },
4904
4904
  {
4905
- label: config$2.label,
4906
- icon: config$2.icon,
4907
- path: "/payments/:id",
4905
+ label: config$1.label,
4906
+ icon: config$1.icon,
4907
+ path: "/refunds/:id",
4908
4908
  nested: void 0
4909
4909
  },
4910
4910
  {
4911
- label: config.label,
4912
- icon: config.icon,
4913
- path: "/returns/:id",
4911
+ label: config$3.label,
4912
+ icon: config$3.icon,
4913
+ path: "/payments/:id",
4914
4914
  nested: void 0
4915
4915
  },
4916
4916
  {
4917
- label: config$3.label,
4918
- icon: config$3.icon,
4919
- path: "/refunds/:id",
4917
+ label: config$2.label,
4918
+ icon: config$2.icon,
4919
+ path: "/returns/:id",
4920
4920
  nested: void 0
4921
4921
  },
4922
4922
  {
4923
- label: config$1.label,
4924
- icon: config$1.icon,
4923
+ label: config.label,
4924
+ icon: config.icon,
4925
4925
  path: "/swaps/:id",
4926
4926
  nested: void 0
4927
4927
  }