order-management 0.0.27 → 0.0.28

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.
@@ -18,21 +18,21 @@ const getStatusBadgeClass$3 = (status) => {
18
18
  if (statusLower === "requested") {
19
19
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
20
20
  }
21
- if (statusLower === "received") {
21
+ if (statusLower === "approved") {
22
22
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
23
23
  }
24
- if (statusLower === "requires_action") {
24
+ if (statusLower === "rejected") {
25
25
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
26
26
  }
27
27
  if (statusLower === "completed") {
28
28
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
29
29
  }
30
- if (statusLower === "canceled") {
30
+ if (statusLower === "cancelled") {
31
31
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
32
32
  }
33
33
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
34
34
  };
35
- const ReturnsPage = () => {
35
+ const SwapsPage = () => {
36
36
  const navigate = reactRouterDom.useNavigate();
37
37
  const [items, setItems] = react.useState([]);
38
38
  const [statusFilter, setStatusFilter] = react.useState("all");
@@ -44,7 +44,7 @@ const ReturnsPage = () => {
44
44
  const [offset, setOffset] = react.useState(0);
45
45
  const [count, setCount] = react.useState(0);
46
46
  const limit = 50;
47
- const loadReturns = react.useCallback(
47
+ const loadSwaps = react.useCallback(
48
48
  async (nextOffset, replace = false) => {
49
49
  var _a;
50
50
  try {
@@ -61,25 +61,24 @@ const ReturnsPage = () => {
61
61
  params.set("status", statusFilter);
62
62
  }
63
63
  if (debouncedSearchQuery.trim()) {
64
- params.set("q", debouncedSearchQuery.trim());
64
+ params.set("order_id", debouncedSearchQuery.trim());
65
65
  }
66
- params.set("order", "created_at");
67
66
  const response = await fetch(
68
- `/admin/returns?${params.toString()}`,
67
+ `/admin/swaps?${params.toString()}`,
69
68
  { credentials: "include" }
70
69
  );
71
70
  if (!response.ok) {
72
71
  const message = await response.text();
73
- throw new Error(message || "Unable to load return orders");
72
+ throw new Error(message || "Unable to load swaps");
74
73
  }
75
74
  const payload = await response.json();
76
75
  setCount(payload.count ?? 0);
77
- setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
76
+ setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
78
77
  setItems(
79
- (prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
78
+ (prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
80
79
  );
81
80
  } catch (loadError) {
82
- const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
81
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
83
82
  setError(message);
84
83
  } finally {
85
84
  setIsLoading(false);
@@ -89,8 +88,8 @@ const ReturnsPage = () => {
89
88
  [statusFilter, debouncedSearchQuery]
90
89
  );
91
90
  react.useEffect(() => {
92
- void loadReturns(0, true);
93
- }, [statusFilter, debouncedSearchQuery, loadReturns]);
91
+ void loadSwaps(0, true);
92
+ }, [statusFilter, debouncedSearchQuery, loadSwaps]);
94
93
  const hasMore = react.useMemo(() => offset < count, [offset, count]);
95
94
  const availableStatuses = react.useMemo(() => {
96
95
  const statuses = /* @__PURE__ */ new Set();
@@ -100,16 +99,16 @@ const ReturnsPage = () => {
100
99
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
101
100
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
102
101
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
103
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
104
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
102
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swaps" }),
103
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer swap requests" })
105
104
  ] }),
106
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
105
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
107
106
  ] }),
108
107
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
109
108
  /* @__PURE__ */ jsxRuntime.jsx(
110
109
  ui.Input,
111
110
  {
112
- placeholder: "Search by return ID, order ID, or customer email",
111
+ placeholder: "Search by swap ID or order ID",
113
112
  value: searchQuery,
114
113
  onChange: (event) => setSearchQuery(event.target.value),
115
114
  className: "md:max-w-sm"
@@ -134,51 +133,50 @@ const ReturnsPage = () => {
134
133
  ui.Button,
135
134
  {
136
135
  variant: "secondary",
137
- onClick: () => loadReturns(0, true),
136
+ onClick: () => loadSwaps(0, true),
138
137
  children: "Try again"
139
138
  }
140
139
  ) })
141
140
  ] }) : null,
142
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
143
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
144
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
141
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
142
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No swaps yet" }),
143
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Swap requests created by customers will appear here." })
145
144
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
146
145
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
147
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
146
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Swap ID" }),
148
147
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
149
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
150
148
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
151
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
149
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
152
150
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
153
151
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
154
152
  ] }) }),
155
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
153
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
156
154
  "tr",
157
155
  {
158
156
  className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
159
- onClick: () => navigate(`/returns/${returnOrder.id}`),
157
+ onClick: () => navigate(`/swaps/${swap.id}`),
160
158
  children: [
161
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
162
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
163
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
159
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: swap.id }) }) }),
160
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
164
161
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
165
162
  ui.Badge,
166
163
  {
167
164
  size: "2xsmall",
168
- className: `uppercase ${getStatusBadgeClass$3(returnOrder.status)}`,
169
- children: returnOrder.status.replace(/_/g, " ")
165
+ className: `uppercase ${getStatusBadgeClass$3(swap.status)}`,
166
+ children: swap.status.replace(/_/g, " ")
170
167
  }
171
168
  ) }),
172
169
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
173
- const amount = returnOrder.refund_amount;
170
+ const amount = swap.difference_due;
174
171
  if (amount == null || amount === void 0) {
175
172
  return "—";
176
173
  }
177
174
  const displayAmount = Number(amount) / 100;
178
- const currency = returnOrder.currency_code || "$";
179
- return `${currency}${displayAmount.toFixed(2)}`;
175
+ const currency = swap.currency_code || "$";
176
+ const sign = displayAmount >= 0 ? "+" : "";
177
+ return `${sign}${currency}${displayAmount.toFixed(2)}`;
180
178
  })() }),
