order-management 0.0.103 → 0.0.104

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.
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
3
3
  import { useState, useEffect, useRef, useMemo, useCallback } from "react";
4
4
  import { Text, Container, Heading, Badge, Button, Label, Select, Textarea, Popover, clx, Input, Copy, Skeleton, Tooltip, toast } from "@medusajs/ui";
5
- import { CashSolid, PencilSquareSolid, Trash, ChevronDownMini, Check, ArrowPath, InformationCircle, ExclamationCircle, MagnifierAlert, ChevronRightMini, Receipt, CreditCard, ArrowLeft, ClockSolid, ShieldCheck, SquareTwoStack, CheckCircle } from "@medusajs/icons";
5
+ import { CashSolid, PencilSquareSolid, Trash, ChevronDownMini, Check, ArrowPath, InformationCircle, ExclamationCircle, MagnifierAlert, ChevronRightMini, CreditCard, Receipt, ArrowLeft, ClockSolid, ShieldCheck, SquareTwoStack, CheckCircle } from "@medusajs/icons";
6
6
  import { useNavigate, useLocation, useSearchParams, useParams } from "react-router-dom";
7
7
  function roundRectPath(ctx, x, y, w, h, r) {
8
8
  ctx.beginPath();
@@ -2228,27 +2228,19 @@ const getStatusBadgeClass$7 = (status) => {
2228
2228
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2229
2229
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2230
2230
  };
2231
- const RefundsPage = () => {
2231
+ const PaymentsPage = () => {
2232
2232
  const navigate = useNavigate();
2233
2233
  const [items, setItems] = useState([]);
2234
+ const [statusFilter, setStatusFilter] = useState("all");
2234
2235
  const [orderIdSearch, setOrderIdSearch] = useState("");
2235
2236
  const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
2236
- const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
2237
- const [providerSearch, setProviderSearch] = useState("");
2238
- const debouncedProvider = useDebounce$3(providerSearch, 300);
2239
- const [currencySearch, setCurrencySearch] = useState("");
2240
- const debouncedCurrency = useDebounce$3(currencySearch, 300);
2241
- const [dateFrom, setDateFrom] = useState("");
2242
- const [dateTo, setDateTo] = useState("");
2243
- const [amountMin, setAmountMin] = useState("");
2244
- const [amountMax, setAmountMax] = useState("");
2245
2237
  const [isLoading, setIsLoading] = useState(true);
2246
2238
  const [isFetchingMore, setIsFetchingMore] = useState(false);
2247
2239
  const [error, setError] = useState(null);
2248
2240
  const [offset, setOffset] = useState(0);
2249
2241
  const [count, setCount] = useState(0);
2250
2242
  const limit = 50;
2251
- const loadRefunds = useCallback(
2243
+ const loadTransactions = useCallback(
2252
2244
  async (nextOffset, replace) => {
2253
2245
  try {
2254
2246
  if (replace) setIsLoading(true);
@@ -2257,25 +2249,18 @@ const RefundsPage = () => {
2257
2249
  const params = new URLSearchParams();
2258
2250
  params.set("limit", String(limit));
2259
2251
  params.set("offset", String(nextOffset));
2252
+ if (statusFilter !== "all") params.set("status", statusFilter);
2260
2253
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2261
- if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
2262
- if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
2263
- if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
2264
- if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
2265
- if (dateTo.trim()) params.set("date_to", dateTo.trim());
2266
- const min = amountMin.trim() ? Number(amountMin) : void 0;
2267
- const max = amountMax.trim() ? Number(amountMax) : void 0;
2268
- if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
2269
- if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
2270
- const response = await fetch(`/admin/refunds?${params.toString()}`, {
2271
- credentials: "include"
2272
- });
2254
+ const response = await fetch(
2255
+ `/admin/payment-transactions?${params.toString()}`,
2256
+ { credentials: "include" }
2257
+ );
2273
2258
  if (!response.ok) {
2274
2259
  const text = await response.text();
2275
- throw new Error(text || "Failed to load refunds");
2260
+ throw new Error(text || "Failed to load payment transactions");
2276
2261
  }
2277
2262
  const payload = await response.json();
2278
- const list = payload.refunds ?? [];
2263
+ const list = payload.transactions ?? [];
2279
2264
  setCount(payload.count ?? 0);
2280
2265
  setOffset(nextOffset + list.length);
2281
2266
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -2286,75 +2271,46 @@ const RefundsPage = () => {
2286
2271
  setIsFetchingMore(false);
2287
2272
  }
2288
2273
  },
2289
- [
2290
- debouncedOrderId,
2291
- paymentStatusFilter,
2292
- debouncedProvider,
2293
- debouncedCurrency,
2294
- dateFrom,
2295
- dateTo,
2296
- amountMin,
2297
- amountMax
2298
- ]
2274
+ [statusFilter, debouncedOrderId]
2299
2275
  );
2300
2276
  useEffect(() => {
2301
- void loadRefunds(0, true);
2302
- }, [loadRefunds]);
2277
+ void loadTransactions(0, true);
2278
+ }, [loadTransactions]);
2303
2279
  const hasMore = useMemo(() => offset < count, [offset, count]);
2304
- const displayAmount = (r) => {
2305
- const code = (r.currency_code ?? "USD").toUpperCase();
2306
- return `${code} ${Number(r.amount)}`;
2307
- };
2308
- const displayStatus = (r) => {
2309
- const s2 = r.payment_status ?? "";
2280
+ const displayStatus = (t) => {
2281
+ const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2310
2282
  return s2 !== "" ? s2 : "—";
2311
2283
  };
2284
+ const displayAmount = (t) => {
2285
+ const code = (t.currency_code ?? "USD").toUpperCase();
2286
+ return `${code} ${Number(t.amount)}`;
2287
+ };
2312
2288
  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: [
2313
2289
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2314
2290
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
2315
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refunds" }),
2316
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund records — amount, order, payment status" })
2291
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
2292
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2317
2293
  ] }),
2318
- /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
2294
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2319
2295
  ] }),
