order-management 0.0.45 → 0.0.47

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) => {
@@ -440,6 +440,12 @@ const getStatusBadgeClass$1 = (status) => {
440
440
  if (statusLower === "rejected") {
441
441
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
442
442
  }
443
+ if (statusLower === "received") {
444
+ return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
445
+ }
446
+ if (statusLower === "refunded") {
447
+ return "bg-ui-tag-green-bg text-ui-tag-green-text";
448
+ }
443
449
  if (statusLower === "completed") {
444
450
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
445
451
  }
@@ -448,91 +454,45 @@ const getStatusBadgeClass$1 = (status) => {
448
454
  }
449
455
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
450
456
  };
451
- const SwapDetailPage = () => {
457
+ const ReturnDetailPage = () => {
452
458
  var _a, _b;
453
459
  const navigate = reactRouterDom.useNavigate();
454
460
  const { id } = reactRouterDom.useParams();
455
- const [swap, setSwap] = react.useState(null);
456
- const [order, setOrder] = react.useState(null);
457
- const [selectedStatus, setSelectedStatus] = react.useState("");
461
+ const [returnOrder, setReturnOrder] = react.useState(null);
458
462
  const [isLoading, setIsLoading] = react.useState(true);
459
- const [isUpdating, setIsUpdating] = react.useState(false);
460
463
  const [isApproving, setIsApproving] = react.useState(false);
461
464
  const [isRejecting, setIsRejecting] = react.useState(false);
462
465
  const [error, setError] = react.useState(null);
463
466
  const [updateError, setUpdateError] = react.useState(null);
464
467
  const [updateSuccess, setUpdateSuccess] = react.useState(false);
465
- const availableStatuses = ["requested", "approved", "rejected"];
466
468
  react.useEffect(() => {
467
469
  if (!id) {
468
- navigate("/swaps");
470
+ navigate("/returns");
469
471
  return;
470
472
  }
471
- const loadSwap = async () => {
473
+ const loadReturn = async () => {
472
474
  try {
473
475
  setIsLoading(true);
474
476
  setError(null);
475
- const response = await fetch(`/admin/swaps/${id}`, {
477
+ const response = await fetch(`/admin/returns/${id}`, {
476
478
  credentials: "include"
477
479
  });
478
480
  if (!response.ok) {
479
481
  const message = await response.text();
480
- throw new Error(message || "Unable to load swap");
482
+ throw new Error(message || "Unable to load return order");
481
483
  }
482
484
  const payload = await response.json();
483
- setSwap(payload.swap);
484
- setOrder(payload.order || null);
485
- setSelectedStatus("");
485
+ setReturnOrder(payload.return);
486
486
  } catch (loadError) {
487
- const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
487
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
488
488
  setError(message);
489
489
  } finally {
490
490
  setIsLoading(false);
491
491
  }
492
492
  };
493
- void loadSwap();
493
+ void loadReturn();
494
494
  }, [id, navigate]);
495
- const handleStatusUpdate = async () => {
496
- if (!id || !selectedStatus) {
497
- return;
498
- }
499
- try {
500
- setIsUpdating(true);
501
- setUpdateError(null);
502
- setUpdateSuccess(false);
503
- const response = await fetch(`/admin/swaps/${id}/status`, {
504
- method: "POST",
505
- headers: {
506
- "Content-Type": "application/json"
507
- },
508
- credentials: "include",
509
- body: JSON.stringify({ status: selectedStatus })
510
- });
511
- if (!response.ok) {
512
- const message = await response.text();
513
- throw new Error(message || "Unable to update status");
514
- }
515
- const payload = await response.json();
516
- setSwap(payload.swap);
517
- setSelectedStatus("");
518
- setUpdateSuccess(true);
519
- setTimeout(() => setUpdateSuccess(false), 3e3);
520
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
521
- credentials: "include"
522
- });
523
- if (detailResponse.ok) {
524
- const detailPayload = await detailResponse.json();
525
- setSwap(detailPayload.swap);
526
- setOrder(detailPayload.order || null);
527
- }
528
- } catch (updateErr) {
529
- const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
530
- setUpdateError(message);
531
- } finally {
532
- setIsUpdating(false);
533
- }
534
- };
535
- const handleAutoCreateExchange = async () => {
495
+ const handleApprove = async () => {
536
496
  if (!id) {
537
497
  return;
538
498
  }
@@ -540,7 +500,7 @@ const SwapDetailPage = () => {
540
500
  setIsApproving(true);
541
501
  setUpdateError(null);
542
502
  setUpdateSuccess(false);
543
- const response = await fetch(`/admin/swaps/${id}/create-exchange`, {
503
+ const response = await fetch(`/admin/returns/${id}/approve`, {
544
504
  method: "POST",
545
505
  headers: {
546
506
  "Content-Type": "application/json"
@@ -549,22 +509,21 @@ const SwapDetailPage = () => {
549
509
  });
550
510
  if (!response.ok) {
551
511
  const message = await response.text();
552
- throw new Error(message || "Unable to create exchange from swap");
512
+ throw new Error(message || "Unable to approve return");
553
513
  }
554
514
  const payload = await response.json();
555
- setSwap(payload.swap);
515
+ setReturnOrder(payload.return);
556
516
  setUpdateSuccess(true);
557
517
  setTimeout(() => setUpdateSuccess(false), 3e3);
558
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
518
+ const detailResponse = await fetch(`/admin/returns/${id}`, {
559
519
  credentials: "include"
560
520
  });
561
521
  if (detailResponse.ok) {
562
522
  const detailPayload = await detailResponse.json();
563
- setSwap(detailPayload.swap);
564
- setOrder(detailPayload.order || null);
523
+ setReturnOrder(detailPayload.return);
565
524
  }
566
525
  } catch (approveErr) {
567
- const message = approveErr instanceof Error ? approveErr.message : "Unable to create exchange from swap";
526
+ const message = approveErr instanceof Error ? approveErr.message : "Unable to approve return";
568
527
  setUpdateError(message);
569
528
  } finally {
570
529
  setIsApproving(false);
@@ -578,7 +537,7 @@ const SwapDetailPage = () => {
578
537
  setIsRejecting(true);
579
538
  setUpdateError(null);
580
539
  setUpdateSuccess(false);
581
- const response = await fetch(`/admin/swaps/${id}/reject`, {
540
+ const response = await fetch(`/admin/returns/${id}/reject`, {
582
541
  method: "POST",
583
542
  headers: {
584
543
  "Content-Type": "application/json"
@@ -588,37 +547,36 @@ const SwapDetailPage = () => {
588
547
  });
589
548
  if (!response.ok) {
590
549
  const message = await response.text();
591
- throw new Error(message || "Unable to reject swap");
550
+ throw new Error(message || "Unable to reject return");
592
551
  }
593
552
  const payload = await response.json();
594
- setSwap(payload.swap);
553
+ setReturnOrder(payload.return);
595
554
  setUpdateSuccess(true);
596
555
  setTimeout(() => setUpdateSuccess(false), 3e3);
597
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
556
+ const detailResponse = await fetch(`/admin/returns/${id}`, {
598
557
  credentials: "include"
599
558
  });
600
559
  if (detailResponse.ok) {
601
- const detailPayload = await response.json();
602
- setSwap(detailPayload.swap);
603
- setOrder(detailPayload.order || null);
560
+ const detailPayload = await detailResponse.json();
561
+ setReturnOrder(detailPayload.return);
604
562
  }
605
563
  } catch (updateErr) {
606
- const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
564
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
607
565
  setUpdateError(message);
608
566
  } finally {
609
567
  setIsRejecting(false);
610
568
  }
611
569
  };
612
570
  if (isLoading) {
613
- 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..." }) }) }) });
571
+ 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..." }) }) }) });
614
572
  }
615
- if (error || !swap) {
573
+ if (error || !returnOrder) {
616
574
  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: [
617
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
618
- /* @__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" }) })
575
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
576
+ /* @__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" }) })
619
577
  ] }) }) });
620
578
  }
621
- const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
579
+ const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
622
580
  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: [
623
581
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
624
582
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -626,7 +584,7 @@ const SwapDetailPage = () => {
626
584
  {
627
585
  variant: "transparent",
628
586
  size: "small",
629
- onClick: () => navigate("/swaps"),
587
+ onClick: () => navigate("/returns"),
630
588
  className: "w-fit",
631
589
  children: [
632
590
  /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
@@ -636,29 +594,29 @@ const SwapDetailPage = () => {
636
594
  ),
637
595
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
638
596
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
639
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
640
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
597
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
598
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
641
599
  ] }),
642
600
  /* @__PURE__ */ jsxRuntime.jsx(
643
601
  ui.Badge,
644
602
  {
645
603
  size: "small",
646
- className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
647
- children: swap.status.replace(/_/g, " ")
604
+ className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
605
+ children: returnOrder.status.replace(/_/g, " ")
648
606
  }
649
607
  )
650
608
  ] })
651
609
  ] }),
652
- swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
610
+ returnOrder.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
653
611
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
654
612
  /* @__PURE__ */ jsxRuntime.jsx(
655
613
  ui.Button,
656
614
  {
657
615
  variant: "primary",
658
- onClick: handleAutoCreateExchange,
616
+ onClick: handleApprove,
659
617
  disabled: isApproving || isRejecting,
660
618
  isLoading: isApproving,
661
- children: "Approve & Create Exchange"
619
+ children: "Approve & Process Return"
662
620
  }
663
621
  ),
664
622
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -668,98 +626,62 @@ const SwapDetailPage = () => {
668
626
  onClick: handleReject,
669
627
  disabled: isApproving || isRejecting,
670
628
  isLoading: isRejecting,
671
- children: "Reject Swap"
672
- }
673
- )
674
- ] }),
675
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Approving will automatically create an exchange with return items and new items from the swap request" })
676
- ] }),
677
- swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
678
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
679
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
680
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
681
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
682
- /* @__PURE__ */ jsxRuntime.jsxs(
683
- "select",
684
- {
685
- value: selectedStatus,
686
- onChange: (event) => setSelectedStatus(event.target.value),
687
- 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",
688
- children: [
689
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
690
- availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
691
- ]
692
- }
693
- )
694
- ] }),
695
- /* @__PURE__ */ jsxRuntime.jsx(
696
- ui.Button,
697
- {
698
- variant: "primary",
699
- onClick: handleStatusUpdate,
700
- disabled: !selectedStatus || isUpdating,
701
- isLoading: isUpdating,
702
- children: "Update Status"
629
+ children: "Reject Return"
703
630
  }
704
631
  )
705
632
  ] }),