181
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
179
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
182
180
  year: "numeric",
183
181
  month: "short",
184
182
  day: "numeric",
@@ -193,14 +191,14 @@ const ReturnsPage = () => {
193
191
  size: "small",
194
192
  onClick: (e) => {
195
193
  e.stopPropagation();
196
- navigate(`/returns/${returnOrder.id}`);
194
+ navigate(`/swaps/${swap.id}`);
197
195
  },
198
196
  children: "View"
199
197
  }
200
198
  ) })
201
199
  ]
202
200
  },
203
- returnOrder.id
201
+ swap.id
204
202
  )) })
205
203
  ] }) }),
206
204
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -208,14 +206,14 @@ const ReturnsPage = () => {
208
206
  {
209
207
  variant: "secondary",
210
208
  isLoading: isFetchingMore,
211
- onClick: () => loadReturns(offset, false),
209
+ onClick: () => loadSwaps(offset, false),
212
210
  children: "Load more"
213
211
  }
214
212
  ) }) : null
215
213
  ] }) });
216
214
  };
217
215
  const config$3 = adminSdk.defineRouteConfig({
218
- label: "Return Orders",
216
+ label: "Swaps",
219
217
  icon: icons.ArrowPath
220
218
  });
221
219
  const useDebounce = (value, delay) => {
@@ -231,21 +229,21 @@ const getStatusBadgeClass$2 = (status) => {
231
229
  if (statusLower === "requested") {
232
230
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
233
231
  }
234
- if (statusLower === "approved") {
232
+ if (statusLower === "received") {
235
233
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
236
234
  }
237
- if (statusLower === "rejected") {
235
+ if (statusLower === "requires_action") {
238
236
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
239
237
  }
240
238
  if (statusLower === "completed") {
241
239
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
242
240
  }
243
- if (statusLower === "cancelled") {
241
+ if (statusLower === "canceled") {
244
242
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
245
243
  }
246
244
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
247
245
  };
248
- const SwapsPage = () => {
246
+ const ReturnsPage = () => {
249
247
  const navigate = reactRouterDom.useNavigate();
250
248
  const [items, setItems] = react.useState([]);
251
249
  const [statusFilter, setStatusFilter] = react.useState("all");
@@ -257,7 +255,7 @@ const SwapsPage = () => {
257
255
  const [offset, setOffset] = react.useState(0);
258
256
  const [count, setCount] = react.useState(0);
259
257
  const limit = 50;
260
- const loadSwaps = react.useCallback(
258
+ const loadReturns = react.useCallback(
261
259
  async (nextOffset, replace = false) => {
262
260
  var _a;
263
261
  try {
@@ -274,24 +272,25 @@ const SwapsPage = () => {
274
272
  params.set("status", statusFilter);
275
273
  }
276
274
  if (debouncedSearchQuery.trim()) {
277
- params.set("order_id", debouncedSearchQuery.trim());
275
+ params.set("q", debouncedSearchQuery.trim());
278
276
  }
277
+ params.set("order", "created_at");
279
278
  const response = await fetch(
280
- `/admin/swaps?${params.toString()}`,
279
+ `/admin/returns?${params.toString()}`,
281
280
  { credentials: "include" }
282
281
  );
283
282
  if (!response.ok) {
284
283
  const message = await response.text();
285
- throw new Error(message || "Unable to load swaps");
284
+ throw new Error(message || "Unable to load return orders");
286
285
  }
287
286
  const payload = await response.json();
288
287
  setCount(payload.count ?? 0);
289
- setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
288
+ setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
290
289
  setItems(
291
- (prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
290
+ (prev) => replace ? payload.returns ?? [] : [...prev, ...payload.returns ?? []]
292
291
  );
293
292
  } catch (loadError) {
294
- const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
293
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return orders";
295
294
  setError(message);
296
295
  } finally {
297
296
  setIsLoading(false);
@@ -301,8 +300,8 @@ const SwapsPage = () => {
301
300
  [statusFilter, debouncedSearchQuery]
302
301
  );
303
302
  react.useEffect(() => {
304
- void loadSwaps(0, true);
305
- }, [statusFilter, debouncedSearchQuery, loadSwaps]);
303
+ void loadReturns(0, true);
304
+ }, [statusFilter, debouncedSearchQuery, loadReturns]);
306
305
  const hasMore = react.useMemo(() => offset < count, [offset, count]);
307
306
  const availableStatuses = react.useMemo(() => {
308
307
  const statuses = /* @__PURE__ */ new Set();
@@ -312,16 +311,16 @@ const SwapsPage = () => {
312
311
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
313
312
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
314
313
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
315
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swaps" }),
316
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer swap requests" })
314
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Orders" }),
315
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer return orders" })
317
316
  ] }),
318
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
317
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadReturns(0, true), children: "Refresh" })
319
318
  ] }),
320
319
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
321
320
  /* @__PURE__ */ jsxRuntime.jsx(
322
321
  ui.Input,
323
322
  {
324
- placeholder: "Search by swap ID or order ID",
323
+ placeholder: "Search by return ID, order ID, or customer email",
325
324
  value: searchQuery,
326
325
  onChange: (event) => setSearchQuery(event.target.value),
327
326
  className: "md:max-w-sm"
@@ -346,50 +345,51 @@ const SwapsPage = () => {
346
345
  ui.Button,
347
346
  {
348
347
  variant: "secondary",
349
- onClick: () => loadSwaps(0, true),
348
+ onClick: () => loadReturns(0, true),
350
349
  children: "Try again"
351
350
  }
352
351
  ) })
353
352
  ] }) : null,
354
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
355
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No swaps yet" }),
356
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Swap requests created by customers will appear here." })
353
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return orders..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
354
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No return orders yet" }),
355
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Return orders created by customers will appear here." })
357
356
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
358
357
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
359
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Swap ID" }),
358
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Return ID" }),
360
359
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
360
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Customer" }),
361
361
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
362
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
362
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund Amount" }),
363
363
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
364
364
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
365
365
  ] }) }),