2320
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2296
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2321
2297
  /* @__PURE__ */ jsx(
2322
2298
  Input,
2323
2299
  {
2324
- placeholder: "Order ID",
2300
+ placeholder: "Search by Order ID",
2325
2301
  value: orderIdSearch,
2326
2302
  onChange: (e) => setOrderIdSearch(e.target.value),
2327
- className: "md:max-w-[180px]",
2328
- "aria-label": "Filter by order ID"
2329
- }
2330
- ),
2331
- /* @__PURE__ */ jsx(
2332
- Input,
2333
- {
2334
- placeholder: "Provider",
2335
- value: providerSearch,
2336
- onChange: (e) => setProviderSearch(e.target.value),
2337
- className: "md:max-w-[140px]",
2338
- "aria-label": "Filter by provider"
2339
- }
2340
- ),
2341
- /* @__PURE__ */ jsx(
2342
- Input,
2343
- {
2344
- placeholder: "Currency",
2345
- value: currencySearch,
2346
- onChange: (e) => setCurrencySearch(e.target.value),
2347
- className: "md:max-w-[100px]",
2348
- "aria-label": "Filter by currency"
2303
+ className: "md:max-w-sm",
2304
+ "aria-label": "Search by order ID"
2349
2305
  }
2350
2306
  ),
2351
- /* @__PURE__ */ jsxs(
2307
+ /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
2352
2308
  "select",
2353
2309
  {
2354
- value: paymentStatusFilter,
2355
- onChange: (e) => setPaymentStatusFilter(e.target.value),
2356
- 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-[160px]",
2357
- "aria-label": "Filter by payment status",
2310
+ value: statusFilter,
2311
+ onChange: (e) => setStatusFilter(e.target.value),
2312
+ 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",
2313
+ "aria-label": "Filter by status",
2358
2314
  children: [
2359
2315
  /* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
2360
2316
  /* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
@@ -2365,103 +2321,52 @@ const RefundsPage = () => {
2365
2321
  /* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
2366
2322
  ]
2367
2323
  }
2368
- ),
2369
- /* @__PURE__ */ jsx(
2370
- Input,
2371
- {
2372
- type: "date",
2373
- placeholder: "From",
2374
- value: dateFrom,
2375
- onChange: (e) => setDateFrom(e.target.value),
2376
- className: "md:max-w-[140px]",
2377
- "aria-label": "Date from"
2378
- }
2379
- ),
2380
- /* @__PURE__ */ jsx(
2381
- Input,
2382
- {
2383
- type: "date",
2384
- placeholder: "To",
2385
- value: dateTo,
2386
- onChange: (e) => setDateTo(e.target.value),
2387
- className: "md:max-w-[140px]",
2388
- "aria-label": "Date to"
2389
- }
2390
- ),
2391
- /* @__PURE__ */ jsx(
2392
- Input,
2393
- {
2394
- placeholder: "Amount min",
2395
- value: amountMin,
2396
- onChange: (e) => setAmountMin(e.target.value),
2397
- type: "number",
2398
- min: 0,
2399
- className: "md:max-w-[100px]",
2400
- "aria-label": "Refund amount minimum"
2401
- }
2402
- ),
2403
- /* @__PURE__ */ jsx(
2404
- Input,
2405
- {
2406
- placeholder: "Amount max",
2407
- value: amountMax,
2408
- onChange: (e) => setAmountMax(e.target.value),
2409
- type: "number",
2410
- min: 0,
2411
- className: "md:max-w-[100px]",
2412
- "aria-label": "Refund amount maximum"
2413
- }
2414
- )
2415
- ] }) }),
2324
+ ) })
2325
+ ] }),
2416
2326
  error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2417
2327
  /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2418
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
2328
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2419
2329
  ] }) : null,
2420
- isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2421
- /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
2422
- /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
2423
- ] }) : /* @__PURE__ */ jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
2330
+ 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: [
2331
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2332
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2333
+ ] }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
2424
2334
  /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
2425
- /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
2426
- /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2427
- /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
2428
- /* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2429
- /* @__PURE__ */ jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
2430
- /* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2431
- /* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
2432
- /* @__PURE__ */ jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
2433
- /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2434
- /* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2335
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2336
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2337
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2338
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2339
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2340
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2341
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2435
2342
  ] }) }),
2436
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxs(
2343
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
2437
2344
  "tr",
2438
2345
  {
2439
- className: "cursor-pointer hover:bg-ui-bg-subtle/60",
2440
- onClick: () => navigate(`/refunds/${r.refund_id}`),
2346
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2347
+ onClick: () => navigate(`/payments/${t.payment_session_id}`),
2441
2348
  children: [
2442
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
2443
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
2444
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
2445
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
2446
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
2447
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
2448
- /* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(
2349
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2350
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2351
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2352
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
2449
2353
  Badge,
2450
2354
  {
2451
2355
  size: "2xsmall",
2452
- className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
2453
- children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
2356
+ className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
2357
+ children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2454
2358
  }
2455
2359
  ) }),
2456
- /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
2457
- /* @__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", {
2360
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2361
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2362
+ year: "numeric",
2458
2363
  month: "short",
2459
2364
  day: "numeric",
2460
2365
  hour: "numeric",
2461
2366
  minute: "2-digit",
2462
2367
  hour12: true
2463
2368
  }) }),
2464
- /* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
2369
+ /* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
2465
2370
  /* @__PURE__ */ jsx(
2466
2371
  Button,
2467
2372
  {
@@ -2469,27 +2374,27 @@ const RefundsPage = () => {
2469
2374
  size: "small",
2470
2375
  onClick: (e) => {
2471
2376
  e.stopPropagation();
2472
- navigate(`/refunds/${r.refund_id}`);
2377
+ navigate(`/payments/${t.payment_session_id}`);
2473
2378
  },
2474
- children: "Details"
2379
+ children: "View details"
2475
2380
  }
2476
2381
  ),
2477
- r.order_id ? /* @__PURE__ */ jsx(
2382
+ t.order_id ? /* @__PURE__ */ jsx(
2478
2383
  Button,
2479
2384
  {
2480
2385
  variant: "transparent",
2481
2386
  size: "small",
2482
2387
  onClick: (e) => {
2483
2388
  e.stopPropagation();
2484
- navigate(`/orders/${r.order_id}`);
2389
+ navigate(`/orders/${t.order_id}`);
2485
2390
  },
2486
2391
  children: "Order"
2487
2392
  }
2488
2393
  ) : null
2489
- ] }) })
2394
+ ] })
2490
2395
  ]