706
- updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
707
- updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
633
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Approving will create a Medusa return entity and process the return request" })
708
634
  ] }),
709
- swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
710
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
711
- swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
635
+ (returnOrder.status === "approved" || returnOrder.status === "received" || returnOrder.status === "refunded") && returnOrder.medusa_return_id && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Receive item and process refund from the order detail page (same flow as admin-created returns)." }) }),
636
+ returnOrder.status === "approved" && returnOrder.medusa_return_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
637
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
638
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
712
639
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
713
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
714
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
640
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Medusa Return ID" }),
641
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.medusa_return_id })
715
642
  ] }),
716
643
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
717
644
  ui.Button,
718
645
  {
719
646
  variant: "secondary",
720
647
  onClick: () => {
721
- window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
648
+ window.open(
649
+ `/app/orders/${returnOrder.order_id}`,
650
+ "_blank"
651
+ );
722
652
  },
723
- children: "View Exchange"
653
+ children: "View in Medusa"
724
654
  }
725
655
  ) })
726
- ] }) : /* @__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." }) })
656
+ ] })
727
657
  ] }),
728
658
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
729
659
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
730
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
660
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
731
661
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
732
662
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
733
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
734
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
663
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
664
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
735
665
  ] }),
736
666
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
737
667
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
738
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
739
- ] }),
740
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
741
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
742
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
668
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
743
669
  ] }),
744
- swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
670
+ returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
745
671
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
746
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
672
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
747
673
  ] }),
748
- swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
674
+ returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
749
675
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
750
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
676
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
751
677
  ] }),
752
678
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
753
679
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
754
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
680
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
755
681
  ] }),
756
682
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
757
683
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
758
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
759
- ] }),
760
- swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
761
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
762
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
684
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
763
685
  ] })
764
686
  ] })
765
687
  ] }),
@@ -789,31 +711,31 @@ const SwapDetailPage = () => {
789
711
  )) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
790
712
  ] })
791
713
  ] }),
792
- order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
714
+ returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
793
715
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
794
716
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
795
717
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
796
718
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
797
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
719
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
798
720
  ] }),
799
721
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
800
722
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
801
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
723
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
802
724
  ] }),
803
725
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
804
726
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
805
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
727
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
806
728
  ] }),
807
- order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
729
+ returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
808
730
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
809
731
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
810
- order.currency_code || "$",
811
- (Number(order.total) / 100).toFixed(2)
732
+ returnOrder.order.currency_code || "$",
733
+ (Number(returnOrder.order.total) / 100).toFixed(2)
812
734
  ] })
813
735
  ] })
814
736
  ] })
815
737
  ] }),
816
- 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: [
738
+ returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
817
739
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
818
740
  /* @__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: [
819
741
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
@@ -821,31 +743,20 @@ const SwapDetailPage = () => {
821
743
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
822
744
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
823
745
  ] }) }),
824
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
746
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
825
747
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
826
748
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
827
749
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
828
750
  ] }, item.id || index)) })
829
751
  ] }) })
830
752
  ] }),
831
- 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: [
832
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
833
- /* @__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: [
834
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
835
- /* @__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" }),
836
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
837
- ] }) }),
838
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
839
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
840
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
841
- ] }, item.variant_id || index)) })
842
- ] }) })
843
- ] })
753
+ updateError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: updateError }) }),
754
+ updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
844
755
  ] }) });
845
756
  };
846
757
  const config$1 = adminSdk.defineRouteConfig({
847
- label: "Swap Details",
848
- icon: icons.ArrowPath
758
+ label: "Return Order Details",
759
+ icon: icons.CheckCircle
849
760
  });
850
761
  const getStatusBadgeClass = (status) => {
851
762
  const statusLower = status.toLowerCase();
@@ -858,12 +769,6 @@ const getStatusBadgeClass = (status) => {
858
769
  if (statusLower === "rejected") {
859
770
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
860
771
  }
861
- if (statusLower === "received") {
862
- return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
863
- }
864
- if (statusLower === "refunded") {
865
- return "bg-ui-tag-green-bg text-ui-tag-green-text";
866
- }
867
772
  if (statusLower === "completed") {
868
773
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
869
774
  }
@@ -872,45 +777,91 @@ const getStatusBadgeClass = (status) => {
872
777
  }
873
778
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
874
779
  };
875
- const ReturnDetailPage = () => {
780
+ const SwapDetailPage = () => {
876
781
  var _a, _b;
877
782
  const navigate = reactRouterDom.useNavigate();
878
783
  const { id } = reactRouterDom.useParams();
879
- const [returnOrder, setReturnOrder] = react.useState(null);
784
+ const [swap, setSwap] = react.useState(null);
785
+ const [order, setOrder] = react.useState(null);
786
+ const [selectedStatus, setSelectedStatus] = react.useState("");
880
787
  const [isLoading, setIsLoading] = react.useState(true);
788
+ const [isUpdating, setIsUpdating] = react.useState(false);
881
789
  const [isApproving, setIsApproving] = react.useState(false);
882
790
  const [isRejecting, setIsRejecting] = react.useState(false);
883
791
  const [error, setError] = react.useState(null);
884
792
  const [updateError, setUpdateError] = react.useState(null);
885
793
  const [updateSuccess, setUpdateSuccess] = react.useState(false);
794
+ const availableStatuses = ["requested", "approved", "rejected"];
886
795
  react.useEffect(() => {
887
796
  if (!id) {
888
- navigate("/returns");
797
+ navigate("/swaps");
889
798
  return;
890
799
  }
891
- const loadReturn = async () => {
800
+ const loadSwap = async () => {
892
801
  try {
893
802
  setIsLoading(true);
894
803
  setError(null);
895
- const response = await fetch(`/admin/returns/${id}`, {
804
+ const response = await fetch(`/admin/swaps/${id}`, {
896
805
  credentials: "include"
897
806
  });
898
807
  if (!response.ok) {
899
808
  const message = await response.text();
900
- throw new Error(message || "Unable to load return order");
809
+ throw new Error(message || "Unable to load swap");
901
810
  }
902
811
  const payload = await response.json();
903
- setReturnOrder(payload.return);
812
+ setSwap(payload.swap);
813
+ setOrder(payload.order || null);
814
+ setSelectedStatus("");
904
815
  } catch (loadError) {
905
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
816
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
906
817
  setError(message);
907
818
  } finally {
908
819
  setIsLoading(false);
909
820
  }
910
821
  };
911
- void loadReturn();
822
+ void loadSwap();
912
823
  }, [id, navigate]);
913
- const handleApprove = async () => {
824
+ const handleStatusUpdate = async () => {
825
+ if (!id || !selectedStatus) {
826
+ return;
827
+ }
828
+ try {
829
+ setIsUpdating(true);
830
+ setUpdateError(null);
831
+ setUpdateSuccess(false);
832
+ const response = await fetch(`/admin/swaps/${id}/status`, {
833
+ method: "POST",
834
+ headers: {
835
+ "Content-Type": "application/json"
836
+ },
837
+ credentials: "include",
838
+ body: JSON.stringify({ status: selectedStatus })
839
+ });
840
+ if (!response.ok) {
841
+ const message = await response.text();
842
+ throw new Error(message || "Unable to update status");
843
+ }
844
+ const payload = await response.json();
845
+ setSwap(payload.swap);
846
+ setSelectedStatus("");
847
+ setUpdateSuccess(true);
848
+ setTimeout(() => setUpdateSuccess(false), 3e3);
849
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
850
+ credentials: "include"
851
+ });
852
+ if (detailResponse.ok) {
853
+ const detailPayload = await detailResponse.json();
854
+ setSwap(detailPayload.swap);
855
+ setOrder(detailPayload.order || null);
856
+ }
857
+ } catch (updateErr) {
858
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
859
+ setUpdateError(message);
860
+ } finally {
861
+ setIsUpdating(false);
862
+ }
863
+ };
864
+ const handleAutoCreateExchange = async () => {
914
865
  if (!id) {
915
866
  return;
916
867
  }
@@ -918,7 +869,7 @@ const ReturnDetailPage = () => {
918
869
  setIsApproving(true);
919
870
  setUpdateError(null);
920
871
  setUpdateSuccess(false);
921
- const response = await fetch(`/admin/returns/${id}/approve`, {
872
+ const response = await fetch(`/admin/swaps/${id}/create-exchange`, {
922
873
  method: "POST",
923
874
  headers: {
924
875
  "Content-Type": "application/json"
@@ -927,21 +878,22 @@ const ReturnDetailPage = () => {
927
878
  });
928
879
  if (!response.ok) {
929
880
  const message = await response.text();
930
- throw new Error(message || "Unable to approve return");
881
+ throw new Error(message || "Unable to create exchange from swap");
931
882
  }
932
883
  const payload = await response.json();
933
- setReturnOrder(payload.return);
884
+ setSwap(payload.swap);
934
885
  setUpdateSuccess(true);
935
886
  setTimeout(() => setUpdateSuccess(false), 3e3);
936
- const detailResponse = await fetch(`/admin/returns/${id}`, {
887
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
937
888
  credentials: "include"
938
889
  });
939
890
  if (detailResponse.ok) {
940
891
  const detailPayload = await detailResponse.json();
941
- setReturnOrder(detailPayload.return);
892
+ setSwap(detailPayload.swap);
893
+ setOrder(detailPayload.order || null);
942
894
  }
943
895
  } catch (approveErr) {
944
- const message = approveErr instanceof Error ? approveErr.message : "Unable to approve return";
896
+ const message = approveErr instanceof Error ? approveErr.message : "Unable to create exchange from swap";
945
897
  setUpdateError(message);
946
898
  } finally {
947
899
  setIsApproving(false);
@@ -955,7 +907,7 @@ const ReturnDetailPage = () => {
955
907
  setIsRejecting(true);
956
908
  setUpdateError(null);
957
909
  setUpdateSuccess(false);
958
- const response = await fetch(`/admin/returns/${id}/reject`, {
910
+ const response = await fetch(`/admin/swaps/${id}/reject`, {
959
911
  method: "POST",
960
912
  headers: {
961
913
  "Content-Type": "application/json"
@@ -965,36 +917,37 @@ const ReturnDetailPage = () => {
965
917
  });
966
918
  if (!response.ok) {
967
919
  const message = await response.text();
968
- throw new Error(message || "Unable to reject return");
920
+ throw new Error(message || "Unable to reject swap");
969
921
  }
970
922
  const payload = await response.json();
971
- setReturnOrder(payload.return);
923
+ setSwap(payload.swap);
972
924
  setUpdateSuccess(true);
973
925
  setTimeout(() => setUpdateSuccess(false), 3e3);
974
- const detailResponse = await fetch(`/admin/returns/${id}`, {
926
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
975
927
  credentials: "include"
976
928
  });
977
929
  if (detailResponse.ok) {
978
- const detailPayload = await detailResponse.json();
979
- setReturnOrder(detailPayload.return);
930
+ const detailPayload = await response.json();
931
+ setSwap(detailPayload.swap);
932
+ setOrder(detailPayload.order || null);
980
933
  }
981
934
  } catch (updateErr) {
982
- const message = updateErr instanceof Error ? updateErr.message : "Unable to reject return";
935
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
983
936
  setUpdateError(message);
984
937
  } finally {
985
938
  setIsRejecting(false);
986
939
  }
987
940
  };
988
941
  if (isLoading) {
989
- 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..." }) }) }) });
942
+ 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..." }) }) }) });
990
943
  }
991
- if (error || !returnOrder) {
944
+ if (error || !swap) {
992
945
  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: [
993
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
994
- /* @__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" }) })
946
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
947
+ /* @__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" }) })
995
948
  ] }) }) });
996
949
  }
997
- const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
950
+ const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
998
951
  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: [
999
952
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
1000
953
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1002,7 +955,7 @@ const ReturnDetailPage = () => {
1002
955
  {
1003
956
  variant: "transparent",
1004
957
  size: "small",
1005
- onClick: () => navigate("/returns"),
958
+ onClick: () => navigate("/swaps"),
1006
959
  className: "w-fit",
1007
960
  children: [
1008
961
  /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
@@ -1012,29 +965,29 @@ const ReturnDetailPage = () => {
1012
965
  ),
1013
966
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
1014
967
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1015
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Return Order Details" }),
1016
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
968
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
969
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
1017
970
  ] }),
1018
971
  /* @__PURE__ */ jsxRuntime.jsx(
1019
972
  ui.Badge,
1020
973
  {
1021
974
  size: "small",
1022
- className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
1023
- children: returnOrder.status.replace(/_/g, " ")
975
+ className: `uppercase ${getStatusBadgeClass(swap.status)}`,
976
+ children: swap.status.replace(/_/g, " ")
1024
977
  }
1025
978
  )