366
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
366
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((returnOrder) => /* @__PURE__ */ jsxRuntime.jsxs(
367
367
  "tr",
368
368
  {
369
369
  className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
370
- onClick: () => navigate(`/swaps/${swap.id}`),
370
+ onClick: () => navigate(`/returns/${returnOrder.id}`),
371
371
  children: [
372
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: swap.id }) }) }),
373
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
372
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: returnOrder.id }) }) }),
373
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
374
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
374
375
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
375
376
  ui.Badge,
376
377
  {
377
378
  size: "2xsmall",
378
- className: `uppercase ${getStatusBadgeClass$2(swap.status)}`,
379
- children: swap.status.replace(/_/g, " ")
379
+ className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
380
+ children: returnOrder.status.replace(/_/g, " ")
380
381
  }
381
382
  ) }),
382
383
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
383
- const amount = swap.difference_due;
384
+ const amount = returnOrder.refund_amount;
384
385
  if (amount == null || amount === void 0) {
385
386
  return "—";
386
387
  }
387
388
  const displayAmount = Number(amount) / 100;
388
- const currency = swap.currency_code || "$";
389
- const sign = displayAmount >= 0 ? "+" : "";
390
- return `${sign}${currency}${displayAmount.toFixed(2)}`;
389
+ const currency = returnOrder.currency_code || "$";
390
+ return `${currency}${displayAmount.toFixed(2)}`;
391
391
  })() }),
392
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
392
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(returnOrder.created_at).toLocaleDateString("en-US", {
393
393
  year: "numeric",
394
394
  month: "short",
395
395
  day: "numeric",
@@ -404,14 +404,14 @@ const SwapsPage = () => {
404
404
  size: "small",
405
405
  onClick: (e) => {
406
406
  e.stopPropagation();
407
- navigate(`/swaps/${swap.id}`);
407
+ navigate(`/returns/${returnOrder.id}`);
408
408
  },
409
409
  children: "View"
410
410
  }
411
411
  ) })
412
412
  ]
413
413
  },
414
- swap.id
414
+ returnOrder.id
415
415
  )) })
416
416
  ] }) }),
417
417
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -419,14 +419,14 @@ const SwapsPage = () => {
419
419
  {
420
420
  variant: "secondary",
421
421
  isLoading: isFetchingMore,
422
- onClick: () => loadSwaps(offset, false),
422
+ onClick: () => loadReturns(offset, false),
423
423
  children: "Load more"
424
424
  }
425
425
  ) }) : null
426
426
  ] }) });
427
427
  };
428
428
  const config$2 = adminSdk.defineRouteConfig({
429
- label: "Swaps",
429
+ label: "Return Orders",
430
430
  icon: icons.ArrowPath
431
431
  });
