order-management 0.0.22 → 0.0.24

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,67 @@ 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);
461
+ const [isCreatingExchange, setIsCreatingExchange] = useState(false);
462
+ const [sendNotification, setSendNotification] = useState(false);
463
+ const [exchangeError, setExchangeError] = useState(null);
464
+ const [exchangeSuccess, setExchangeSuccess] = useState(false);
458
465
  const [error, setError] = useState(null);
459
466
  const [updateError, setUpdateError] = useState(null);
460
467
  const [updateSuccess, setUpdateSuccess] = useState(false);
461
- const availableStatuses = [
462
- "requested",
463
- "received",
464
- "requires_action",
465
- "completed",
466
- "canceled"
467
- ];
468
+ const availableStatuses = ["requested", "approved", "rejected"];
468
469
  useEffect(() => {
469
470
  if (!id) {
470
- navigate("/returns");
471
+ navigate("/swaps");
471
472
  return;
472
473
  }
473
- const loadReturn = async () => {
474
+ const loadSwap = async () => {
474
475
  try {
475
476
  setIsLoading(true);
476
477
  setError(null);
477
- const response = await fetch(`/admin/returns/${id}`, {
478
+ const response = await fetch(`/admin/swaps/${id}`, {
478
479
  credentials: "include"
479
480
  });
480
481
  if (!response.ok) {
481
482
  const message = await response.text();
482
- throw new Error(message || "Unable to load return order");
483
+ throw new Error(message || "Unable to load swap");
483
484
  }
484
485
  const payload = await response.json();
485
- setReturnOrder(payload.return);
486
+ setSwap(payload.swap);
487
+ setOrder(payload.order || null);
486
488
  setSelectedStatus("");
487
489
  } catch (loadError) {
488
- const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
490
+ const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
489
491
  setError(message);
490
492
  } finally {
491
493
  setIsLoading(false);
492
494
  }
493
495
  };
494
- void loadReturn();
496
+ void loadSwap();
495
497
  }, [id, navigate]);
496
498
  const handleStatusUpdate = async () => {
497
499
  if (!id || !selectedStatus) {
@@ -501,7 +503,7 @@ const ReturnDetailPage = () => {
501
503
  setIsUpdating(true);
502
504
  setUpdateError(null);
503
505
  setUpdateSuccess(false);
504
- const response = await fetch(`/admin/returns/${id}/status`, {
506
+ const response = await fetch(`/admin/swaps/${id}/status`, {
505
507
  method: "POST",
506
508
  headers: {
507
509
  "Content-Type": "application/json"
@@ -514,16 +516,17 @@ const ReturnDetailPage = () => {
514
516
  throw new Error(message || "Unable to update status");
515
517
  }
516
518
  const payload = await response.json();
517
- setReturnOrder(payload.return);
519
+ setSwap(payload.swap);
518
520
  setSelectedStatus("");
519
521
  setUpdateSuccess(true);
520
522
  setTimeout(() => setUpdateSuccess(false), 3e3);
521
- const detailResponse = await fetch(`/admin/returns/${id}`, {
523
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
522
524
  credentials: "include"
523
525
  });
524
526
  if (detailResponse.ok) {
525
527
  const detailPayload = await detailResponse.json();
526
- setReturnOrder(detailPayload.return);
528
+ setSwap(detailPayload.swap);
529
+ setOrder(detailPayload.order || null);
527
530
  }
528
531
  } catch (updateErr) {
529
532
  const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
@@ -532,64 +535,204 @@ const ReturnDetailPage = () => {
532
535
  setIsUpdating(false);
533
536
  }
534
537
  };
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
- ] }),
538
+ const handleApprove = async () => {
539
+ if (!id) {
540
+ return;
541
+ }
542
+ try {
543
+ setIsApproving(true);
544
+ setUpdateError(null);
545
+ setUpdateSuccess(false);
546
+ const response = await fetch(`/admin/swaps/${id}/approve`, {
547
+ method: "POST",
548
+ headers: {
549
+ "Content-Type": "application/json"
550
+ },
551
+ credentials: "include"
552
+ });
553
+ if (!response.ok) {
554
+ const message = await response.text();
555
+ throw new Error(message || "Unable to approve swap");
556
+ }
557
+ const payload = await response.json();
558
+ setSwap(payload.swap);
559
+ setUpdateSuccess(true);
560
+ setTimeout(() => setUpdateSuccess(false), 5e3);
561
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
562
+ credentials: "include"
563
+ });
564
+ if (detailResponse.ok) {
565
+ const detailPayload = await detailResponse.json();
566
+ setSwap(detailPayload.swap);
567
+ setOrder(detailPayload.order || null);
568
+ }
569
+ } catch (updateErr) {
570
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to approve swap";
571
+ setUpdateError(message);
572
+ } finally {
573
+ setIsApproving(false);
574
+ }
575
+ };
576
+ const handleReject = async () => {
577
+ if (!id) {
578
+ return;
579
+ }
580
+ try {
581
+ setIsRejecting(true);
582
+ setUpdateError(null);
583
+ setUpdateSuccess(false);
584
+ const response = await fetch(`/admin/swaps/${id}/reject`, {
585
+ method: "POST",
586
+ headers: {
587
+ "Content-Type": "application/json"
588
+ },
589
+ credentials: "include",
590
+ body: JSON.stringify({ reason: "Rejected by admin" })
591
+ });
592
+ if (!response.ok) {
593
+ const message = await response.text();
594
+ throw new Error(message || "Unable to reject swap");
595
+ }
596
+ const payload = await response.json();
597
+ setSwap(payload.swap);
598
+ setUpdateSuccess(true);
599
+ setTimeout(() => setUpdateSuccess(false), 3e3);
600
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
601
+ credentials: "include"
602
+ });
603
+ if (detailResponse.ok) {
604
+ const detailPayload = await response.json();
605
+ setSwap(detailPayload.swap);
606
+ setOrder(detailPayload.order || null);
607
+ }
608
+ } catch (updateErr) {
609
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
610
+ setUpdateError(message);
611
+ } finally {
612
+ setIsRejecting(false);
613
+ }
614
+ };
615
+ const handleCreateExchange = async () => {
616
+ if (!id) {
617
+ return;
618
+ }
619
+ try {
620
+ setIsCreatingExchange(true);
621
+ setExchangeError(null);
622
+ setExchangeSuccess(false);
623
+ const response = await fetch(`/admin/swaps/${id}/confirm-exchange`, {
624
+ method: "POST",
625
+ headers: {
626
+ "Content-Type": "application/json"
627
+ },
628
+ credentials: "include",
629
+ body: JSON.stringify({
630
+ send_notification: sendNotification
631
+ })
632
+ });
633
+ if (!response.ok) {
634
+ const errorData = await response.json().catch(() => ({ message: "Failed to create exchange" }));
635
+ throw new Error(errorData.message || errorData.error || "Failed to create exchange");
636
+ }
637
+ const result = await response.json();
638
+ setSwap(result.swap);
639
+ setExchangeSuccess(true);
640
+ setTimeout(() => setExchangeSuccess(false), 5e3);
641
+ const detailResponse = await fetch(`/admin/swaps/${id}`, {
642
+ credentials: "include"
643
+ });
644
+ if (detailResponse.ok) {
645
+ const detailPayload = await detailResponse.json();
646
+ setSwap(detailPayload.swap);
647
+ setOrder(detailPayload.order || null);
648
+ }
649
+ } catch (createErr) {
650
+ const message = createErr instanceof Error ? createErr.message : "Unable to create exchange";
651
+ setExchangeError(message);
652
+ } finally {
653
+ setIsCreatingExchange(false);
654
+ }
655
+ };
656
+ if (isLoading) {
657
+ 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..." }) }) }) });
658
+ }
659
+ if (error || !swap) {
660
+ 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: [
661
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
662
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
663
+ ] }) }) });
664
+ }
665
+ const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
666
+ 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: [
667
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
668
+ /* @__PURE__ */ jsxs(
669
+ Button,
670
+ {
671
+ variant: "transparent",
672
+ size: "small",
673
+ onClick: () => navigate("/swaps"),
674
+ className: "w-fit",
675
+ children: [
676
+ /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
677
+ "Back to list"
678
+ ]
679
+ }
680
+ ),
681
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
682
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
683
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Swap Details" }),
684
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
685
+ ] }),
686
+ /* @__PURE__ */ jsx(
687
+ Badge,
688
+ {
689
+ size: "small",
690
+ className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
691
+ children: swap.status.replace(/_/g, " ")
692
+ }
693
+ )
694
+ ] })
695
+ ] }),
696
+ swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
697
+ /* @__PURE__ */ jsx(
698
+ Button,
699
+ {
700
+ variant: "primary",
701
+ onClick: handleApprove,
702
+ disabled: isApproving || isRejecting,
703
+ isLoading: isApproving,
704
+ children: "Approve Swap"
705
+ }
706
+ ),
707
+ /* @__PURE__ */ jsx(
708
+ Button,
709
+ {
710
+ variant: "secondary",
711
+ onClick: handleReject,
712
+ disabled: isApproving || isRejecting,
713
+ isLoading: isRejecting,
714
+ children: "Reject Swap"
715
+ }
716
+ )
717
+ ] }),
718
+ swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
719
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
720
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
721
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
722
+ /* @__PURE__ */ jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
723
+ /* @__PURE__ */ jsxs(
724
+ "select",
725
+ {
726
+ value: selectedStatus,
727
+ onChange: (event) => setSelectedStatus(event.target.value),
728
+ 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",
729
+ children: [
730
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select new status" }),
731
+ availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
732
+ ]
733
+ }
734
+ )
735
+ ] }),
593
736
  /* @__PURE__ */ jsx(
594
737
  Button,
595
738
  {
@@ -604,37 +747,139 @@ const ReturnDetailPage = () => {
604
747
  updateError && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
605
748
  updateSuccess && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
606
749
  ] }),
