order-management 0.0.22 → 0.0.23

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