432
432
  const getStatusBadgeClass$1 = (status) => {
@@ -434,65 +434,63 @@ const getStatusBadgeClass$1 = (status) => {
434
434
  if (statusLower === "requested") {
435
435
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
436
436
  }
437
- if (statusLower === "received") {
437
+ if (statusLower === "approved") {
438
438
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
439
439
  }
440
- if (statusLower === "requires_action") {
440
+ if (statusLower === "rejected") {
441
441
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
442
442
  }
443
443
  if (statusLower === "completed") {
444
444
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
445
445
  }
446
- if (statusLower === "canceled") {
446
+ if (statusLower === "cancelled") {
447
447
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
448
448
  }
449
449
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
450
450
  };
451
- const ReturnDetailPage = () => {
452
- var _a, _b, _c;
451
+ const SwapDetailPage = () => {
452
+ var _a, _b;
453
453
  const navigate = reactRouterDom.useNavigate();
454
454
  const { id } = reactRouterDom.useParams();
455
- const [returnOrder, setReturnOrder] = react.useState(null);
455
+ const [swap, setSwap] = react.useState(null);
456
+ const [order, setOrder] = react.useState(null);
456
457
  const [selectedStatus, setSelectedStatus] = react.useState("");
457
458
  const [isLoading, setIsLoading] = react.useState(true);
458
459
  const [isUpdating, setIsUpdating] = react.useState(false);
460
+ const [isApproving, setIsApproving] = react.useState(false);
461
+ const [isRejecting, setIsRejecting] = react.useState(false);
459
462
  const [error, setError] = react.useState(null);
460
463
  const [updateError, setUpdateError] = react.useState(null);
461
464
  const [updateSuccess, setUpdateSuccess] = react.useState(false);
462
- const availableStatuses = [
463
- "requested",
464
- "received",
465
- "requires_action",
466
- "completed",
467
- "canceled"
468
- ];
465
+ const availableStatuses = ["requested", "approved", "rejected"];
469
466
  react.useEffect(() => {
470
467
  if (!id) {
471
- navigate("/returns");
468
+ navigate("/swaps");
472
469
  return;
473
470
  }
474
- const loadReturn = async () => {
471
+ const loadSwap = async () => {
475
472
  try {
476
473
  setIsLoading(true);
477
474
  setError(null);
478
- const response = await fetch(`/admin/returns/${id}`, {
475
+ const response = await fetch(`/admin/swaps/${id}`, {
479
476
  credentials: "include"
480
477
  });
481
478
  if (!response.ok) {
482
479
  const message = await response.text();
483
- throw new Error(message || "Unable to load return order");
480
+ throw new Error(message || "Unable to load swap");
484
481
  }
485
482
  const payload = await response.json();
486
- setReturnOrder(payload.return);
483
+ setSwap(payload.swap);
484
+ setOrder(payload.order || null);
487
485
  setSelectedStatus("");
488
486
  } catch (loadError) {
489
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
487
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
490
488
  setError(message);
491
489
  } finally {
492
490
  setIsLoading(false);
493
491
  }
494
492
  };
495
- void loadReturn();
493
+ void loadSwap();
496
494
  }, [id, navigate]);
497
495
  const handleStatusUpdate = async () => {
498
496
  if (!id || !selectedStatus) {
@@ -502,7 +500,7 @@ const ReturnDetailPage = () => {
502
500
  setIsUpdating(true);
503
501
  setUpdateError(null);
504
502
  setUpdateSuccess(false);
505
- const response = await fetch(`/admin/returns/${id}/status`, {
503
+ const response = await fetch(`/admin/swaps/${id}/status`, {
506
504
  method: "POST",
507
505
  headers: {
508
506
  "Content-Type": "application/json"
@@ -515,16 +513,17 @@ const ReturnDetailPage = () => {
515
513
  throw new Error(message || "Unable to update status");
516
514
  }
517
515
  const payload = await response.json();
518
- setReturnOrder(payload.return);
516
+ setSwap(payload.swap);
519
517
  setSelectedStatus("");
520
518
  setUpdateSuccess(true);
521
519
  setTimeout(() => setUpdateSuccess(false), 3e3);
522
- const detailResponse = await fetch(`/admin/returns/${id}`, {
520
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
523
521
  credentials: "include"
524
522
  });
525
523
  if (detailResponse.ok) {
526
524
  const detailPayload = await detailResponse.json();
527
- setReturnOrder(detailPayload.return);
525
+ setSwap(detailPayload.swap);
526
+ setOrder(detailPayload.order || null);
528
527
  }
529
528
  } catch (updateErr) {
530
529
  const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
@@ -533,16 +532,65 @@ const ReturnDetailPage = () => {
533
532
  setIsUpdating(false);
534
533
  }
535
534
  };
535
+ const handleApproveClick = async () => {
536
+ if (!id) {
537
+ return;
538
+ }
539
+ if (!swap || !swap.order_id) {
540
+ setUpdateError("Swap must have an order_id to create exchange");
541
+ return;
542
+ }
543
+ window.location.href = `/app/orders/${swap.order_id}/exchanges`;
544
+ };
545
+ const handleReject = async () => {
546
+ if (!id) {
547
+ return;
548
+ }
549
+ try {
550
+ setIsRejecting(true);
551
+ setUpdateError(null);
552
+ setUpdateSuccess(false);
553
+ const response = await fetch(`/admin/swaps/${id}/reject`, {
554
+ method: "POST",
555
+ headers: {
556
+ "Content-Type": "application/json"
557
+ },
558
+ credentials: "include",
559
+ body: JSON.stringify({ reason: "Rejected by admin" })
560
+ });
561
+ if (!response.ok) {
562
+ const message = await response.text();
563
+ throw new Error(message || "Unable to reject swap");
564
+ }
565
+ const payload = await response.json();
566
+ setSwap(payload.swap);
567
+ setUpdateSuccess(true);
568
+ setTimeout(() => setUpdateSuccess(false), 3e3);
569
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
570
+ credentials: "include"
571
+ });
572
+ if (detailResponse.ok) {
573
+ const detailPayload = await response.json();
574
+ setSwap(detailPayload.swap);
575
+ setOrder(detailPayload.order || null);
576
+ }
577
+ } catch (updateErr) {
578
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
579
+ setUpdateError(message);
580
+ } finally {
581
+ setIsRejecting(false);
582
+ }
583
+ };
536
584
  if (isLoading) {
537
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return order..." }) }) }) });
585
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
538
586
  }
539
- if (error || !returnOrder) {
587
+ if (error || !swap) {
540
588
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
541
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
542
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
589
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
590
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
543
591
  ] }) }) });
544
592
  }
545
- const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
593
+ const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
546
594
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
547
595
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
548
596
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -550,7 +598,7 @@ const ReturnDetailPage = () => {
550
598
  {
551
599
  variant: "transparent",
552
600
  size: "small",
553
- onClick: () => navigate("/returns"),
601
+ onClick: () => navigate("/swaps"),
554
602
  className: "w-fit",
555
603
  children: [
556
604
  /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
@@ -560,20 +608,42 @@ const ReturnDetailPage = () => {
560
608
  ),
561
609
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
562
610
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
563
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
564
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
611
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
612
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
565
613
  ] }),
566
614
  /* @__PURE__ */ jsxRuntime.jsx(
567
615
  ui.Badge,
568
616
  {
569
617
  size: "small",
570
- className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
571
- children: returnOrder.status.replace("_", " ")
618
+ className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
619
+ children: swap.status.replace(/_/g, " ")
572
620
  }
573
621
  )
574
622
  ] })
575
623
  ] }),
576
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
624
+ swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
625
+ /* @__PURE__ */ jsxRuntime.jsx(
626
+ ui.Button,
627
+ {
628
+ variant: "primary",
629
+ onClick: handleApproveClick,
630
+ disabled: isApproving || isRejecting,
631
+ isLoading: isApproving,
632
+ children: "Approve Swap"
633
+ }
634
+ ),
635
+ /* @__PURE__ */ jsxRuntime.jsx(
636
+ ui.Button,
637
+ {
638
+ variant: "secondary",
639
+ onClick: handleReject,
640
+ disabled: isApproving || isRejecting,
641
+ isLoading: isRejecting,
642
+ children: "Reject Swap"
643
+ }
644
+ )
645
+ ] }),
646
+ swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
577
647
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
578
648
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
579
649
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
@@ -586,7 +656,7 @@ const ReturnDetailPage = () => {
586
656
  className: "h-9 w-full 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",
587
657
  children: [
588
658
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
589
- availableStatuses.filter((status) => status !== returnOrder.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace("_", " ").toUpperCase() }, status))
659
+ availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
590
660
  ]
591
661
  }
592
662
  )
@@ -605,37 +675,60 @@ const ReturnDetailPage = () => {
605
675
  updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
606
676
  updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
607
677
  ] }),
