order-management 0.0.49 → 0.0.50

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