2491
2396
  },
2492
- r.refund_id
2397
+ t.payment_session_id
2493
2398
  )) })
2494
2399
  ] }) }),
2495
2400
  hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
@@ -2497,15 +2402,15 @@ const RefundsPage = () => {
2497
2402
  {
2498
2403
  variant: "secondary",
2499
2404
  isLoading: isFetchingMore,
2500
- onClick: () => loadRefunds(offset, false),
2405
+ onClick: () => loadTransactions(offset, false),
2501
2406
  children: "Load more"
2502
2407
  }
2503
2408
  ) }) : null
2504
2409
  ] }) });
2505
2410
  };
2506
2411
  const config$8 = defineRouteConfig({
2507
- label: "Refunds",
2508
- icon: Receipt
2412
+ label: "Payments",
2413
+ icon: CreditCard
2509
2414
  });
2510
2415
  const useDebounce$2 = (value, delay) => {
2511
2416
  const [debouncedValue, setDebouncedValue] = useState(value);
@@ -2523,19 +2428,27 @@ const getStatusBadgeClass$6 = (status) => {
2523
2428
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2524
2429
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2525
2430
  };
2526
- const PaymentsPage = () => {
2431
+ const RefundsPage = () => {
2527
2432
  const navigate = useNavigate();
2528
2433
  const [items, setItems] = useState([]);
2529
- const [statusFilter, setStatusFilter] = useState("all");
2530
2434
  const [orderIdSearch, setOrderIdSearch] = useState("");
2531
2435
  const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
2436
+ const [paymentStatusFilter, setPaymentStatusFilter] = useState("all");
2437
+ const [providerSearch, setProviderSearch] = useState("");
2438
+ const debouncedProvider = useDebounce$2(providerSearch, 300);
2439
+ const [currencySearch, setCurrencySearch] = useState("");
2440
+ const debouncedCurrency = useDebounce$2(currencySearch, 300);
2441
+ const [dateFrom, setDateFrom] = useState("");
2442
+ const [dateTo, setDateTo] = useState("");
2443
+ const [amountMin, setAmountMin] = useState("");
2444
+ const [amountMax, setAmountMax] = useState("");
2532
2445
  const [isLoading, setIsLoading] = useState(true);
2533
2446
  const [isFetchingMore, setIsFetchingMore] = useState(false);
2534
2447
  const [error, setError] = useState(null);
2535
2448
  const [offset, setOffset] = useState(0);
2536
2449
  const [count, setCount] = useState(0);
2537
2450
  const limit = 50;
2538
- const loadTransactions = useCallback(
2451
+ const loadRefunds = useCallback(
2539
2452
  async (nextOffset, replace) => {
2540
2453
  try {
2541
2454
  if (replace) setIsLoading(true);
@@ -2544,18 +2457,25 @@ const PaymentsPage = () => {
2544
2457
  const params = new URLSearchParams();
2545
2458
  params.set("limit", String(limit));
2546
2459
  params.set("offset", String(nextOffset));
2547
- if (statusFilter !== "all") params.set("status", statusFilter);
2548
2460
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2549
- const response = await fetch(
2550
- `/admin/payment-transactions?${params.toString()}`,
2551
- { credentials: "include" }
2552
- );
2461
+ if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
2462
+ if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
2463
+ if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
2464
+ if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
2465
+ if (dateTo.trim()) params.set("date_to", dateTo.trim());
2466
+ const min = amountMin.trim() ? Number(amountMin) : void 0;
2467
+ const max = amountMax.trim() ? Number(amountMax) : void 0;
2468
+ if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
2469
+ if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
2470
+ const response = await fetch(`/admin/refunds?${params.toString()}`, {
2471
+ credentials: "include"
2472
+ });
2553
2473
  if (!response.ok) {
2554
2474
  const text = await response.text();
2555
- throw new Error(text || "Failed to load payment transactions");
2475
+ throw new Error(text || "Failed to load refunds");
2556
2476
  }
2557
2477
  const payload = await response.json();
2558
- const list = payload.transactions ?? [];
2478
+ const list = payload.refunds ?? [];
2559
2479
  setCount(payload.count ?? 0);
2560
2480
  setOffset(nextOffset + list.length);
2561
2481
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -2566,46 +2486,75 @@ const PaymentsPage = () => {
2566
2486
  setIsFetchingMore(false);
2567
2487
  }
2568
2488
  },
2569
- [statusFilter, debouncedOrderId]
2489
+ [
2490
+ debouncedOrderId,
2491
+ paymentStatusFilter,
2492
+ debouncedProvider,
2493
+ debouncedCurrency,
2494
+ dateFrom,
2495
+ dateTo,
2496
+ amountMin,
2497
+ amountMax
2498
+ ]
2570
2499
  );
2571
2500
  useEffect(() => {
2572
- void loadTransactions(0, true);
2573
- }, [loadTransactions]);
2501
+ void loadRefunds(0, true);
2502
+ }, [loadRefunds]);
2574
2503
  const hasMore = useMemo(() => offset < count, [offset, count]);
2575
- const displayStatus = (t) => {
2576
- const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2577
- return s2 !== "" ? s2 : "—";
2504
+ const displayAmount = (r) => {
2505
+ const code = (r.currency_code ?? "USD").toUpperCase();
2506
+ return `${code} ${Number(r.amount)}`;
2578
2507
  };
2579
- const displayAmount = (t) => {
2580
- const code = (t.currency_code ?? "USD").toUpperCase();
2581
- return `${code} ${Number(t.amount)}`;
2508
+ const displayStatus = (r) => {
2509
+ const s2 = r.payment_status ?? "";
2510
+ return s2 !== "" ? s2 : "—";
2582
2511
  };
2583
2512
  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: [
2584
2513
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2585
2514
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
2586
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Payments" }),
2587
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2515
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refunds" }),
2516
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund records — amount, order, payment status" })
2588
2517
  ] }),
2589
- /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2518
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
2590
2519
  ] }),
2591
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2520
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2592
2521
  /* @__PURE__ */ jsx(
2593
2522
  Input,
2594
2523
  {
2595
- placeholder: "Search by Order ID",
2524
+ placeholder: "Order ID",
2596
2525
  value: orderIdSearch,
2597
2526
  onChange: (e) => setOrderIdSearch(e.target.value),
2598
- className: "md:max-w-sm",
2599
- "aria-label": "Search by order ID"
2527
+ className: "md:max-w-[180px]",
2528
+ "aria-label": "Filter by order ID"
2600
2529
  }
2601
2530
  ),
2602
- /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxs(
2531
+ /* @__PURE__ */ jsx(
2532
+ Input,
2533
+ {
2534
+ placeholder: "Provider",
2535
+ value: providerSearch,
2536
+ onChange: (e) => setProviderSearch(e.target.value),
2537
+ className: "md:max-w-[140px]",
2538
+ "aria-label": "Filter by provider"
2539
+ }
2540
+ ),
2541
+ /* @__PURE__ */ jsx(
2542
+ Input,
2543
+ {
2544
+ placeholder: "Currency",
2545
+ value: currencySearch,
2546
+ onChange: (e) => setCurrencySearch(e.target.value),
2547
+ className: "md:max-w-[100px]",
2548
+ "aria-label": "Filter by currency"
2549
+ }
2550
+ ),
2551
+ /* @__PURE__ */ jsxs(
2603
2552
  "select",
2604
2553
  {
2605
- value: statusFilter,
2606
- onChange: (e) => setStatusFilter(e.target.value),
2607
- 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",
2608
- "aria-label": "Filter by status",
2554
+ value: paymentStatusFilter,
2555
+ onChange: (e) => setPaymentStatusFilter(e.target.value),
2556
+ 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-[160px]",
2557
+ "aria-label": "Filter by payment status",
2609
2558
  children: [
2610
2559
  /* @__PURE__ */ jsx("option", { value: "all", children: "All statuses" }),
2611
2560
  /* @__PURE__ */ jsx("option", { value: "pending", children: "Pending" }),
@@ -2616,52 +2565,103 @@ const PaymentsPage = () => {
2616
2565
  /* @__PURE__ */ jsx("option", { value: "captured", children: "Captured" })
2617
2566
  ]
2618
2567
  }
2619
- ) })
2620
- ] }),
2568
+ ),
2569
+ /* @__PURE__ */ jsx(
2570
+ Input,
2571
+ {
2572
+ type: "date",
2573
+ placeholder: "From",
2574
+ value: dateFrom,
2575
+ onChange: (e) => setDateFrom(e.target.value),
2576
+ className: "md:max-w-[140px]",
2577
+ "aria-label": "Date from"
2578
+ }
2579
+ ),
2580
+ /* @__PURE__ */ jsx(
2581
+ Input,
2582
+ {
2583
+ type: "date",
2584
+ placeholder: "To",
2585
+ value: dateTo,
2586
+ onChange: (e) => setDateTo(e.target.value),
2587
+ className: "md:max-w-[140px]",
2588
+ "aria-label": "Date to"
2589
+ }
2590
+ ),
2591
+ /* @__PURE__ */ jsx(
2592
+ Input,
2593
+ {
2594
+ placeholder: "Amount min",
2595
+ value: amountMin,
2596
+ onChange: (e) => setAmountMin(e.target.value),
2597
+ type: "number",
2598
+ min: 0,
2599
+ className: "md:max-w-[100px]",
2600
+ "aria-label": "Refund amount minimum"
2601
+ }
2602
+ ),
2603
+ /* @__PURE__ */ jsx(
2604
+ Input,
2605
+ {
2606
+ placeholder: "Amount max",
2607
+ value: amountMax,
2608
+ onChange: (e) => setAmountMax(e.target.value),
2609
+ type: "number",
2610
+ min: 0,
2611
+ className: "md:max-w-[100px]",
2612
+ "aria-label": "Refund amount maximum"
2613
+ }
2614
+ )
2615
+ ] }) }),
2621
2616
  error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2622