678
+ swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
679
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
680
+ swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
681
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
682
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
683
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
684
+ ] }),
685
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
686
+ ui.Button,
687
+ {
688
+ variant: "secondary",
689
+ onClick: () => {
690
+ window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
691
+ },
692
+ children: "View Exchange"
693
+ }
694
+ ) })
695
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
696
+ ] }),
608
697
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
609
698
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
610
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
699
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
611
700
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
612
701
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
613
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
614
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
702
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
703
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
615
704
  ] }),
616
705
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
617
706
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
618
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
707
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
619
708
  ] }),
620
709
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
621
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund Amount" }),
622
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.refund_amount ? `${((_b = returnOrder.order) == null ? void 0 : _b.currency_code) || "$"}${Number(returnOrder.refund_amount).toFixed(2)}` : "—" })
710
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
711
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
623
712
  ] }),
624
- returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
713
+ swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
625
714
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
626
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
715
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
627
716
  ] }),
628
- returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
717
+ swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
629
718
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
630
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
719
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
631
720
  ] }),
632
721
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
633
722
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
634
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
723
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
635
724
  ] }),
636
725
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
637
726
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
638
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
727
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
728
+ ] }),
729
+ swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
730
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
731
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
639
732
  ] })
640
733
  ] })
641
734
  ] }),
@@ -646,23 +739,18 @@ const ReturnDetailPage = () => {
646
739
  {
647
740
  className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
648
741
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
649
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
650
- /* @__PURE__ */ jsxRuntime.jsx(
651
- ui.Badge,
652
- {
653
- size: "2xsmall",
654
- className: `uppercase ${getStatusBadgeClass$1(entry.to)}`,
655
- children: entry.to.replace("_", " ")
656
- }
657
- ),
658
- entry.from && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
659
- "from ",
660
- entry.from.replace("_", " ")
661
- ] })
662
- ] }),
742
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
743
+ ui.Badge,
744
+ {
745
+ size: "2xsmall",
746
+ className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
747
+ children: entry.status.replace(/_/g, " ")
748
+ }
749
+ ) }),
663
750
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
664
- new Date(entry.changed_at).toLocaleString(),
665
- entry.changed_by && ` by ${entry.changed_by}`
751
+ new Date(entry.timestamp).toLocaleString(),
752
+ entry.admin_id && ` by ${entry.admin_id}`,
753
+ entry.reason && ` - ${entry.reason}`
666
754
  ] })
667
755
  ] })
668
756
  },
@@ -670,76 +758,62 @@ const ReturnDetailPage = () => {
670
758
  )) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
671
759
  ] })
672
760
  ] }),
673
- returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
761
+ order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
674
762
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
675
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
676
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
677
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
678
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
679
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
680
- ] }),
681
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
682
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
683
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
684
- ] }),
685
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
686
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
687
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_c = returnOrder.order.customer) == null ? void 0 : _c.email) || returnOrder.order.email || "—" })
688
- ] }),
689
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
690
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
691
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.total).toFixed(2)}` : "—" })
692
- ] })
763
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
764
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
765
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
766
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
693
767
  ] }),
694
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
695
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
696
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Subtotal" }),
697
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.subtotal ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.subtotal).toFixed(2)}` : "—" })
698
- ] }),
699
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
700
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Tax Total" }),
701
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.tax_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.tax_total).toFixed(2)}` : "—" })
702
- ] }),
703
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
704
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Shipping Total" }),
705
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.shipping_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.shipping_total).toFixed(2)}` : "—" })
706
- ] }),
707
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
708
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Created" }),
709
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.created_at ? new Date(returnOrder.order.created_at).toLocaleString() : "—" })
768
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
769
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
770
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "" })
771
+ ] }),
772
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
773
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
774
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
775
+ ] }),
776
+ order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
777
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
778
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
779
+ order.currency_code || "$",
780
+ (Number(order.total) / 100).toFixed(2)
710
781
  ] })
711
782
  ] })
712
783
  ] })
713
784
  ] }),
714
- returnOrder.items && returnOrder.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
785
+ swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
715
786
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
716
787
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
717
788
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
718
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item" }),
719
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
789
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
790
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
791
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
720
792
  ] }) }),
721
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.items.map((item) => {
722
- var _a2, _b2;
723
- return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
724
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: ((_a2 = item.item) == null ? void 0 : _a2.title) || ((_b2 = item.item) == null ? void 0 : _b2.id) || item.id }),
725
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
726
- ] }, item.id);
727
- }) })
793
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
794
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
795
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
796
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
797
+ ] }, item.id || index)) })
728
798
  ] }) })
729
799
  ] }),
730
- returnOrder.metadata && Object.keys(returnOrder.metadata).filter(
731
- (key) => key !== "status_history"
732
- ).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
733
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Metadata" }),
734
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: Object.entries(returnOrder.metadata).filter(([key]) => key !== "status_history").map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
735
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: key }),
736
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "font-medium", children: typeof value === "string" ? value : JSON.stringify(value) })
737
- ] }, key)) })
800
+ swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
801
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
802
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
803
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
804
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
805
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
806
+ ] }) }),
807
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
809
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
810
+ ] }, item.variant_id || index)) })
811
+ ] }) })
738
812
  ] })
739
813
  ] }) });
740
814
  };
741
815
  const config$1 = adminSdk.defineRouteConfig({
742
- label: "Return Order Details",
816
+ label: "Swap Details",
743
817
  icon: icons.ArrowPath
744
818
  });
