order-management 0.0.28 → 0.0.30

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