750
+ swap.status === "approved" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
751
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
752
+ swap.exchange_id ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
753
+ /* @__PURE__ */ jsxs("div", { children: [
754
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
755
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
756
+ ] }),
757
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
758
+ Button,
759
+ {
760
+ variant: "secondary",
761
+ onClick: () => {
762
+ window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
763
+ },
764
+ children: "View Exchange"
765
+ }
766
+ ) })
767
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
768
+ swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
769
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "mb-3 text-base", children: "Return Items (Inbound)" }),
770
+ /* @__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: [
771
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
772
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item" }),
773
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
774
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
775
+ ] }) }),
776
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle bg-ui-bg-base", children: swap.return_items.map((item, index) => {
777
+ var _a2;
778
+ const orderItem = (_a2 = order == null ? void 0 : order.items) == null ? void 0 : _a2.find((oi) => oi.id === item.id);
779
+ return /* @__PURE__ */ jsxs("tr", { children: [
780
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: (orderItem == null ? void 0 : orderItem.title) || item.id }),
781
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
782
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
783
+ ] }, item.id || index);
784
+ }) })
785
+ ] }) })
786
+ ] }),
787
+ swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
788
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "mb-3 text-base", children: "New Items (Outbound)" }),
789
+ /* @__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: [
790
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
791
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Product/Variant" }),
792
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
793
+ ] }) }),
794
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle bg-ui-bg-base", children: swap.new_items.map((item, index) => {
795
+ var _a2;
796
+ const orderItem = (_a2 = order == null ? void 0 : order.items) == null ? void 0 : _a2.find((oi) => oi.variant_id === item.variant_id);
797
+ return /* @__PURE__ */ jsxs("tr", { children: [
798
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: (orderItem == null ? void 0 : orderItem.title) || item.variant_id }),
799
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
800
+ ] }, item.variant_id || index);
801
+ }) })
802
+ ] }) })
803
+ ] }),
804
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-lg border border-ui-border-base bg-ui-bg-subtle p-4", children: [
805
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-base", children: "Exchange Details" }),
806
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-3 md:grid-cols-2", children: [
807
+ /* @__PURE__ */ jsxs("div", { children: [
808
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return Location" }),
809
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.return_location_id || "—" })
810
+ ] }),
811
+ /* @__PURE__ */ jsxs("div", { children: [
812
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return Shipping Method" }),
813
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.return_shipping_method_id || "—" })
814
+ ] }),
815
+ /* @__PURE__ */ jsxs("div", { children: [
816
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Outbound Shipping Method" }),
817
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.outbound_shipping_method_id || "—" })
818
+ ] })
819
+ ] })
820
+ ] }),
821
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
822
+ /* @__PURE__ */ jsx(
823
+ "input",
824
+ {
825
+ type: "checkbox",
826
+ id: "send-notification",
827
+ checked: sendNotification,
828
+ onChange: (e) => setSendNotification(e.target.checked),
829
+ className: "h-4 w-4 rounded border-ui-border-base text-ui-fg-interactive focus:ring-2 focus:ring-ui-fg-interactive"
830
+ }
831
+ ),
832
+ /* @__PURE__ */ jsx("label", { htmlFor: "send-notification", className: "cursor-pointer", children: /* @__PURE__ */ jsx(Text, { size: "small", children: "Send notification to customer about exchange" }) })
833
+ ] }),
834
+ exchangeError && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-error bg-ui-bg-error-subtle p-3", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-error", children: exchangeError }) }),
835
+ exchangeSuccess && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-3", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-success", children: "Exchange created successfully!" }) }),
836
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
837
+ Button,
838
+ {
839
+ variant: "primary",
840
+ onClick: handleCreateExchange,
841
+ disabled: isCreatingExchange,
842
+ isLoading: isCreatingExchange,
843
+ children: "Confirm & Create Exchange"
844
+ }
845
+ ) })
846
+ ] })
847
+ ] }),
607
848
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
608
849
  /* @__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" }),
850
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
610
851
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
611
852
  /* @__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 })
853
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
854
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
614
855
  ] }),
615
856
  /* @__PURE__ */ jsxs("div", { children: [
616
857
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
617
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
858
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
618
859
  ] }),