745
819
  const getStatusBadgeClass = (status) => {
@@ -747,63 +821,65 @@ const getStatusBadgeClass = (status) => {
747
821
  if (statusLower === "requested") {
748
822
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
749
823
  }
750
- if (statusLower === "approved") {
824
+ if (statusLower === "received") {
751
825
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
752
826
  }
753
- if (statusLower === "rejected") {
827
+ if (statusLower === "requires_action") {
754
828
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
755
829
  }
756
830
  if (statusLower === "completed") {
757
831
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
758
832
  }
759
- if (statusLower === "cancelled") {
833
+ if (statusLower === "canceled") {
760
834
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
761
835
  }
762
836
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
763
837
  };
764
- const SwapDetailPage = () => {
765
- var _a, _b;
838
+ const ReturnDetailPage = () => {
839
+ var _a, _b, _c;
766
840
  const navigate = reactRouterDom.useNavigate();
767
841
  const { id } = reactRouterDom.useParams();
768
- const [swap, setSwap] = react.useState(null);
769
- const [order, setOrder] = react.useState(null);
842
+ const [returnOrder, setReturnOrder] = react.useState(null);
770
843
  const [selectedStatus, setSelectedStatus] = react.useState("");
771
844
  const [isLoading, setIsLoading] = react.useState(true);
772
845
  const [isUpdating, setIsUpdating] = react.useState(false);
773
- const [isApproving, setIsApproving] = react.useState(false);
774
- const [isRejecting, setIsRejecting] = react.useState(false);
775
846
  const [error, setError] = react.useState(null);
776
847
  const [updateError, setUpdateError] = react.useState(null);
777
848
  const [updateSuccess, setUpdateSuccess] = react.useState(false);
778
- const availableStatuses = ["requested", "approved", "rejected"];
849
+ const availableStatuses = [
850
+ "requested",
851
+ "received",
852
+ "requires_action",
853
+ "completed",
854
+ "canceled"
855
+ ];
779
856
  react.useEffect(() => {
780
857
  if (!id) {
781
- navigate("/swaps");
858
+ navigate("/returns");
782
859
  return;
783
860
  }
784
- const loadSwap = async () => {
861
+ const loadReturn = async () => {
785
862
  try {
786
863
  setIsLoading(true);
787
864
  setError(null);
788
- const response = await fetch(`/admin/swaps/${id}`, {
865
+ const response = await fetch(`/admin/returns/${id}`, {
789
866
  credentials: "include"
790
867
  });
791
868
  if (!response.ok) {
792
869
  const message = await response.text();
793
- throw new Error(message || "Unable to load swap");
870
+ throw new Error(message || "Unable to load return order");
794
871
  }
795
872
  const payload = await response.json();
796
- setSwap(payload.swap);
797
- setOrder(payload.order || null);
873
+ setReturnOrder(payload.return);
798
874
  setSelectedStatus("");
799
875
  } catch (loadError) {
800
- const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
876
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
801
877
  setError(message);
802
878
  } finally {
803
879
  setIsLoading(false);
804
880
  }
805
881
  };
806
- void loadSwap();
882
+ void loadReturn();
807
883
  }, [id, navigate]);
808
884
  const handleStatusUpdate = async () => {
809
885
  if (!id || !selectedStatus) {
@@ -813,7 +889,7 @@ const SwapDetailPage = () => {
813
889
  setIsUpdating(true);
814
890
  setUpdateError(null);
815
891
  setUpdateSuccess(false);
816
- const response = await fetch(`/admin/swaps/${id}/status`, {
892
+ const response = await fetch(`/admin/returns/${id}/status`, {
817
893
  method: "POST",
818
894
  headers: {
819
895
  "Content-Type": "application/json"
@@ -826,17 +902,16 @@ const SwapDetailPage = () => {
826
902
  throw new Error(message || "Unable to update status");
827
903
  }
828
904
  const payload = await response.json();
829
- setSwap(payload.swap);
905
+ setReturnOrder(payload.return);
830
906
  setSelectedStatus("");
831
907
  setUpdateSuccess(true);
832
908
  setTimeout(() => setUpdateSuccess(false), 3e3);
833
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
909
+ const detailResponse = await fetch(`/admin/returns/${id}`, {
834
910
  credentials: "include"
835
911
  });
836
912
  if (detailResponse.ok) {
837
913
  const detailPayload = await detailResponse.json();
838
- setSwap(detailPayload.swap);
839
- setOrder(detailPayload.order || null);
914
+ setReturnOrder(detailPayload.return);
840
915
  }
841
916
  } catch (updateErr) {
842
917
  const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
@@ -845,90 +920,16 @@ const SwapDetailPage = () => {
845
920
  setIsUpdating(false);
846
921
  }
847
922
  };
848
- const handleApproveClick = async () => {
849
- if (!id) {
850
- return;
851
- }
852
- if (!swap || !swap.order_id) {
853
- setUpdateError("Swap must have an order_id to create exchange");
854
- return;
855
- }
856
- try {
857
- setIsApproving(true);
858
- setUpdateError(null);
859
- setUpdateSuccess(false);
860
- const response = await fetch(`/admin/swaps/${id}/prepare-exchange`, {
861
- method: "POST",
862
- headers: {
863
- "Content-Type": "application/json"
864
- },
865
- credentials: "include"
866
- });
867
- if (!response.ok) {
868
- const errorData = await response.json().catch(() => ({ message: "Unable to prepare swap for exchange creation" }));
869
- throw new Error(errorData.message || errorData.error || "Unable to prepare swap for exchange creation");
870
- }
871
- const payload = await response.json();
872
- setSwap(payload.swap);
873
- setUpdateSuccess(true);
874
- setTimeout(() => setUpdateSuccess(false), 3e3);
875
- window.location.href = `/app/orders/${swap.order_id}/exchanges`;
876
- } catch (updateErr) {
877
- const message = updateErr instanceof Error ? updateErr.message : "Unable to prepare swap for exchange creation";
878
- setUpdateError(message);
879
- } finally {
880
- setIsApproving(false);
881
- }
882
- };
883
- const handleReject = async () => {
884
- if (!id) {
885
- return;
886
- }
887
- try {
888
- setIsRejecting(true);
889
- setUpdateError(null);
890
- setUpdateSuccess(false);
891
- const response = await fetch(`/admin/swaps/${id}/reject`, {
892
- method: "POST",
893
- headers: {
894
- "Content-Type": "application/json"
895
- },
896
- credentials: "include",
897
- body: JSON.stringify({ reason: "Rejected by admin" })
898
- });
899
- if (!response.ok) {
900
- const message = await response.text();
901
- throw new Error(message || "Unable to reject swap");
902
- }
903
- const payload = await response.json();
904
- setSwap(payload.swap);
905
- setUpdateSuccess(true);
906
- setTimeout(() => setUpdateSuccess(false), 3e3);
907
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
908
- credentials: "include"
909
- });
910
- if (detailResponse.ok) {
911
- const detailPayload = await response.json();
912
- setSwap(detailPayload.swap);
913
- setOrder(detailPayload.order || null);
914
- }
915
- } catch (updateErr) {
916
- const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
917
- setUpdateError(message);
918
- } finally {
919
- setIsRejecting(false);
920
- }
921
- };
922
923
  if (isLoading) {
923
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
924
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading return order..." }) }) }) });
924
925
  }
925
- if (error || !swap) {
926
+ if (error || !returnOrder) {
926
927
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
927
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
928
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
928
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
929
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
929
930
  ] }) }) });
930
931
  }
931
- const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
932
+ const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
932
933
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
933
934
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
934
935
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -936,7 +937,7 @@ const SwapDetailPage = () => {
936
937
  {
937
938
  variant: "transparent",
938
939
  size: "small",
939
- onClick: () => navigate("/swaps"),
940
+ onClick: () => navigate("/returns"),
940
941
  className: "w-fit",
941
942
  children: [
942
943
  /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
@@ -946,42 +947,20 @@ const SwapDetailPage = () => {
946
947
  ),
947
948
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
948
949
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
949
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
950
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
950
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
951
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
951
952
  ] }),
952
953
  /* @__PURE__ */ jsxRuntime.jsx(
953
954
  ui.Badge,
954
955
  {
955
956
  size: "small",
956
- className: `uppercase ${getStatusBadgeClass(swap.status)}`,
957
- children: swap.status.replace(/_/g, " ")
957
+ className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
958
+ children: returnOrder.status.replace("_", " ")
958
959
  }
959
960
  )
960
961
  ] })
961
962
  ] }),
962
- swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
963
- /* @__PURE__ */ jsxRuntime.jsx(
964
- ui.Button,
965
- {
966
- variant: "primary",
967
- onClick: handleApproveClick,
968
- disabled: isApproving || isRejecting,
969
- isLoading: isApproving,
970
- children: "Approve Swap"
971
- }
972
- ),
973
- /* @__PURE__ */ jsxRuntime.jsx(
974
- ui.Button,
975
- {
976
- variant: "secondary",
977
- onClick: handleReject,
978
- disabled: isApproving || isRejecting,
979
- isLoading: isRejecting,
980
- children: "Reject Swap"
981
- }
982
- )
983
- ] }),
984
- swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
963
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
985
964
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
986
965
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
987
966
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
@@ -994,7 +973,7 @@ const SwapDetailPage = () => {
994
973
  className: "h-9 w-full 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",
995
974
  children: [
996
975
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
997
- availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
976
+ availableStatuses.filter((status) => status !== returnOrder.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace("_", " ").toUpperCase() }, status))
998
977
  ]
