order-management 0.0.18 → 0.0.19

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.
@@ -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,73 @@ 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
777
  const availableStatuses = [
864
778
  "requested",
865
- "received",
866
- "requires_action",
779
+ "approved",
780
+ "rejected",
781
+ "return_started",
782
+ "return_shipped",
783
+ "return_received",
784
+ "new_items_shipped",
867
785
  "completed",
868
- "canceled"
786
+ "cancelled"
869
787
  ];
870
788
  useEffect(() => {
871
789
  if (!id) {
872
- navigate("/returns");
790
+ navigate("/swaps");
873
791
  return;
874
792
  }
875
- const loadReturn = async () => {
793
+ const loadSwap = async () => {
876
794
  try {
877
795
  setIsLoading(true);
878
796
  setError(null);
879
- const response = await fetch(`/admin/returns/${id}`, {
797
+ const response = await fetch(`/admin/swaps/${id}`, {
880
798
  credentials: "include"
881
799
  });
882
800
  if (!response.ok) {
883
801
  const message = await response.text();
884
- throw new Error(message || "Unable to load return order");
802
+ throw new Error(message || "Unable to load swap");
885
803
  }
886
804
  const payload = await response.json();
887
- setReturnOrder(payload.return);
805
+ setSwap(payload.swap);
806
+ setOrder(payload.order || null);
888
807
  setSelectedStatus("");
889
808
  } catch (loadError) {
890
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
809
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
891
810
  setError(message);
892
811
  } finally {
893
812
  setIsLoading(false);
894
813
  }
895
814
  };
896
- void loadReturn();
815
+ void loadSwap();
897
816
  }, [id, navigate]);
898
817
  const handleStatusUpdate = async () => {
899
818
  if (!id || !selectedStatus) {
@@ -903,7 +822,7 @@ const ReturnDetailPage = () => {
903
822
  setIsUpdating(true);
904
823
  setUpdateError(null);
905
824
  setUpdateSuccess(false);
906
- const response = await fetch(`/admin/returns/${id}/status`, {
825
+ const response = await fetch(`/admin/swaps/${id}/status`, {
907
826
  method: "POST",
908
827
  headers: {
909
828
  "Content-Type": "application/json"
@@ -916,16 +835,17 @@ const ReturnDetailPage = () => {
916
835
  throw new Error(message || "Unable to update status");
917
836
  }
918
837
  const payload = await response.json();
919
- setReturnOrder(payload.return);
838
+ setSwap(payload.swap);
920
839
  setSelectedStatus("");
921
840
  setUpdateSuccess(true);
922
841
  setTimeout(() => setUpdateSuccess(false), 3e3);
923
- const detailResponse = await fetch(`/admin/returns/${id}`, {
842
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
924
843
  credentials: "include"
925
844
  });
926
845
  if (detailResponse.ok) {
927
846
  const detailPayload = await detailResponse.json();
928
- setReturnOrder(detailPayload.return);
847
+ setSwap(detailPayload.swap);
848
+ setOrder(detailPayload.order || null);
929
849
  }
930
850
  } catch (updateErr) {
931
851
  const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
@@ -934,16 +854,93 @@ const ReturnDetailPage = () => {
934
854
  setIsUpdating(false);
935
855
  }
936
856
  };
857
+ const handleApprove = async () => {
858
+ if (!id) {
859
+ return;
860
+ }
861
+ try {
862
+ setIsApproving(true);
863
+ setUpdateError(null);
864
+ setUpdateSuccess(false);
865
+ const response = await fetch(`/admin/swaps/${id}/approve`, {
866
+ method: "POST",
867
+ headers: {
868
+ "Content-Type": "application/json"
869
+ },
870
+ credentials: "include"
871
+ });
872
+ if (!response.ok) {
873
+ const message = await response.text();
874
+ throw new Error(message || "Unable to approve swap");
875
+ }
876
+ const payload = await response.json();
877
+ setSwap(payload.swap);
878
+ setUpdateSuccess(true);
879
+ setTimeout(() => setUpdateSuccess(false), 3e3);
880
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
881
+ credentials: "include"
882
+ });
883
+ if (detailResponse.ok) {
884
+ const detailPayload = await response.json();
885
+ setSwap(detailPayload.swap);
886
+ setOrder(detailPayload.order || null);
887
+ }
888
+ } catch (updateErr) {
889
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to approve swap";
890
+ setUpdateError(message);
891
+ } finally {
892
+ setIsApproving(false);
893
+ }
894
+ };
895
+ const handleReject = async () => {
896
+ if (!id) {
897
+ return;
898
+ }
899
+ try {
900
+ setIsRejecting(true);
901
+ setUpdateError(null);
902
+ setUpdateSuccess(false);
903
+ const response = await fetch(`/admin/swaps/${id}/reject`, {
904
+ method: "POST",
905
+ headers: {
906
+ "Content-Type": "application/json"
907
+ },
908
+ credentials: "include",
909
+ body: JSON.stringify({ reason: "Rejected by admin" })
910
+ });
911
+ if (!response.ok) {
912
+ const message = await response.text();
913
+ throw new Error(message || "Unable to reject swap");
914
+ }
915
+ const payload = await response.json();
916
+ setSwap(payload.swap);
917
+ setUpdateSuccess(true);
918
+ setTimeout(() => setUpdateSuccess(false), 3e3);
919
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
920
+ credentials: "include"
921
+ });
922
+ if (detailResponse.ok) {
923
+ const detailPayload = await response.json();
924
+ setSwap(detailPayload.swap);
925
+ setOrder(detailPayload.order || null);
926
+ }
927
+ } catch (updateErr) {
928
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
929
+ setUpdateError(message);
930
+ } finally {
931
+ setIsRejecting(false);
932
+ }
933
+ };
937
934
  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..." }) }) }) });
935
+ 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..." }) }) }) });
939
936
  }
940
- if (error || !returnOrder) {
937
+ if (error || !swap) {
941
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__ */ 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" }) })
939
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
940
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
944
941
  ] }) }) });