2617
  /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2623
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2618
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
2624
2619
  ] }) : null,
2625
- 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: [
2626
- /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2627
- /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2628
- ] }) : /* @__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: [
2629
- /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
2630
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2631
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2632
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2633
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2634
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2635
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2636
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2620
+ isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2621
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
2622
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
2623
+ ] }) : /* @__PURE__ */ jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
2624
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
2625
+ /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
2626
+ /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2627
+ /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
2628
+ /* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2629
+ /* @__PURE__ */ jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
2630
+ /* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2631
+ /* @__PURE__ */ jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
2632
+ /* @__PURE__ */ jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
2633
+ /* @__PURE__ */ jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2634
+ /* @__PURE__ */ jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2637
2635
  ] }) }),
2638
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxs(
2636
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxs(
2639
2637
  "tr",
2640
2638
  {
2641
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2642
- onClick: () => navigate(`/payments/${t.payment_session_id}`),
2639
+ className: "cursor-pointer hover:bg-ui-bg-subtle/60",
2640
+ onClick: () => navigate(`/refunds/${r.refund_id}`),
2643
2641
  children: [
2644
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2645
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2646
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2647
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsx(
2642
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
2643
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
2644
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
2645
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
2646
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
2647
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
2648
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsx(
2648
2649
  Badge,
2649
2650
  {
2650
2651
  size: "2xsmall",
2651
- className: `uppercase ${getStatusBadgeClass$6(displayStatus(t))}`,
2652
- children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2652
+ className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
2653
+ children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
2653
2654
  }
2654
2655
  ) }),
2655
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2656
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2657
- year: "numeric",
2656
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
2657
+ /* @__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", {
2658
2658
  month: "short",
2659
2659
  day: "numeric",
2660
2660
  hour: "numeric",
2661
2661
  minute: "2-digit",
2662
2662
  hour12: true
2663
2663
  }) }),
2664
- /* @__PURE__ */ jsxs("td", { className: "px-4 py-4", children: [
2664
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
2665
2665
  /* @__PURE__ */ jsx(
2666
2666
  Button,
2667
2667
  {
@@ -2669,27 +2669,27 @@ const PaymentsPage = () => {
2669
2669
  size: "small",
2670
2670
  onClick: (e) => {
2671
2671
  e.stopPropagation();
2672
- navigate(`/payments/${t.payment_session_id}`);
2672
+ navigate(`/refunds/${r.refund_id}`);
2673
2673
  },
2674
- children: "View details"
2674
+ children: "Details"
2675
2675
  }
2676
2676
  ),
2677
- t.order_id ? /* @__PURE__ */ jsx(
2677
+ r.order_id ? /* @__PURE__ */ jsx(
2678
2678
  Button,
2679
2679
  {
2680
2680
  variant: "transparent",
2681
2681
  size: "small",
2682
2682
  onClick: (e) => {
2683
2683
  e.stopPropagation();
2684
- navigate(`/orders/${t.order_id}`);
2684
+ navigate(`/orders/${r.order_id}`);
2685
2685
  },
2686
2686
  children: "Order"
2687
2687
  }
2688
2688
  ) : null
2689
- ] })
2689
+ ] }) })
2690
2690
  ]