999
978
  }
1000
979
  )
@@ -1013,60 +992,37 @@ const SwapDetailPage = () => {
1013
992
  updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
1014
993
  updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
1015
994
  ] }),
1016
- swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1017
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
1018
- swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1019
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1020
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1021
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
1022
- ] }),
1023
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
1024
- ui.Button,
1025
- {
1026
- variant: "secondary",
1027
- onClick: () => {
1028
- window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
1029
- },
1030
- children: "View Exchange"
1031
- }
1032
- ) })
1033
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
1034
- ] }),
1035
995
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1036
996
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1037
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
997
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
1038
998
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1039
999
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1040
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
1041
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
1000
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
1001
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
1042
1002
  ] }),
1043
1003
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1044
1004
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
1045
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
1005
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
1046
1006
  ] }),
1047
1007
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1048
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
1049
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
1008
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund Amount" }),
1009
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.refund_amount ? `${((_b = returnOrder.order) == null ? void 0 : _b.currency_code) || "$"}${Number(returnOrder.refund_amount).toFixed(2)}` : "—" })
1050
1010
  ] }),
1051
- swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1011
+ returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1052
1012
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
1053
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
1013
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
1054
1014
  ] }),
1055
- swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1015
+ returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1056
1016
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
1057
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
1017
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
1058
1018
  ] }),
1059
1019
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1060
1020
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
1061
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
1021
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
1062
1022
  ] }),
1063
1023
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1064
1024
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
1065
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
1066
- ] }),
1067
- swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1068
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1069
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
1025
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
1070
1026
  ] })
1071
1027
  ] })
1072
1028
  ] }),
@@ -1077,18 +1033,23 @@ const SwapDetailPage = () => {
1077
1033
  {
1078
1034
  className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
1079
1035
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1080
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
1081
- ui.Badge,
1082
- {
1083
- size: "2xsmall",
1084
- className: `uppercase ${getStatusBadgeClass(entry.status)}`,
1085
- children: entry.status.replace(/_/g, " ")
1086
- }
1087
- ) }),
1036
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1037
+ /* @__PURE__ */ jsxRuntime.jsx(
1038
+ ui.Badge,
1039
+ {
1040
+ size: "2xsmall",
1041
+ className: `uppercase ${getStatusBadgeClass(entry.to)}`,
1042
+ children: entry.to.replace("_", " ")
1043
+ }
1044
+ ),
1045
+ entry.from && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
1046
+ "from ",
1047
+ entry.from.replace("_", " ")
1048
+ ] })
1049
+ ] }),
1088
1050
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
1089
- new Date(entry.timestamp).toLocaleString(),
1090
- entry.admin_id && ` by ${entry.admin_id}`,
1091
- entry.reason && ` - ${entry.reason}`
1051
+ new Date(entry.changed_at).toLocaleString(),
1052
+ entry.changed_by && ` by ${entry.changed_by}`
1092
1053
  ] })