619
860
  /* @__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)}` : "—" })
861
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
862
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
622
863
  ] }),
623
- returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
864
+ swap.reason && /* @__PURE__ */ jsxs("div", { children: [
624
865
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
625
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
866
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
626
867
  ] }),
627
- returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
868
+ swap.note && /* @__PURE__ */ jsxs("div", { children: [
628
869
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
629
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
870
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
630
871
  ] }),
631
872
  /* @__PURE__ */ jsxs("div", { children: [
632
873
  /* @__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() })
874
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
634
875
  ] }),
635
876
  /* @__PURE__ */ jsxs("div", { children: [
636
877
  /* @__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() })
878
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
879
+ ] }),
880
+ swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
881
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
882
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
638
883
  ] })
639
884
  ] })
640
885
  ] }),
@@ -645,23 +890,18 @@ const ReturnDetailPage = () => {
645
890
  {
646
891
  className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
647
892
  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
- ] }),
893
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
894
+ Badge,
895
+ {
896
+ size: "2xsmall",
897
+ className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
898
+ children: entry.status.replace(/_/g, " ")
899
+ }
900
+ ) }),
662
901
  /* @__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}`
902
+ new Date(entry.timestamp).toLocaleString(),
903
+ entry.admin_id && ` by ${entry.admin_id}`,
904
+ entry.reason && ` - ${entry.reason}`
665
905
  ] })
666
906
  ] })
667
907
  },
@@ -669,76 +909,62 @@ const ReturnDetailPage = () => {
669
909
  )) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
670
910
  ] })
671
911
  ] }),
672
- returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
912
+ order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
673
913
  /* @__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
- ] })
914
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
915
+ /* @__PURE__ */ jsxs("div", { children: [
916
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
917
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
692
918
  ] }),
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() : "—" })
919
+ /* @__PURE__ */ jsxs("div", { children: [
920
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
921
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "" })
922
+ ] }),
923
+ /* @__PURE__ */ jsxs("div", { children: [
924
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
925
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
926
+ ] }),
927
+ order.total && /* @__PURE__ */ jsxs("div", { children: [
928
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
929
+ /* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
930
+ order.currency_code || "$",
931
+ (Number(order.total) / 100).toFixed(2)
709
932
  ] })
710
933
  ] })
711
934
  ] })
712
935
  ] }),
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: [
936
+ 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: [
714
937
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
715
938
  /* @__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
939
  /* @__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" })
940
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
941
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
942
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
719
943
  ] }) }),
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
- }) })
944
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
945
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
946
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
947
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
948
+ ] }, item.id || index)) })
727
949
  ] }) })
728
950
  ] }),
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)) })
951
+ 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: [
952
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
953
+ /* @__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: [
954
+ /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
955
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
956
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
957
+ ] }) }),
958
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
959
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
960
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
961
+ ] }, item.variant_id || index)) })
962
+ ] }) })
737
963
  ] })
738
964
  ] }) });
739
965
  };
740
966
  const config$1 = defineRouteConfig({
741
- label: "Return Order Details",
967
+ label: "Swap Details",
742
968
  icon: ArrowPath
743
969
  });
744
970
  const getStatusBadgeClass = (status) => {
@@ -746,63 +972,65 @@ const getStatusBadgeClass = (status) => {
746
972
  if (statusLower === "requested") {
747
973
  return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
748
974
  }
749
- if (statusLower === "approved") {
975
+ if (statusLower === "received") {
750
976
  return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
751
977
  }
752
- if (statusLower === "rejected") {
978
+ if (statusLower === "requires_action") {
753
979
  return "bg-ui-tag-red-bg text-ui-tag-red-text";
754
980
  }
755
981
  if (statusLower === "completed") {
756
982
  return "bg-ui-tag-green-bg text-ui-tag-green-text";
757
983
  }
758
- if (statusLower === "cancelled") {
984
+ if (statusLower === "canceled") {
759
985
  return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
760
986
  }
761
987
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
762
988
  };
763
- const SwapDetailPage = () => {
764
- var _a, _b;
989
+ const ReturnDetailPage = () => {
990
+ var _a, _b, _c;
765
991
  const navigate = useNavigate();
766
992
  const { id } = useParams();
767
- const [swap, setSwap] = useState(null);
768
- const [order, setOrder] = useState(null);
993
+ const [returnOrder, setReturnOrder] = useState(null);
769
994
  const [selectedStatus, setSelectedStatus] = useState("");
770
995
  const [isLoading, setIsLoading] = useState(true);
771
996
  const [isUpdating, setIsUpdating] = useState(false);
772
- const [isApproving, setIsApproving] = useState(false);
773
- const [isRejecting, setIsRejecting] = useState(false);
774
997
  const [error, setError] = useState(null);
775
998
  const [updateError, setUpdateError] = useState(null);
776
999
  const [updateSuccess, setUpdateSuccess] = useState(false);
777
- const availableStatuses = ["requested", "approved", "rejected"];
1000
+ const availableStatuses = [
1001
+ "requested",
1002
+ "received",
1003
+ "requires_action",
1004
+ "completed",
1005
+ "canceled"
1006
+ ];
778
1007
  useEffect(() => {
779
1008
  if (!id) {
780
- navigate("/swaps");
1009
+ navigate("/returns");
781
1010
  return;
782
1011
  }
783
- const loadSwap = async () => {
1012
+ const loadReturn = async () => {
784
1013
  try {
785
1014
  setIsLoading(true);
786
1015
  setError(null);
787
- const response = await fetch(`/admin/swaps/${id}`, {
1016
+ const response = await fetch(`/admin/returns/${id}`, {
788
1017
  credentials: "include"
789
1018
  });
790
1019
  if (!response.ok) {
791
1020
  const message = await response.text();
792
- throw new Error(message || "Unable to load swap");
1021
+ throw new Error(message || "Unable to load return order");
793
1022
  }
794
1023
  const payload = await response.json();
795
- setSwap(payload.swap);
796
- setOrder(payload.order || null);
1024
+ setReturnOrder(payload.return);
797
1025
  setSelectedStatus("");
798
1026
  } catch (loadError) {
799
- const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
1027
+ const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
800
1028
  setError(message);
801
1029
  } finally {
802
1030
  setIsLoading(false);
803
1031
  }
804
1032
  };
805
- void loadSwap();
1033
+ void loadReturn();
806
1034
  }, [id, navigate]);
807
1035
  const handleStatusUpdate = async () => {
808
1036
  if (!id || !selectedStatus) {
@@ -812,125 +1040,47 @@ const SwapDetailPage = () => {
812
1040
  setIsUpdating(true);
813
1041
  setUpdateError(null);
814
1042
  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);
839
- }
840
- } catch (updateErr) {
841
- const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
842
- setUpdateError(message);
843
- } finally {
844
- setIsUpdating(false);
845
- }
846
- };
847
- const handleApprove = async () => {
848
- if (!id) {
849
- return;
850
- }
851
- try {
852
- setIsApproving(true);
853
- setUpdateError(null);
854
- setUpdateSuccess(false);
855
- const response = await fetch(`/admin/swaps/${id}/approve`, {
856
- method: "POST",
857
- headers: {
858
- "Content-Type": "application/json"
859
- },
860
- credentials: "include"
861
- });
862
- if (!response.ok) {
863
- const message = await response.text();
864
- throw new Error(message || "Unable to approve swap");
865
- }
866
- const payload = await response.json();
867
- setSwap(payload.swap);
868
- setUpdateSuccess(true);
869
- setTimeout(() => setUpdateSuccess(false), 5e3);
870
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
871
- credentials: "include"
872
- });
873
- if (detailResponse.ok) {
874
- const detailPayload = await detailResponse.json();
875
- setSwap(detailPayload.swap);
876
- setOrder(detailPayload.order || null);
877
- }
878
- } catch (updateErr) {
879
- const message = updateErr instanceof Error ? updateErr.message : "Unable to approve swap";
880
- setUpdateError(message);
881
- } finally {
882
- setIsApproving(false);
883
- }
884
- };
885
- const handleReject = async () => {
886
- if (!id) {
887
- return;
888
- }
889
- try {
890
- setIsRejecting(true);
891
- setUpdateError(null);
892
- setUpdateSuccess(false);
893
- const response = await fetch(`/admin/swaps/${id}/reject`, {
1043
+ const response = await fetch(`/admin/returns/${id}/status`, {
894
1044
  method: "POST",
895
1045
  headers: {
896
1046
  "Content-Type": "application/json"
897
1047
  },
898
1048
  credentials: "include",
899
- body: JSON.stringify({ reason: "Rejected by admin" })
1049
+ body: JSON.stringify({ status: selectedStatus })
900
1050
  });
901
1051
  if (!response.ok) {
902
1052
  const message = await response.text();
903
- throw new Error(message || "Unable to reject swap");
1053
+ throw new Error(message || "Unable to update status");
904
1054
  }
905
1055
  const payload = await response.json();
906
- setSwap(payload.swap);
1056
+ setReturnOrder(payload.return);
1057
+ setSelectedStatus("");
907
1058
  setUpdateSuccess(true);
908
1059
  setTimeout(() => setUpdateSuccess(false), 3e3);
909
- const detailResponse = await fetch(`/admin/swaps/${id}`, {
1060
+ const detailResponse = await fetch(`/admin/returns/${id}`, {
910
1061
  credentials: "include"
911
1062
  });
912
1063
  if (detailResponse.ok) {
913
- const detailPayload = await response.json();
914
- setSwap(detailPayload.swap);
915
- setOrder(detailPayload.order || null);
1064
+ const detailPayload = await detailResponse.json();
1065
+ setReturnOrder(detailPayload.return);
916
1066
  }
917
1067
  } catch (updateErr) {
918
- const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
1068
+ const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
919
1069
  setUpdateError(message);
920
1070
  } finally {
921
- setIsRejecting(false);
1071
+ setIsUpdating(false);
922
1072
  }
923
1073
  };
924
1074
  if (isLoading) {
925
- return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx(Text, { children: "Loading swap..." }) }) }) });
1075
+ 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..." }) }) }) });
926
1076
  }
927
- if (error || !swap) {
1077
+ if (error || !returnOrder) {
928
1078
  return /* @__PURE__ */ jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsx(Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
929
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
930
- /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
1079
+ /* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
1080
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
931
1081
  ] }) }) });
932
1082
  }
933
- const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
1083
+ const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
934
1084
  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: [
935
1085
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
936
1086
  /* @__PURE__ */ jsxs(
@@ -938,7 +1088,7 @@ const SwapDetailPage = () => {
938
1088
  {
939
1089
  variant: "transparent",
940
1090
  size: "small",
941
- onClick: () => navigate("/swaps"),
1091
+ onClick: () => navigate("/returns"),
942
1092
  className: "w-fit",
943
1093
  children: [
944
1094
  /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
@@ -948,42 +1098,20 @@ const SwapDetailPage = () => {
948
1098
  ),
949
1099
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
950
1100
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
951
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Swap Details" }),
952
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
1101
+ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
1102
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
953
1103
  ] }),
954
1104
  /* @__PURE__ */ jsx(
955
1105
  Badge,
956
1106
  {
957
1107
  size: "small",
958
- className: `uppercase ${getStatusBadgeClass(swap.status)}`,
959
- children: swap.status.replace(/_/g, " ")
1108
+ className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
1109
+ children: returnOrder.status.replace("_", " ")
960
1110
  }
961
1111
  )
962
1112
  ] })
963
1113
  ] }),
964
- swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
965
- /* @__PURE__ */ jsx(
966
- Button,
967
- {
968
- variant: "primary",
969
- onClick: handleApprove,
970
- disabled: isApproving || isRejecting,
971
- isLoading: isApproving,
972
- children: "Approve Swap"
973
- }
974
- ),
975
- /* @__PURE__ */ jsx(
976
- Button,
977
- {
978
- variant: "secondary",
979
- onClick: handleReject,
980
- disabled: isApproving || isRejecting,
981
- isLoading: isRejecting,
982
- children: "Reject Swap"
983
- }
984
- )
985
- ] }),
986
- swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1114
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
987
1115
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
988
1116
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
989
1117
  /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
