order-management 0.0.22 → 0.0.23

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