1093
1054
  ] })
1094
1055
  },
@@ -1096,109 +1057,123 @@ const SwapDetailPage = () => {
1096
1057
  )) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
1097
1058
  ] })
1098
1059
  ] }),
1099
- order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1060
+ returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1100
1061
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
1101
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1102
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1103
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1104
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
1105
- ] }),
1106
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1107
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1108
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
1109
- ] }),
1110
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1111
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1112
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "" })
1062
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1063
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1064
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1065
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1066
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
1067
+ ] }),
1068
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1069
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1070
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
1071
+ ] }),
1072
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1073
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1074
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_c = returnOrder.order.customer) == null ? void 0 : _c.email) || returnOrder.order.email || "—" })
1075
+ ] }),
1076
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1077
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1078
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.total).toFixed(2)}` : "—" })
1079
+ ] })
1113
1080
  ] }),
1114
- order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1115
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1116
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
1117
- order.currency_code || "$",
1118
- (Number(order.total) / 100).toFixed(2)
1081
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1083
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Subtotal" }),
1084
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.subtotal ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.subtotal).toFixed(2)}` : "—" })
1085
+ ] }),
1086
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1087
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Tax Total" }),
1088
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.tax_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.tax_total).toFixed(2)}` : "—" })
1089
+ ] }),
1090
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1091
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Shipping Total" }),
1092
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.shipping_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.shipping_total).toFixed(2)}` : "—" })
1093
+ ] }),
1094
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1095
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Created" }),
1096
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.created_at ? new Date(returnOrder.order.created_at).toLocaleString() : "—" })
1119
1097
  ] })
1120
1098
  ] })
1121
1099
  ] })
1122
1100
  ] }),
1123
- swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1101
+ returnOrder.items && returnOrder.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1124
1102
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
1125
1103
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
1126
1104
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1127
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
1128
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
1129
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
1130
- ] }) }),
1131
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1132
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
1133
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
1134
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
1135
- ] }, item.id || index)) })
1136
- ] }) })
1137
- ] }),
1138
- swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1139
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
1140
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
1141
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1142
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
1105
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item" }),
1143
1106
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
1144
1107
  ] }) }),
1145
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1146
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
1147
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1148
- ] }, item.variant_id || index)) })
1108
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.items.map((item) => {
1109
+ var _a2, _b2;
1110
+ return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1111
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: ((_a2 = item.item) == null ? void 0 : _a2.title) || ((_b2 = item.item) == null ? void 0 : _b2.id) || item.id }),
1112
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1113
+ ] }, item.id);
1114
+ }) })
1149
1115
  ] }) })
1116
+ ] }),
1117
+ returnOrder.metadata && Object.keys(returnOrder.metadata).filter(
1118
+ (key) => key !== "status_history"
1119
+ ).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1120
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Metadata" }),
1121
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: Object.entries(returnOrder.metadata).filter(([key]) => key !== "status_history").map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
1122
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: key }),
1123
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "font-medium", children: typeof value === "string" ? value : JSON.stringify(value) })
1124
+ ] }, key)) })
1150
1125
  ] })
1151
1126
  ] }) });
1152
1127
  };
1153
1128
  const config = adminSdk.defineRouteConfig({
1154
- label: "Swap Details",
1129
+ label: "Return Order Details",
1155
1130
  icon: icons.ArrowPath
1156
1131
  });
1157
1132
  const i18nTranslations0 = {};
1158
1133
  const widgetModule = { widgets: [] };
1159
1134
  const routeModule = {
1160
1135
  routes: [
1161
- {
1162
- Component: ReturnsPage,
1163
- path: "/returns"
1164
- },
1165
1136
  {
1166
1137
  Component: SwapsPage,
1167
1138
  path: "/swaps"
1168
1139
  },
1169
1140
  {
1170
- Component: ReturnDetailPage,
1171
- path: "/returns/:id"
1141
+ Component: ReturnsPage,
1142
+ path: "/returns"
1172
1143
  },
1173
1144
  {
1174
1145
  Component: SwapDetailPage,
1175
1146
  path: "/swaps/:id"
1147
+ },
1148
+ {
1149
+ Component: ReturnDetailPage,
1150
+ path: "/returns/:id"
1176
1151
  }
1177
1152
  ]
1178
1153
  };
1179
1154
  const menuItemModule = {
1180
1155
  menuItems: [
1181
1156
  {
1182
- label: config$3.label,
1183
- icon: config$3.icon,
1157
+ label: config$2.label,
1158
+ icon: config$2.icon,
1184
1159
  path: "/returns",
1185
1160
  nested: void 0
1186
1161
  },
1187
1162
  {
1188
- label: config$2.label,
1189
- icon: config$2.icon,
1163
+ label: config$3.label,
1164
+ icon: config$3.icon,
1190
1165
  path: "/swaps",
1191
1166
  nested: void 0
1192
1167
  },
1193
1168
  {
1194
- label: config$1.label,
1195
- icon: config$1.icon,
1169
+ label: config.label,
1170
+ icon: config.icon,
1196
1171
  path: "/returns/:id",
1197
1172
  nested: void 0
1198
1173
  },
1199
1174
  {
1200
- label: config.label,
1201
- icon: config.icon,
1175
+ label: config$1.label,
1176
+ icon: config$1.icon,
1202
1177
  path: "/swaps/:id",
1203
1178
  nested: void 0
1204
1179
  }