order-management 0.0.111 → 0.0.112

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