@@ -996,7 +1124,7 @@ const SwapDetailPage = () => {
996
1124
  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",
997
1125
  children: [
998
1126
  /* @__PURE__ */ jsx("option", { value: "", children: "Select new status" }),
999
- availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
1127
+ availableStatuses.filter((status) => status !== returnOrder.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace("_", " ").toUpperCase() }, status))
1000
1128
  ]
1001
1129
  }
1002
1130
  )
@@ -1015,73 +1143,37 @@ const SwapDetailPage = () => {
1015
1143
  updateError && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
1016
1144
  updateSuccess && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
1017
1145
  ] }),
1018
- swap.status === "approved" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1019
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
1020
- swap.exchange_id ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1021
- /* @__PURE__ */ jsxs("div", { children: [
1022
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1023
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
1024
- ] }),
1025
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1026
- Button,
1027
- {
1028
- variant: "secondary",
1029
- onClick: () => {
1030
- window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
1031
- },
1032
- children: "View Exchange"
1033
- }
1034
- ) })
1035
- ] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1036
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap approved. Please create the exchange using Medusa's exchange creation form." }),
1037
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1038
- Button,
1039
- {
1040
- variant: "primary",
1041
- onClick: () => {
1042
- window.open(`/app/orders/${swap.order_id}/exchanges`, "_blank");
1043
- },
1044
- children: "Create Exchange"
1045
- }
1046
- ) }),
1047
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "The exchange will be automatically linked to this swap once created." })
1048
- ] })
1049
- ] }),
1050
1146
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1051
1147
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1052
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
1148
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
1053
1149
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1054
1150
  /* @__PURE__ */ jsxs("div", { children: [
1055
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
1056
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
1151
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
1152
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
1057
1153
  ] }),