2691
2691
  },
2692
- t.payment_session_id
2692
+ r.refund_id
2693
2693
  )) })
2694
2694
  ] }) }),
2695
2695
  hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
@@ -2697,15 +2697,15 @@ const PaymentsPage = () => {
2697
2697
  {
2698
2698
  variant: "secondary",
2699
2699
  isLoading: isFetchingMore,
2700
- onClick: () => loadTransactions(offset, false),
2700
+ onClick: () => loadRefunds(offset, false),
2701
2701
  children: "Load more"
2702
2702
  }
2703
2703
  ) }) : null
2704
2704
  ] }) });
2705
2705
  };
2706
2706
  const config$7 = defineRouteConfig({
2707
- label: "Payments",
2708
- icon: CreditCard
2707
+ label: "Refunds",
2708
+ icon: Receipt
2709
2709
  });
2710
2710
  const useDebounce$1 = (value, delay) => {
2711
2711
  const [debouncedValue, setDebouncedValue] = useState(value);
@@ -3912,205 +3912,14 @@ const DetailError = ({
3912
3912
  /* @__PURE__ */ jsx(ExclamationCircle, { className: clx(notFound ? "text-ui-fg-muted" : "text-ui-fg-error") }),
3913
3913
  /* @__PURE__ */ jsx(Heading, { level: "h3", children: notFound ? "Audit entry not found" : "Unable to load this deleted record" }),
3914
3914
  /* @__PURE__ */ jsx(Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: notFound ? "This audit entry doesn’t exist. The link may be incorrect." : "We couldn’t retrieve the audit entry right now. Check your connection and try again." }),
3915
- !notFound ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
3916
- /* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-2", children: [
3917
- /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
3918
- !notFound ? /* @__PURE__ */ jsx(Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
3919
- ] })
3920
- ] });
3921
- const config$4 = defineRouteConfig({});
3922
- const getStatusBadgeClass$3 = (status) => {
3923
- const s2 = status.toLowerCase();
3924
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
3925
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
3926
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
3927
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
3928
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
3929
- };
3930
- const formatAmount = (value) => {
3931
- return String(value);
3932
- };
3933
- const RefundDetailPage = () => {
3934
- const navigate = useNavigate();
3935
- const params = useParams();
3936
- const id = params?.id?.trim();
3937
- const [detail, setDetail] = useState(null);
3938
- const [loading, setLoading] = useState(!!id);
3939
- const [error, setError] = useState(null);
3940
- const [gatewayExpanded, setGatewayExpanded] = useState(false);
3941
- useEffect(() => {
3942
- if (!id) {
3943
- setLoading(false);
3944
- return;
3945
- }
3946
- let cancelled = false;
3947
- setLoading(true);
3948
- setError(null);
3949
- fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
3950
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
3951
- return res.json();
3952
- }).then((data) => {
3953
- if (!cancelled) setDetail(data);
3954
- }).catch((e) => {
3955
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
3956
- }).finally(() => {
3957
- if (!cancelled) setLoading(false);
3958
- });
3959
- return () => {
3960
- cancelled = true;
3961
- };
3962
- }, [id]);
3963
- const paymentStatus = detail?.payment?.status ?? "—";
3964
- const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
3965
- 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: [
3966
- /* @__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: [
3967
- /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
3968
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
3969
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
3970
- ] }) }),
3971
- error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
3972
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
3973
- /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
3974
- ] }) : 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: [
3975
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
3976
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
3977
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
3978
- /* @__PURE__ */ jsxs("div", { children: [
3979
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
3980
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
3981
- ] }),
3982
- /* @__PURE__ */ jsxs("div", { children: [
3983
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
3984
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
3985
- ] }),
3986
- /* @__PURE__ */ jsxs("div", { children: [
3987
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
3988
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
3989
- ] }),
3990
- /* @__PURE__ */ jsxs("div", { children: [
3991
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
3992
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
3993
- year: "numeric",
3994
- month: "short",
3995
- day: "numeric",
3996
- hour: "numeric",
3997
- minute: "2-digit",
3998
- hour12: true
3999
- }) })
4000
- ] }),
4001
- detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
4002
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
4003
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
4004
- ] }) : null
4005
- ] })
4006
- ] }),
4007
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4008
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
4009
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4010
- /* @__PURE__ */ jsxs("div", { children: [
4011
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
4012
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
4013
- ] }),
4014
- /* @__PURE__ */ jsxs("div", { children: [
4015
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
4016
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
4017
- ] }),
4018
- /* @__PURE__ */ jsxs("div", { children: [
4019
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
4020
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
4021
- ] }),
4022
- /* @__PURE__ */ jsxs("div", { children: [
4023
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
4024
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
4025
- ] }),
4026
- /* @__PURE__ */ jsxs("div", { children: [
4027
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
4028
- /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4029
- Badge,
4030
- {
4031
- size: "2xsmall",
4032
- className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
4033
- children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
4034
- }
4035
- ) })
4036
- ] }),
4037
- detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
4038
- /* @__PURE__ */ jsxs("div", { children: [
4039
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
4040
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
4041
- ] }),
4042
- /* @__PURE__ */ jsxs("div", { children: [
4043
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
4044
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
4045
- ] }),
4046
- /* @__PURE__ */ jsxs("div", { children: [
4047
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
4048
- /* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
4049
- detail.computed.refund_percentage.toFixed(1),
4050
- "%"
4051
- ] })
4052
- ] })
4053
- ] }) : null
4054
- ] })
4055
- ] }),
4056
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4057
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
4058
- detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4059
- /* @__PURE__ */ jsxs("div", { children: [
4060
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
4061
- /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4062
- Button,
4063
- {
4064
- variant: "transparent",
4065
- size: "small",
4066
- onClick: () => navigate(`/orders/${detail.order.order_id}`),
4067
- children: detail.order.order_number ?? detail.order.order_id
4068
- }
4069
- ) })
4070
- ] }),
4071
- detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
4072
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
4073
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
4074
- ] }) : null,
4075
- detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
4076
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
4077
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
4078
- ] }) : null,
4079
- detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
4080
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
4081
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
4082
- ] }) : null,
4083
- detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
4084
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
4085
- /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
4086
- ] }) : null
4087
- ] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
4088
- ] }),
4089
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4090
- /* @__PURE__ */ jsxs(
4091
- "button",
4092
- {
4093
- type: "button",
4094
- className: "flex w-full items-center justify-between text-left",
4095
- onClick: () => setGatewayExpanded((prev) => !prev),
4096
- "aria-expanded": gatewayExpanded,
4097
- "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
4098
- children: [
4099
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
4100
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
4101
- ]
4102
- }
4103
- ),
4104
- 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." }) })
4105
- ] })
4106
- ] }) : null
4107
- ] }) });
4108
- };
4109
- const config$3 = defineRouteConfig({
4110
- label: "Refund details",
4111
- icon: Receipt
4112
- });
4113
- const getStatusBadgeClass$2 = (status) => {
3915
+ !notFound ? /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
3916
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-2", children: [
3917
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
3918
+ !notFound ? /* @__PURE__ */ jsx(Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
3919
+ ] })
3920
+ ] });
3921
+ const config$4 = defineRouteConfig({});
3922
+ const getStatusBadgeClass$3 = (status) => {
4114
3923
  const s2 = status.toLowerCase();
4115
3924
  if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4116
3925
  if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
@@ -4188,7 +3997,7 @@ const PaymentDetailPage = () => {
4188
3997
  Badge,
4189
3998
  {
4190
3999
  size: "2xsmall",
4191
- className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
4000
+ className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
4192
4001
  children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
4193
4002
  }
4194
4003
  ) })