945
942
  }
946
- const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
943
+ const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
947
944
  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
945
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
949
946
  /* @__PURE__ */ jsxs(
@@ -951,7 +948,7 @@ const ReturnDetailPage = () => {
951
948
  {
952
949
  variant: "transparent",
953
950
  size: "small",
954
- onClick: () => navigate("/returns"),
951
+ onClick: () => navigate("/swaps"),
955
952
  className: "w-fit",
956
953
  children: [
957
954
  /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
@@ -961,19 +958,41 @@ const ReturnDetailPage = () => {
961
958
  ),
962
959
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
963
960
  /* @__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 })
961
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Swap Details" }),
962
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
966
963
  ] }),
967
964
  /* @__PURE__ */ jsx(
968
965
  Badge,
969
966
  {
970
967
  size: "small",
971
- className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
972
- children: returnOrder.status.replace("_", " ")
968
+ className: `uppercase ${getStatusBadgeClass(swap.status)}`,
969
+ children: swap.status.replace(/_/g, " ")
973
970
  }
974
971
  )
975
972
  ] })
976
973
  ] }),
974
+ swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
975
+ /* @__PURE__ */ jsx(
976
+ Button,
977
+ {
978
+ variant: "primary",
979
+ onClick: handleApprove,
980
+ disabled: isApproving || isRejecting,
981
+ isLoading: isApproving,
982
+ children: "Approve Swap"
983
+ }
984
+ ),
985
+ /* @__PURE__ */ jsx(
986
+ Button,
987
+ {
988
+ variant: "secondary",
989
+ onClick: handleReject,
990
+ disabled: isApproving || isRejecting,
991
+ isLoading: isRejecting,
992
+ children: "Reject Swap"
993
+ }
994
+ )
995
+ ] }),
977
996
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
978
997
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
979
998
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
@@ -987,7 +1006,7 @@ const ReturnDetailPage = () => {
987
1006
  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
1007
  children: [
989
1008
  /* @__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))
1009
+ availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
991
1010
  ]
992
1011
  }
993
1012
  )
@@ -1008,35 +1027,35 @@ const ReturnDetailPage = () => {
1008
1027
  ] }),
1009
1028
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1010
1029
  /* @__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" }),
1030
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
1012
1031
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1013
1032
  /* @__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 })
1033
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
1034
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
1016
1035
  ] }),
1017
1036
  /* @__PURE__ */ jsxs("div", { children: [
1018
1037
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
1019
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
1038
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
1020
1039
  ] }),
1021
1040
  /* @__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)}` : "—" })
1041
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
1042
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
1024
1043
  ] }),
1025
- returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
1044
+ swap.reason && /* @__PURE__ */ jsxs("div", { children: [
1026
1045
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
1027
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
1046
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
1028
1047
  ] }),
1029
- returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
1048
+ swap.note && /* @__PURE__ */ jsxs("div", { children: [
1030
1049
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
1031
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
1050
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
1032
1051
  ] }),
1033
1052
  /* @__PURE__ */ jsxs("div", { children: [
1034
1053
  /* @__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() })
1054
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
1036
1055
  ] }),
1037
1056
  /* @__PURE__ */ jsxs("div", { children: [
1038
1057
  /* @__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() })
1058
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
1040
1059
  ] })
1041
1060
  ] })
1042
1061
  ] }),
@@ -1047,23 +1066,18 @@ const ReturnDetailPage = () => {
1047
1066
  {
1048
1067
  className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
1049
1068
  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
- ] }),
1069
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
1070
+ Badge,
1071
+ {
1072
+ size: "2xsmall",
1073
+ className: `uppercase ${getStatusBadgeClass(entry.status)}`,
1074
+ children: entry.status.replace(/_/g, " ")
1075
+ }
1076
+ ) }),
1064
1077
  /* @__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}`
1078
+ new Date(entry.timestamp).toLocaleString(),
1079
+ entry.admin_id && ` by ${entry.admin_id}`,
1080
+ entry.reason && ` - ${entry.reason}`
1067
1081
  ] })
1068
1082
  ] })
1069
1083
  },
@@ -1071,123 +1085,109 @@ const ReturnDetailPage = () => {
1071
1085
  )) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
1072
1086
  ] })
1073
1087
  ] }),
1074
- returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1088
+ order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1075
1089
  /* @__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
- ] })
1090
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1091
+ /* @__PURE__ */ jsxs("div", { children: [
1092
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1093
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
1094
1094
  ] }),
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() : "—" })
1095
+ /* @__PURE__ */ jsxs("div", { children: [
1096
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1097
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "" })
1098
+ ] }),
1099
+ /* @__PURE__ */ jsxs("div", { children: [
1100
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1101
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
1102
+ ] }),
1103
+ order.total && /* @__PURE__ */ jsxs("div", { children: [
1104
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1105
+ /* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
1106
+ order.currency_code || "$",
1107
+ (Number(order.total) / 100).toFixed(2)
1111
1108
  ] })
1112
1109
  ] })
1113
1110
  ] })
1114
1111
  ] }),
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: [
1112
+ 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
1113
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
1117
1114
  /* @__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
1115
  /* @__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" })
1116
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
1117
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
1118
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
1121
1119
  ] }) }),
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
- }) })
1120
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
1121
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
1122
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
1123
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
1124
+ ] }, item.id || index)) })
1129
1125
  ] }) })
1130
1126
  ] }),
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)) })
1127
+ 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: [
1128
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
1129
+ /* @__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: [
1130
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
1131
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
1132
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
1133
+ ] }) }),
1134
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
1135
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
1136
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1137
+ ] }, item.variant_id || index)) })
1138
+ ] }) })
1139
1139
  ] })
1140
1140
  ] }) });
1141
1141
  };
1142
1142
  const config = defineRouteConfig({
1143
- label: "Return Order Details",
1143
+ label: "Swap Details",
1144
1144
  icon: ArrowPath
1145
1145
  });
1146
1146
  const i18nTranslations0 = {};
1147
1147
  const widgetModule = { widgets: [] };
1148
1148
  const routeModule = {
1149
1149
  routes: [
1150
- {
1151
- Component: SwapsPage,
1152
- path: "/swaps"
1153
- },
1154
1150
  {
1155
1151
  Component: ReturnsPage,
1156
1152
  path: "/returns"
1157
1153
  },
1158
1154
  {
1159
- Component: SwapDetailPage,
1160
- path: "/swaps/:id"
1155
+ Component: SwapsPage,
1156
+ path: "/swaps"
1161
1157
  },
1162
1158
  {
1163
1159
  Component: ReturnDetailPage,
1164
1160
  path: "/returns/:id"
1161
+ },
1162
+ {
1163
+ Component: SwapDetailPage,
1164
+ path: "/swaps/:id"
1165
1165
  }
1166
1166
  ]
1167
1167
  };
1168
1168
  const menuItemModule = {
1169
1169
  menuItems: [
1170
1170
  {
1171
- label: config$2.label,
1172
- icon: config$2.icon,
1171
+ label: config$3.label,
1172
+ icon: config$3.icon,
1173
1173
  path: "/returns",
1174
1174
  nested: void 0
1175
1175
  },
1176
1176
  {
1177
- label: config$3.label,
1178
- icon: config$3.icon,
1177
+ label: config$2.label,
1178
+ icon: config$2.icon,
1179
1179
  path: "/swaps",
1180
1180
  nested: void 0
1181
1181
  },
1182
1182
  {
1183
- label: config.label,
1184
- icon: config.icon,
1183
+ label: config$1.label,
1184
+ icon: config$1.icon,
1185
1185
  path: "/returns/:id",
1186
1186
  nested: void 0
1187
1187
  },
1188
1188
  {
1189
- label: config$1.label,
1190
- icon: config$1.icon,
1189
+ label: config.label,
1190
+ icon: config.icon,
1191
1191
  path: "/swaps/:id",
1192
1192
  nested: void 0
1193
1193
  }