order-management 0.0.42 → 0.0.43

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