@@ -4224,11 +4033,11 @@ const PaymentDetailPage = () => {
4224
4033
  ] }) : null
4225
4034
  ] }) });
4226
4035
  };
4227
- const config$2 = defineRouteConfig({
4036
+ const config$3 = defineRouteConfig({
4228
4037
  label: "Payment details",
4229
4038
  icon: CreditCard
4230
4039
  });
4231
- const getStatusBadgeClass$1 = (status) => {
4040
+ const getStatusBadgeClass$2 = (status) => {
4232
4041
  const statusLower = status.toLowerCase();
4233
4042
  if (statusLower === "requested") {
4234
4043
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -4361,7 +4170,7 @@ const ReturnDetailPage = () => {
4361
4170
  Badge,
4362
4171
  {
4363
4172
  size: "small",
4364
- className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
4173
+ className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
4365
4174
  children: returnOrder.status.replace(/_/g, " ")
4366
4175
  }
4367
4176
  )
@@ -4444,7 +4253,7 @@ const ReturnDetailPage = () => {
4444
4253
  Badge,
4445
4254
  {
4446
4255
  size: "2xsmall",
4447
- className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
4256
+ className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
4448
4257
  children: entry.status.replace(/_/g, " ")
4449
4258
  }
4450
4259
  ) }),
@@ -4506,11 +4315,11 @@ const ReturnDetailPage = () => {
4506
4315
  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" }) })
4507
4316
  ] }) });
4508
4317
  };