1026
979
  ] })
1027
980
  ] }),
1028
- returnOrder.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
981
+ swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
1029
982
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
1030
983
  /* @__PURE__ */ jsxRuntime.jsx(
1031
984
  ui.Button,
1032
985
  {
1033
986
  variant: "primary",
1034
- onClick: handleApprove,
987
+ onClick: handleAutoCreateExchange,
1035
988
  disabled: isApproving || isRejecting,
1036
989
  isLoading: isApproving,
1037
- children: "Approve & Process Return"
990
+ children: "Approve & Create Exchange"
1038
991
  }
1039
992
  ),
1040
993
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1044,62 +997,98 @@ const ReturnDetailPage = () => {
1044
997
  onClick: handleReject,
1045
998
  disabled: isApproving || isRejecting,
1046
999
  isLoading: isRejecting,
1047
- children: "Reject Return"
1000
+ children: "Reject Swap"
1048
1001
  }
1049
1002
  )
1050
1003
  ] }),
1051
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Approving will create a Medusa return entity and process the return request" })
1004
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Approving will automatically create an exchange with return items and new items from the swap request" })
1052
1005
  ] }),
1053
- (returnOrder.status === "approved" || returnOrder.status === "received" || returnOrder.status === "refunded") && returnOrder.medusa_return_id && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Receive item and process refund from the order detail page (same flow as admin-created returns)." }) }),
1054
- returnOrder.status === "approved" && returnOrder.medusa_return_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1055
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
1056
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1006
+ swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1007
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
1008
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
1009
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
1010
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
1011
+ /* @__PURE__ */ jsxRuntime.jsxs(
1012
+ "select",
1013
+ {
1014
+ value: selectedStatus,
1015
+ onChange: (event) => setSelectedStatus(event.target.value),
1016
+ 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",
1017
+ children: [
1018
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
1019
+ availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
1020
+ ]
1021
+ }
1022
+ )
1023
+ ] }),
1024
+ /* @__PURE__ */ jsxRuntime.jsx(
1025
+ ui.Button,
1026
+ {
1027
+ variant: "primary",
1028
+ onClick: handleStatusUpdate,
1029
+ disabled: !selectedStatus || isUpdating,
1030
+ isLoading: isUpdating,
1031
+ children: "Update Status"
1032
+ }
1033
+ )
1034
+ ] }),
1035
+ updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
1036
+ updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
1037
+ ] }),
1038
+ swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1039
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
1040
+ swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1057
1041
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1058
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Medusa Return ID" }),
1059
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.medusa_return_id })
1042
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1043
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
1060
1044
  ] }),