1058
1154
  /* @__PURE__ */ jsxs("div", { children: [
1059
1155
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
1060
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
1156
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
1061
1157
  ] }),
1062
1158
  /* @__PURE__ */ jsxs("div", { children: [
1063
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
1064
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
1159
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund Amount" }),
1160
+ /* @__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)}` : "—" })
1065
1161
  ] }),
1066
- swap.reason && /* @__PURE__ */ jsxs("div", { children: [
1162
+ returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
1067
1163
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
1068
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
1164
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
1069
1165
  ] }),
1070
- swap.note && /* @__PURE__ */ jsxs("div", { children: [
1166
+ returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
1071
1167
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
1072
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
1168
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
1073
1169
  ] }),
1074
1170
  /* @__PURE__ */ jsxs("div", { children: [
1075
1171
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
1076
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
1172
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
1077
1173
  ] }),
1078
1174
  /* @__PURE__ */ jsxs("div", { children: [
1079
1175
  /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
1080
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
1081
- ] }),
1082
- swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
1083
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
1084
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
1176
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
1085
1177
  ] })
1086
1178
  ] })
1087
1179
  ] }),
@@ -1092,18 +1184,23 @@ const SwapDetailPage = () => {
1092
1184
  {
1093
1185
  className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
1094
1186
  children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
1095
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
1096
- Badge,
1097
- {
1098
- size: "2xsmall",
1099
- className: `uppercase ${getStatusBadgeClass(entry.status)}`,
1100
- children: entry.status.replace(/_/g, " ")
1101
- }
1102
- ) }),
1187
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1188
+ /* @__PURE__ */ jsx(
1189
+ Badge,
1190
+ {
1191
+ size: "2xsmall",
1192
+ className: `uppercase ${getStatusBadgeClass(entry.to)}`,
1193
+ children: entry.to.replace("_", " ")
1194
+ }
1195
+ ),
1196
+ entry.from && /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
1197
+ "from ",
1198
+ entry.from.replace("_", " ")
1199
+ ] })
1200
+ ] }),
1103
1201
  /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
