order-management 0.0.20 → 0.0.22

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