1061
1045
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
1062
1046
  ui.Button,
1063
1047
  {
1064
1048
  variant: "secondary",
1065
1049
  onClick: () => {
1066
- window.open(
1067
- `/app/orders/${returnOrder.order_id}`,
1068
- "_blank"
1069
- );
1050
+ window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
1070
1051
  },
1071
- children: "View in Medusa"
1052
+ children: "View Exchange"
1072
1053
  }
1073
1054
  ) })
1074
- ] })
1055
+ ] }) : /* @__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." }) })
1075
1056
  ] }),
1076
1057
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1077
1058
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1078
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Details" }),
1059
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
1079
1060
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1080
1061
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1081
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
1082
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.id })
1062
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
1063
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
1083
1064
  ] }),
1084
1065
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1085
1066
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
1086
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
1067
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
1087
1068
  ] }),
1088
- returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1069
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1070
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
1071
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
1072
+ ] }),
1073
+ swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1089
1074
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
1090
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
1075
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
1091
1076
  ] }),
1092
- returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1077
+ swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1093
1078
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
1094
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
1079
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
1095
1080
  ] }),
1096
1081
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1097
1082
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
1098
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
1083
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
1099
1084
  ] }),
1100
1085
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1101
1086
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
1102
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
1087
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
1088
+ ] }),
1089
+ swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1090
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1091
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
1103
1092
  ] })
1104
1093
  ] })
1105
1094
  ] }),
@@ -1129,31 +1118,31 @@ const ReturnDetailPage = () => {
1129
1118
  )) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
1130
1119
  ] })
1131
1120
  ] }),
1132
- returnOrder.order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1121
+ order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1133
1122
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
1134
1123
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1135
1124
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1136
1125
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1137
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.id })
1126
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
1138
1127
  ] }),
1139
1128
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1140
1129
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1141
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.order.status || "—" })
1130
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
1142
1131
  ] }),
1143
1132
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1144
1133
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1145
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = returnOrder.order.customer) == null ? void 0 : _b.email) || returnOrder.order.email || "—" })
1134
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
1146
1135
  ] }),
1147
- returnOrder.order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1136
+ order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1148
1137
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1149
1138
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
1150
- returnOrder.order.currency_code || "$",
1151
- (Number(returnOrder.order.total) / 100).toFixed(2)
1139
+ order.currency_code || "$",
1140
+ (Number(order.total) / 100).toFixed(2)
1152
1141
  ] })
1153
1142
  ] })
1154
1143
  ] })
1155
1144
  ] }),
1156
- returnOrder.return_items && returnOrder.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1145
+ 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: [
1157
1146
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
1158
1147
  /* @__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: [
1159
1148
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
@@ -1161,66 +1150,77 @@ const ReturnDetailPage = () => {
1161
1150
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
1162
1151
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
1163
1152
  ] }) }),
1164
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1153
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1165
1154
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
1166
1155
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
1167
1156
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
1168
1157
  ] }, item.id || index)) })
1169
1158
  ] }) })
1170
1159
  ] }),
1171
- updateError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: updateError }) }),
1172
- updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
1160
+ 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: [
1161
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
1162
+ /* @__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: [
1163
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1164
+ /* @__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" }),
1165
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
1166
+ ] }) }),
1167
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1168
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
1169
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1170
+ ] }, item.variant_id || index)) })
1171
+ ] }) })
1172
+ ] })
1173
1173
  ] }) });
1174
1174
  };
1175
1175
  const config = adminSdk.defineRouteConfig({
1176
- label: "Return Order Details",
1177
- icon: icons.CheckCircle
1176
+ label: "Swap Details",
1177
+ icon: icons.ArrowPath
1178
1178
  });
1179
1179
  const i18nTranslations0 = {};
1180
1180
  const widgetModule = { widgets: [] };
1181
1181
  const routeModule = {
1182
1182
  routes: [
1183
- {
1184
- Component: SwapsPage,
1185
- path: "/swaps"
1186
- },
1187
1183
  {
1188
1184
  Component: ReturnsPage,
1189
1185
  path: "/returns"
1190
1186
  },
1191
1187
  {
1192
- Component: SwapDetailPage,
1193
- path: "/swaps/:id"
1188
+ Component: SwapsPage,
1189
+ path: "/swaps"
1194
1190
  },
1195
1191
  {
1196
1192
  Component: ReturnDetailPage,
1197
1193
  path: "/returns/:id"
1194
+ },
1195
+ {
1196
+ Component: SwapDetailPage,
1197
+ path: "/swaps/:id"
1198
1198
  }
1199
1199
  ]
1200
1200
  };
1201
1201
  const menuItemModule = {
1202
1202
  menuItems: [
1203
1203
  {
1204
- label: config$2.label,
1205
- icon: config$2.icon,
1204
+ label: config$3.label,
1205
+ icon: config$3.icon,
1206
1206
  path: "/returns",
1207
1207
  nested: void 0
1208
1208
  },
1209
1209
  {
1210
- label: config$3.label,
1211
- icon: config$3.icon,
1210
+ label: config$2.label,
1211
+ icon: config$2.icon,
1212
1212
  path: "/swaps",
1213
1213
  nested: void 0
1214
1214
  },
1215
1215
  {
1216
- label: config.label,
1217
- icon: config.icon,
1216
+ label: config$1.label,
1217
+ icon: config$1.icon,
1218
1218
  path: "/returns/:id",
1219
1219
  nested: void 0
1220
1220
  },
1221
1221
  {
1222
- label: config$1.label,
1223
- icon: config$1.icon,
1222
+ label: config.label,
1223
+ icon: config.icon,
1224
1224
  path: "/swaps/:id",
1225
1225
  nested: void 0
1226
1226
  }