1104
- new Date(entry.timestamp).toLocaleString(),
1105
- entry.admin_id && ` by ${entry.admin_id}`,
1106
- entry.reason && ` - ${entry.reason}`
1202
+ new Date(entry.changed_at).toLocaleString(),
1203
+ entry.changed_by && ` by ${entry.changed_by}`
1107
1204
  ] })
1108
1205
  ] })
1109
1206
  },
@@ -1111,83 +1208,97 @@ const SwapDetailPage = () => {
1111
1208
  )) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
1112
1209
  ] })
1113
1210
  ] }),
1114
- order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1211
+ returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1115
1212
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
1116
- /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1117
- /* @__PURE__ */ jsxs("div", { children: [
1118
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1119
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
1120
- ] }),
1121
- /* @__PURE__ */ jsxs("div", { children: [
1122
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1123
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
1124
- ] }),
1125
- /* @__PURE__ */ jsxs("div", { children: [
1126
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1127
- /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "" })
1213
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1214
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1215
+ /* @__PURE__ */ jsxs("div", { children: [
1216
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
1217
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
1218
+ ] }),
1219
+ /* @__PURE__ */ jsxs("div", { children: [
1220
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
1221
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
1222
+ ] }),
1223
+ /* @__PURE__ */ jsxs("div", { children: [
1224
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
1225
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = returnOrder.order.customer) == null ? void 0 : _c.email) || returnOrder.order.email || "—" })
1226
+ ] }),
1227
+ /* @__PURE__ */ jsxs("div", { children: [
1228
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1229
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.total).toFixed(2)}` : "—" })
1230
+ ] })
1128
1231
  ] }),
1129
- order.total && /* @__PURE__ */ jsxs("div", { children: [
1130
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
1131
- /* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
1132
- order.currency_code || "$",
1133
- (Number(order.total) / 100).toFixed(2)
1232
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
1233
+ /* @__PURE__ */ jsxs("div", { children: [
1234
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Subtotal" }),
1235
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.subtotal ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.subtotal).toFixed(2)}` : "—" })
1236
+ ] }),
1237
+ /* @__PURE__ */ jsxs("div", { children: [
1238
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Tax Total" }),
1239
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.tax_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.tax_total).toFixed(2)}` : "—" })
1240
+ ] }),
1241
+ /* @__PURE__ */ jsxs("div", { children: [
1242
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Shipping Total" }),
1243
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.shipping_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.shipping_total).toFixed(2)}` : "—" })
1244
+ ] }),
1245
+ /* @__PURE__ */ jsxs("div", { children: [
1246
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Created" }),
1247
+ /* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.created_at ? new Date(returnOrder.order.created_at).toLocaleString() : "—" })
1134
1248
  ] })
1135
1249
  ] })
1136
1250
  ] })
1137
1251
  ] }),
1138
- swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1252
+ returnOrder.items && returnOrder.items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1139
1253
  /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
1140
1254
  /* @__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: [
1141
1255
  /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
1142
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
1143
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
1144
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
1145
- ] }) }),
1146
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
1147
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
1148
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
1149
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
1150
- ] }, item.id || index)) })
1151
- ] }) })
1152
- ] }),
1153
- swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1154
- /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
1155
- /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
1156
- /* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
1157
- /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
1256
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item" }),
1158
1257
  /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
1159
1258
  ] }) }),
1160
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
1161
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
1162
- /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1163
- ] }, item.variant_id || index)) })
1259
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.items.map((item) => {
1260
+ var _a2, _b2;
1261
+ return /* @__PURE__ */ jsxs("tr", { children: [
1262
+ /* @__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 }),
1263
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
1264
+ ] }, item.id);
1265
+ }) })
1164
1266
  ] }) })
1267
+ ] }),
1268
+ returnOrder.metadata && Object.keys(returnOrder.metadata).filter(
1269
+ (key) => key !== "status_history"
1270
+ ).length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
1271
+ /* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Metadata" }),
1272
+ /* @__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: [
1273
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: key }),
1274
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "font-medium", children: typeof value === "string" ? value : JSON.stringify(value) })
1275
+ ] }, key)) })
1165
1276
  ] })
1166
1277
  ] }) });
1167
1278
  };
1168
1279
  const config = defineRouteConfig({
1169
- label: "Swap Details",
1280
+ label: "Return Order Details",
1170
1281
  icon: ArrowPath
1171
1282
  });
1172
1283
  const i18nTranslations0 = {};
1173
1284
  const widgetModule = { widgets: [] };
1174
1285
  const routeModule = {
1175
1286
  routes: [
1176
- {
1177
- Component: ReturnsPage,
1178
- path: "/returns"
1179
- },
1180
1287
  {
1181
1288
  Component: SwapsPage,
1182
1289
  path: "/swaps"
1183
1290
  },
1184
1291
  {
1185
- Component: ReturnDetailPage,
1186
- path: "/returns/:id"
1292
+ Component: ReturnsPage,
1293
+ path: "/returns"
1187
1294
  },
1188
1295
  {
1189
1296
  Component: SwapDetailPage,
1190
1297
  path: "/swaps/:id"
1298
+ },
1299
+ {
1300
+ Component: ReturnDetailPage,
1301
+ path: "/returns/:id"
1191
1302
  }
1192
1303
  ]
1193
1304
  };
@@ -1196,25 +1307,25 @@ const menuItemModule = {
1196
1307
  {
1197
1308
  label: config$3.label,
1198
1309
  icon: config$3.icon,
1199
- path: "/returns",
1310
+ path: "/swaps",
1200
1311
  nested: void 0
1201
1312
  },
1202
1313
  {
1203
1314
  label: config$2.label,
1204
1315
  icon: config$2.icon,
1205
- path: "/swaps",
1316
+ path: "/returns",
1206
1317
  nested: void 0
1207
1318
  },
1208
1319
  {
1209
1320
  label: config$1.label,
1210
1321
  icon: config$1.icon,
1211
- path: "/returns/:id",
1322
+ path: "/swaps/:id",
1212
1323
  nested: void 0
1213
1324
  },
1214
1325
  {
1215
1326
  label: config.label,
1216
1327
  icon: config.icon,
1217
- path: "/swaps/:id",
1328
+ path: "/returns/:id",
1218
1329
  nested: void 0
1219
1330
  }
1220
1331
  ]