4509
- const config$1 = defineRouteConfig({
4318
+ const config$2 = defineRouteConfig({
4510
4319
  label: "Return Order Details",
4511
4320
  icon: CheckCircle
4512
4321
  });
4513
- const getStatusBadgeClass = (status) => {
4322
+ const getStatusBadgeClass$1 = (status) => {
4514
4323
  const statusLower = status.toLowerCase();
4515
4324
  if (statusLower === "requested") {
4516
4325
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
@@ -4647,7 +4456,7 @@ const SwapDetailPage = () => {
4647
4456
  Badge,
4648
4457
  {
4649
4458
  size: "small",
4650
- className: `uppercase ${getStatusBadgeClass(swap.status)}`,
4459
+ className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
4651
4460
  children: swap.status.replace(/_/g, " ")
4652
4461
  }
4653
4462
  )
@@ -4715,7 +4524,7 @@ const SwapDetailPage = () => {
4715
4524
  Badge,
4716
4525
  {
4717
4526
  size: "2xsmall",
4718
- className: `uppercase ${getStatusBadgeClass(entry.status)}`,
4527
+ className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
4719
4528
  children: entry.status.replace(/_/g, " ")
4720
4529
  }
4721
4530
  ) }),
@@ -4784,10 +4593,201 @@ const SwapDetailPage = () => {
4784
4593
  ] })
4785
4594
  ] }) });
4786
4595
  };
4787
- const config = defineRouteConfig({
4596
+ const config$1 = defineRouteConfig({
4788
4597
  label: "Swap Details",
4789
4598
  icon: ArrowPath
4790
4599
  });
4600
+ const getStatusBadgeClass = (status) => {
4601
+ const s2 = status.toLowerCase();
4602
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4603
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4604
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
4605
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4606
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4607
+ };
4608
+ const formatAmount = (value) => {
4609
+ return String(value);
4610
+ };
4611
+ const RefundDetailPage = () => {
4612
+ const navigate = useNavigate();
4613
+ const params = useParams();
4614
+ const id = params?.id?.trim();
4615
+ const [detail, setDetail] = useState(null);
4616
+ const [loading, setLoading] = useState(!!id);
4617
+ const [error, setError] = useState(null);
4618
+ const [gatewayExpanded, setGatewayExpanded] = useState(false);
4619
+ useEffect(() => {
4620
+ if (!id) {
4621
+ setLoading(false);
4622
+ return;
4623
+ }
4624
+ let cancelled = false;
4625
+ setLoading(true);
4626
+ setError(null);
4627
+ fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
4628
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
4629
+ return res.json();
4630
+ }).then((data) => {
4631
+ if (!cancelled) setDetail(data);
4632
+ }).catch((e) => {
4633
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
4634
+ }).finally(() => {
4635
+ if (!cancelled) setLoading(false);
4636
+ });
4637
+ return () => {
4638
+ cancelled = true;
4639
+ };
4640
+ }, [id]);
4641
+ const paymentStatus = detail?.payment?.status ?? "—";
4642
+ const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
4643
+ 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: [
4644
+ /* @__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: [
4645
+ /* @__PURE__ */ jsx(Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
4646
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Refund details" }),
4647
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
4648
+ ] }) }),
4649
+ error ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
4650
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
4651
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
4652
+ ] }) : 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: [
4653
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4654
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
4655
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4656
+ /* @__PURE__ */ jsxs("div", { children: [
4657
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
4658
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
4659
+ ] }),
4660
+ /* @__PURE__ */ jsxs("div", { children: [
4661
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
4662
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
4663
+ ] }),
4664
+ /* @__PURE__ */ jsxs("div", { children: [
4665
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
4666
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
4667
+ ] }),
4668
+ /* @__PURE__ */ jsxs("div", { children: [
4669
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
4670
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
4671
+ year: "numeric",
4672
+ month: "short",
4673
+ day: "numeric",
4674
+ hour: "numeric",
4675
+ minute: "2-digit",
4676
+ hour12: true
4677
+ }) })
4678
+ ] }),
4679
+ detail.refund.created_by ? /* @__PURE__ */ jsxs("div", { children: [
4680
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
4681
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
4682
+ ] }) : null
4683
+ ] })
4684
+ ] }),
4685
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4686
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
4687
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4688
+ /* @__PURE__ */ jsxs("div", { children: [
4689
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
4690
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
4691
+ ] }),
4692
+ /* @__PURE__ */ jsxs("div", { children: [
4693
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
4694
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
4695
+ ] }),
4696
+ /* @__PURE__ */ jsxs("div", { children: [
4697
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
4698
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
4699
+ ] }),
4700
+ /* @__PURE__ */ jsxs("div", { children: [
4701
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
4702
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
4703
+ ] }),
4704
+ /* @__PURE__ */ jsxs("div", { children: [
4705
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
4706
+ /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4707
+ Badge,
4708
+ {
4709
+ size: "2xsmall",
4710
+ className: `uppercase ${getStatusBadgeClass(paymentStatus)}`,
4711
+ children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
4712
+ }
4713
+ ) })
4714
+ ] }),
4715
+ detail.computed ? /* @__PURE__ */ jsxs(Fragment, { children: [
4716
+ /* @__PURE__ */ jsxs("div", { children: [
4717
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
4718
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
4719
+ ] }),
4720
+ /* @__PURE__ */ jsxs("div", { children: [
4721
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
4722
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
4723
+ ] }),
4724
+ /* @__PURE__ */ jsxs("div", { children: [
4725
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
4726
+ /* @__PURE__ */ jsxs(Text, { className: "mt-1 block", children: [
4727
+ detail.computed.refund_percentage.toFixed(1),
4728
+ "%"
4729
+ ] })
4730
+ ] })
4731
+ ] }) : null
4732
+ ] })
4733
+ ] }),
4734
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4735
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
4736
+ detail.order ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4737
+ /* @__PURE__ */ jsxs("div", { children: [
4738
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
4739
+ /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
4740
+ Button,
4741
+ {
4742
+ variant: "transparent",
4743
+ size: "small",
4744
+ onClick: () => navigate(`/orders/${detail.order.order_id}`),
4745
+ children: detail.order.order_number ?? detail.order.order_id
4746
+ }
4747
+ ) })
4748
+ ] }),
4749
+ detail.order.total != null ? /* @__PURE__ */ jsxs("div", { children: [
4750
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
4751
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
4752
+ ] }) : null,
4753
+ detail.order.customer_id ? /* @__PURE__ */ jsxs("div", { children: [
4754
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
4755
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
4756
+ ] }) : null,
4757
+ detail.order.region ? /* @__PURE__ */ jsxs("div", { children: [
4758
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
4759
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.region })
4760
+ ] }) : null,
4761
+ detail.order.fulfillment_status ? /* @__PURE__ */ jsxs("div", { children: [
4762
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
4763
+ /* @__PURE__ */ jsx(Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
4764
+ ] }) : null
4765
+ ] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
4766
+ ] }),
4767
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4768
+ /* @__PURE__ */ jsxs(
4769
+ "button",
4770
+ {
4771
+ type: "button",
4772
+ className: "flex w-full items-center justify-between text-left",
4773
+ onClick: () => setGatewayExpanded((prev) => !prev),
4774
+ "aria-expanded": gatewayExpanded,
4775
+ "aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
4776
+ children: [
4777
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
4778
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
4779
+ ]
4780
+ }
4781
+ ),
4782
+ 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." }) })
4783
+ ] })
4784
+ ] }) : null
4785
+ ] }) });
4786
+ };
4787
+ const config = defineRouteConfig({
4788
+ label: "Refund details",
4789
+ icon: Receipt
4790
+ });
4791
4791
  const i18nTranslations0 = {};
4792
4792
  const widgetModule = { widgets: [
4793
4793
  {
@@ -4809,13 +4809,13 @@ const routeModule = {
4809
4809
  handle: { label: config$9.label, translationNs: config$9.translationNs }
4810
4810
  },
4811
4811
  {
4812
- Component: RefundsPage,
4813
- path: "/refunds",
4812
+ Component: PaymentsPage,
4813
+ path: "/payments",
4814
4814
  handle: { label: config$8.label, translationNs: config$8.translationNs }
4815
4815
  },
4816
4816
  {
4817
- Component: PaymentsPage,
4818
- path: "/payments",
4817
+ Component: RefundsPage,
4818
+ path: "/refunds",
4819
4819
  handle: { label: config$7.label, translationNs: config$7.translationNs }
4820
4820
  },
4821
4821
  {
@@ -4833,24 +4833,24 @@ const routeModule = {
4833
4833
  path: "/deleted-records-audit/:id",
4834
4834
  handle: { label: config$4.label, translationNs: config$4.translationNs }
4835
4835
  },
4836
- {
4837
- Component: RefundDetailPage,
4838
- path: "/refunds/:id",
4839
- handle: { label: config$3.label, translationNs: config$3.translationNs }
4840
- },
4841
4836
  {
4842
4837
  Component: PaymentDetailPage,
4843
4838
  path: "/payments/:id",
4844
- handle: { label: config$2.label, translationNs: config$2.translationNs }
4839
+ handle: { label: config$3.label, translationNs: config$3.translationNs }
4845
4840
  },
4846
4841
  {
4847
4842
  Component: ReturnDetailPage,
4848
4843
  path: "/returns/:id",
4849
- handle: { label: config$1.label, translationNs: config$1.translationNs }
4844
+ handle: { label: config$2.label, translationNs: config$2.translationNs }
4850
4845
  },
4851
4846
  {
4852
4847
  Component: SwapDetailPage,
4853
4848
  path: "/swaps/:id",
4849
+ handle: { label: config$1.label, translationNs: config$1.translationNs }
4850
+ },
4851
+ {
4852
+ Component: RefundDetailPage,
4853
+ path: "/refunds/:id",
4854
4854
  handle: { label: config.label, translationNs: config.translationNs }
4855
4855
  }
4856
4856
  ]
@@ -4866,16 +4866,16 @@ const menuItemModule = {
4866
4866
  translationNs: void 0
4867
4867
  },
4868
4868
  {
4869
- label: config$7.label,
4870
- icon: config$7.icon,
4869
+ label: config$8.label,
4870
+ icon: config$8.icon,
4871
4871
  path: "/payments",
4872
4872
  nested: void 0,
4873
4873
  rank: void 0,
4874
4874
  translationNs: void 0
4875
4875
  },
4876
4876
  {
4877
- label: config$8.label,
4878
- icon: config$8.icon,
4877
+ label: config$7.label,
4878
+ icon: config$7.icon,
4879
4879
  path: "/refunds",
4880
4880
  nested: void 0,
4881
4881
  rank: void 0,
@@ -4898,32 +4898,32 @@ const menuItemModule = {
4898
4898
  translationNs: void 0
4899
4899
  },
4900
4900
  {
4901
- label: config$2.label,
4902
- icon: config$2.icon,
4901
+ label: config$3.label,
4902
+ icon: config$3.icon,
4903
4903
  path: "/payments/:id",
4904
4904
  nested: void 0,
4905
4905
  rank: void 0,
4906
4906
  translationNs: void 0
4907
4907
  },
4908
4908
  {
4909
- label: config$3.label,
4910
- icon: config$3.icon,
4909
+ label: config.label,
4910
+ icon: config.icon,
4911
4911
  path: "/refunds/:id",
4912
4912
  nested: void 0,
4913
4913
  rank: void 0,
4914
4914
  translationNs: void 0
4915
4915
  },
4916
4916
  {
4917
- label: config$1.label,
4918
- icon: config$1.icon,
4917
+ label: config$2.label,
4918
+ icon: config$2.icon,
4919
4919
  path: "/returns/:id",
4920
4920
  nested: void 0,
4921
4921
  rank: void 0,
4922
4922
  translationNs: void 0
4923
4923
  },
4924
4924
  {
4925
- label: config.label,
4926
- icon: config.icon,
4925
+ label: config$1.label,
4926
+ icon: config$1.icon,
4927
4927
  path: "/swaps/:id",
4928
4928
  nested: void 0,
4929
4929
  rank: void 0,