order-management 0.0.27 → 0.0.28
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.
- package/.medusa/server/src/admin/index.js +402 -427
- package/.medusa/server/src/admin/index.mjs +402 -427
- package/.medusa/server/src/api/admin/swaps/route.js +9 -1
- package/.medusa/server/src/subscribers/exchange-created.js +196 -183
- package/.medusa/server/src/workflows/steps/swap/create-medusa-exchange-step.js +41 -1
- package/package.json +1 -1
- package/.medusa/server/src/api/admin/swaps/[id]/prepare-exchange/route.js +0 -84
|
@@ -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 === "
|
|
20
|
+
if (statusLower === "approved") {
|
|
21
21
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
22
22
|
}
|
|
23
|
-
if (statusLower === "
|
|
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 === "
|
|
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
|
|
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
|
|
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("
|
|
63
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
64
64
|
}
|
|
65
|
-
params.set("order", "created_at");
|
|
66
65
|
const response = await fetch(
|
|
67
|
-
`/admin/
|
|
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
|
|
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.
|
|
75
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
77
76
|
setItems(
|
|
78
|
-
(prev) => replace ? payload.
|
|
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
|
|
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
|
|
92
|
-
}, [statusFilter, debouncedSearchQuery,
|
|
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: "
|
|
103
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer
|
|
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: () =>
|
|
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
|
|
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: () =>
|
|
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
|
|
142
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No
|
|
143
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
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: "
|
|
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: "
|
|
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((
|
|
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(`/
|
|
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:
|
|
161
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
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(
|
|
168
|
-
children:
|
|
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 =
|
|
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 =
|
|
178
|
-
|
|
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(
|
|
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(`/
|
|
193
|
+
navigate(`/swaps/${swap.id}`);
|
|
196
194
|
},
|
|
197
195
|
children: "View"
|
|
198
196
|
}
|
|
199
197
|
) })
|
|
200
198
|
]
|
|
201
199
|
},
|
|
202
|
-
|
|
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: () =>
|
|
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: "
|
|
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 === "
|
|
231
|
+
if (statusLower === "received") {
|
|
234
232
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
235
233
|
}
|
|
236
|
-
if (statusLower === "
|
|
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 === "
|
|
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
|
|
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
|
|
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("
|
|
274
|
+
params.set("q", debouncedSearchQuery.trim());
|
|
277
275
|
}
|
|
276
|
+
params.set("order", "created_at");
|
|
278
277
|
const response = await fetch(
|
|
279
|
-
`/admin/
|
|
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
|
|
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.
|
|
287
|
+
setOffset(nextOffset + (((_a = payload.returns) == null ? void 0 : _a.length) ?? 0));
|
|
289
288
|
setItems(
|
|
290
|
-
(prev) => replace ? payload.
|
|
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
|
|
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
|
|
304
|
-
}, [statusFilter, debouncedSearchQuery,
|
|
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: "
|
|
315
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer
|
|
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: () =>
|
|
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
|
|
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: () =>
|
|
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
|
|
354
|
-
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-xl", children: "No
|
|
355
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "
|
|
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: "
|
|
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: "
|
|
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((
|
|
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(`/
|
|
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:
|
|
372
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children:
|
|
371
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx("span", { children: returnOrder.id }) }) }),
|
|
372
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.order_id }),
|
|
373
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: returnOrder.customer_email || returnOrder.order_email || "—" }),
|
|
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(
|
|
378
|
-
children:
|
|
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 =
|
|
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 =
|
|
388
|
-
|
|
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(
|
|
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(`/
|
|
406
|
+
navigate(`/returns/${returnOrder.id}`);
|
|
407
407
|
},
|
|
408
408
|
children: "View"
|
|
409
409
|
}
|
|
410
410
|
) })
|
|
411
411
|
]
|
|
412
412
|
},
|
|
413
|
-
|
|
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: () =>
|
|
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: "
|
|
428
|
+
label: "Return Orders",
|
|
429
429
|
icon: ArrowPath
|
|
430
430
|
});
|
|
431
431
|
const getStatusBadgeClass$1 = (status) => {
|
|
@@ -433,65 +433,63 @@ const getStatusBadgeClass$1 = (status) => {
|
|
|
433
433
|
if (statusLower === "requested") {
|
|
434
434
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
435
435
|
}
|
|
436
|
-
if (statusLower === "
|
|
436
|
+
if (statusLower === "approved") {
|
|
437
437
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
438
438
|
}
|
|
439
|
-
if (statusLower === "
|
|
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 === "
|
|
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
|
|
451
|
-
var _a, _b
|
|
450
|
+
const SwapDetailPage = () => {
|
|
451
|
+
var _a, _b;
|
|
452
452
|
const navigate = useNavigate();
|
|
453
453
|
const { id } = useParams();
|
|
454
|
-
const [
|
|
454
|
+
const [swap, setSwap] = useState(null);
|
|
455
|
+
const [order, setOrder] = useState(null);
|
|
455
456
|
const [selectedStatus, setSelectedStatus] = useState("");
|
|
456
457
|
const [isLoading, setIsLoading] = useState(true);
|
|
457
458
|
const [isUpdating, setIsUpdating] = useState(false);
|
|
459
|
+
const [isApproving, setIsApproving] = useState(false);
|
|
460
|
+
const [isRejecting, setIsRejecting] = useState(false);
|
|
458
461
|
const [error, setError] = useState(null);
|
|
459
462
|
const [updateError, setUpdateError] = useState(null);
|
|
460
463
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
461
|
-
const availableStatuses = [
|
|
462
|
-
"requested",
|
|
463
|
-
"received",
|
|
464
|
-
"requires_action",
|
|
465
|
-
"completed",
|
|
466
|
-
"canceled"
|
|
467
|
-
];
|
|
464
|
+
const availableStatuses = ["requested", "approved", "rejected"];
|
|
468
465
|
useEffect(() => {
|
|
469
466
|
if (!id) {
|
|
470
|
-
navigate("/
|
|
467
|
+
navigate("/swaps");
|
|
471
468
|
return;
|
|
472
469
|
}
|
|
473
|
-
const
|
|
470
|
+
const loadSwap = async () => {
|
|
474
471
|
try {
|
|
475
472
|
setIsLoading(true);
|
|
476
473
|
setError(null);
|
|
477
|
-
const response = await fetch(`/admin/
|
|
474
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
478
475
|
credentials: "include"
|
|
479
476
|
});
|
|
480
477
|
if (!response.ok) {
|
|
481
478
|
const message = await response.text();
|
|
482
|
-
throw new Error(message || "Unable to load
|
|
479
|
+
throw new Error(message || "Unable to load swap");
|
|
483
480
|
}
|
|
484
481
|
const payload = await response.json();
|
|
485
|
-
|
|
482
|
+
setSwap(payload.swap);
|
|
483
|
+
setOrder(payload.order || null);
|
|
486
484
|
setSelectedStatus("");
|
|
487
485
|
} catch (loadError) {
|
|
488
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
486
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
489
487
|
setError(message);
|
|
490
488
|
} finally {
|
|
491
489
|
setIsLoading(false);
|
|
492
490
|
}
|
|
493
491
|
};
|
|
494
|
-
void
|
|
492
|
+
void loadSwap();
|
|
495
493
|
}, [id, navigate]);
|
|
496
494
|
const handleStatusUpdate = async () => {
|
|
497
495
|
if (!id || !selectedStatus) {
|
|
@@ -501,7 +499,7 @@ const ReturnDetailPage = () => {
|
|
|
501
499
|
setIsUpdating(true);
|
|
502
500
|
setUpdateError(null);
|
|
503
501
|
setUpdateSuccess(false);
|
|
504
|
-
const response = await fetch(`/admin/
|
|
502
|
+
const response = await fetch(`/admin/swaps/${id}/status`, {
|
|
505
503
|
method: "POST",
|
|
506
504
|
headers: {
|
|
507
505
|
"Content-Type": "application/json"
|
|
@@ -514,16 +512,17 @@ const ReturnDetailPage = () => {
|
|
|
514
512
|
throw new Error(message || "Unable to update status");
|
|
515
513
|
}
|
|
516
514
|
const payload = await response.json();
|
|
517
|
-
|
|
515
|
+
setSwap(payload.swap);
|
|
518
516
|
setSelectedStatus("");
|
|
519
517
|
setUpdateSuccess(true);
|
|
520
518
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
521
|
-
const detailResponse = await fetch(`/admin/
|
|
519
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
522
520
|
credentials: "include"
|
|
523
521
|
});
|
|
524
522
|
if (detailResponse.ok) {
|
|
525
523
|
const detailPayload = await detailResponse.json();
|
|
526
|
-
|
|
524
|
+
setSwap(detailPayload.swap);
|
|
525
|
+
setOrder(detailPayload.order || null);
|
|
527
526
|
}
|
|
528
527
|
} catch (updateErr) {
|
|
529
528
|
const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
|
|
@@ -532,16 +531,65 @@ const ReturnDetailPage = () => {
|
|
|
532
531
|
setIsUpdating(false);
|
|
533
532
|
}
|
|
534
533
|
};
|
|
534
|
+
const handleApproveClick = async () => {
|
|
535
|
+
if (!id) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (!swap || !swap.order_id) {
|
|
539
|
+
setUpdateError("Swap must have an order_id to create exchange");
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
window.location.href = `/app/orders/${swap.order_id}/exchanges`;
|
|
543
|
+
};
|
|
544
|
+
const handleReject = async () => {
|
|
545
|
+
if (!id) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
try {
|
|
549
|
+
setIsRejecting(true);
|
|
550
|
+
setUpdateError(null);
|
|
551
|
+
setUpdateSuccess(false);
|
|
552
|
+
const response = await fetch(`/admin/swaps/${id}/reject`, {
|
|
553
|
+
method: "POST",
|
|
554
|
+
headers: {
|
|
555
|
+
"Content-Type": "application/json"
|
|
556
|
+
},
|
|
557
|
+
credentials: "include",
|
|
558
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
559
|
+
});
|
|
560
|
+
if (!response.ok) {
|
|
561
|
+
const message = await response.text();
|
|
562
|
+
throw new Error(message || "Unable to reject swap");
|
|
563
|
+
}
|
|
564
|
+
const payload = await response.json();
|
|
565
|
+
setSwap(payload.swap);
|
|
566
|
+
setUpdateSuccess(true);
|
|
567
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
568
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
569
|
+
credentials: "include"
|
|
570
|
+
});
|
|
571
|
+
if (detailResponse.ok) {
|
|
572
|
+
const detailPayload = await response.json();
|
|
573
|
+
setSwap(detailPayload.swap);
|
|
574
|
+
setOrder(detailPayload.order || null);
|
|
575
|
+
}
|
|
576
|
+
} catch (updateErr) {
|
|
577
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
|
|
578
|
+
setUpdateError(message);
|
|
579
|
+
} finally {
|
|
580
|
+
setIsRejecting(false);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
535
583
|
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
|
|
584
|
+
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..." }) }) }) });
|
|
537
585
|
}
|
|
538
|
-
if (error || !
|
|
586
|
+
if (error || !swap) {
|
|
539
587
|
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 || "
|
|
541
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
588
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
589
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
542
590
|
] }) }) });
|
|
543
591
|
}
|
|
544
|
-
const statusHistory = ((_a =
|
|
592
|
+
const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
|
|
545
593
|
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
594
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
547
595
|
/* @__PURE__ */ jsxs(
|
|
@@ -549,7 +597,7 @@ const ReturnDetailPage = () => {
|
|
|
549
597
|
{
|
|
550
598
|
variant: "transparent",
|
|
551
599
|
size: "small",
|
|
552
|
-
onClick: () => navigate("/
|
|
600
|
+
onClick: () => navigate("/swaps"),
|
|
553
601
|
className: "w-fit",
|
|
554
602
|
children: [
|
|
555
603
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -559,20 +607,42 @@ const ReturnDetailPage = () => {
|
|
|
559
607
|
),
|
|
560
608
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
561
609
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
562
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
563
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
610
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Swap Details" }),
|
|
611
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
564
612
|
] }),
|
|
565
613
|
/* @__PURE__ */ jsx(
|
|
566
614
|
Badge,
|
|
567
615
|
{
|
|
568
616
|
size: "small",
|
|
569
|
-
className: `uppercase ${getStatusBadgeClass$1(
|
|
570
|
-
children:
|
|
617
|
+
className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
|
|
618
|
+
children: swap.status.replace(/_/g, " ")
|
|
571
619
|
}
|
|
572
620
|
)
|
|
573
621
|
] })
|
|
574
622
|
] }),
|
|
575
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
623
|
+
swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
624
|
+
/* @__PURE__ */ jsx(
|
|
625
|
+
Button,
|
|
626
|
+
{
|
|
627
|
+
variant: "primary",
|
|
628
|
+
onClick: handleApproveClick,
|
|
629
|
+
disabled: isApproving || isRejecting,
|
|
630
|
+
isLoading: isApproving,
|
|
631
|
+
children: "Approve Swap"
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
/* @__PURE__ */ jsx(
|
|
635
|
+
Button,
|
|
636
|
+
{
|
|
637
|
+
variant: "secondary",
|
|
638
|
+
onClick: handleReject,
|
|
639
|
+
disabled: isApproving || isRejecting,
|
|
640
|
+
isLoading: isRejecting,
|
|
641
|
+
children: "Reject Swap"
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
] }),
|
|
645
|
+
swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
576
646
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
577
647
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
578
648
|
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
@@ -585,7 +655,7 @@ const ReturnDetailPage = () => {
|
|
|
585
655
|
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
656
|
children: [
|
|
587
657
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select new status" }),
|
|
588
|
-
availableStatuses.filter((status) => status !==
|
|
658
|
+
availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
589
659
|
]
|
|
590
660
|
}
|
|
591
661
|
)
|
|
@@ -604,37 +674,60 @@ const ReturnDetailPage = () => {
|
|
|
604
674
|
updateError && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
605
675
|
updateSuccess && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
606
676
|
] }),
|
|
677
|
+
swap.status === "approved" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
678
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
679
|
+
swap.exchange_id ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
680
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
681
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
682
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
683
|
+
] }),
|
|
684
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
685
|
+
Button,
|
|
686
|
+
{
|
|
687
|
+
variant: "secondary",
|
|
688
|
+
onClick: () => {
|
|
689
|
+
window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
|
|
690
|
+
},
|
|
691
|
+
children: "View Exchange"
|
|
692
|
+
}
|
|
693
|
+
) })
|
|
694
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
|
|
695
|
+
] }),
|
|
607
696
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
608
697
|
/* @__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: "
|
|
698
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
|
|
610
699
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
611
700
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
612
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
613
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
701
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
|
|
702
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.id })
|
|
614
703
|
] }),
|
|
615
704
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
616
705
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
617
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
706
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.status })
|
|
618
707
|
] }),
|
|
619
708
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
620
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
621
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
709
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
710
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
622
711
|
] }),
|
|
623
|
-
|
|
712
|
+
swap.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
624
713
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
625
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
714
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.reason })
|
|
626
715
|
] }),
|
|
627
|
-
|
|
716
|
+
swap.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
628
717
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
629
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
718
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.note })
|
|
630
719
|
] }),
|
|
631
720
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
632
721
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
633
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
722
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
634
723
|
] }),
|
|
635
724
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
636
725
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
637
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
726
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
727
|
+
] }),
|
|
728
|
+
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
729
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
730
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
638
731
|
] })
|
|
639
732
|
] })
|
|
640
733
|
] }),
|
|
@@ -645,23 +738,18 @@ const ReturnDetailPage = () => {
|
|
|
645
738
|
{
|
|
646
739
|
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
647
740
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
648
|
-
/* @__PURE__ */
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
),
|
|
657
|
-
entry.from && /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
658
|
-
"from ",
|
|
659
|
-
entry.from.replace("_", " ")
|
|
660
|
-
] })
|
|
661
|
-
] }),
|
|
741
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
742
|
+
Badge,
|
|
743
|
+
{
|
|
744
|
+
size: "2xsmall",
|
|
745
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
746
|
+
children: entry.status.replace(/_/g, " ")
|
|
747
|
+
}
|
|
748
|
+
) }),
|
|
662
749
|
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
663
|
-
new Date(entry.
|
|
664
|
-
entry.
|
|
750
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
751
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
752
|
+
entry.reason && ` - ${entry.reason}`
|
|
665
753
|
] })
|
|
666
754
|
] })
|
|
667
755
|
},
|
|
@@ -669,76 +757,62 @@ const ReturnDetailPage = () => {
|
|
|
669
757
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
670
758
|
] })
|
|
671
759
|
] }),
|
|
672
|
-
|
|
760
|
+
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
673
761
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
674
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
675
|
-
/* @__PURE__ */ jsxs("div", {
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
|
|
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
|
-
] })
|
|
762
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
763
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
764
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
765
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.id })
|
|
692
766
|
] }),
|
|
693
|
-
/* @__PURE__ */ jsxs("div", {
|
|
694
|
-
/* @__PURE__ */
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
/* @__PURE__ */
|
|
703
|
-
|
|
704
|
-
|
|
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() : "—" })
|
|
767
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
768
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
769
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: order.status || "—" })
|
|
770
|
+
] }),
|
|
771
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
772
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
773
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
|
|
774
|
+
] }),
|
|
775
|
+
order.total && /* @__PURE__ */ jsxs("div", { children: [
|
|
776
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
777
|
+
/* @__PURE__ */ jsxs(Text, { className: "font-medium", children: [
|
|
778
|
+
order.currency_code || "$",
|
|
779
|
+
(Number(order.total) / 100).toFixed(2)
|
|
709
780
|
] })
|
|
710
781
|
] })
|
|
711
782
|
] })
|
|
712
783
|
] }),
|
|
713
|
-
|
|
784
|
+
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
785
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
715
786
|
/* @__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
787
|
/* @__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" })
|
|
788
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
789
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
790
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
719
791
|
] }) }),
|
|
720
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
] }, item.id);
|
|
726
|
-
}) })
|
|
792
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
793
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
794
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
795
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
796
|
+
] }, item.id || index)) })
|
|
727
797
|
] }) })
|
|
728
798
|
] }),
|
|
729
|
-
|
|
730
|
-
(
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
799
|
+
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: [
|
|
800
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
801
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
802
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
803
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
804
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
805
|
+
] }) }),
|
|
806
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
807
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
808
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
809
|
+
] }, item.variant_id || index)) })
|
|
810
|
+
] }) })
|
|
737
811
|
] })
|
|
738
812
|
] }) });
|
|
739
813
|
};
|
|
740
814
|
const config$1 = defineRouteConfig({
|
|
741
|
-
label: "
|
|
815
|
+
label: "Swap Details",
|
|
742
816
|
icon: ArrowPath
|
|
743
817
|
});
|
|
744
818
|
const getStatusBadgeClass = (status) => {
|
|
@@ -746,63 +820,65 @@ const getStatusBadgeClass = (status) => {
|
|
|
746
820
|
if (statusLower === "requested") {
|
|
747
821
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
748
822
|
}
|
|
749
|
-
if (statusLower === "
|
|
823
|
+
if (statusLower === "received") {
|
|
750
824
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
751
825
|
}
|
|
752
|
-
if (statusLower === "
|
|
826
|
+
if (statusLower === "requires_action") {
|
|
753
827
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
754
828
|
}
|
|
755
829
|
if (statusLower === "completed") {
|
|
756
830
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
757
831
|
}
|
|
758
|
-
if (statusLower === "
|
|
832
|
+
if (statusLower === "canceled") {
|
|
759
833
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
760
834
|
}
|
|
761
835
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
762
836
|
};
|
|
763
|
-
const
|
|
764
|
-
var _a, _b;
|
|
837
|
+
const ReturnDetailPage = () => {
|
|
838
|
+
var _a, _b, _c;
|
|
765
839
|
const navigate = useNavigate();
|
|
766
840
|
const { id } = useParams();
|
|
767
|
-
const [
|
|
768
|
-
const [order, setOrder] = useState(null);
|
|
841
|
+
const [returnOrder, setReturnOrder] = useState(null);
|
|
769
842
|
const [selectedStatus, setSelectedStatus] = useState("");
|
|
770
843
|
const [isLoading, setIsLoading] = useState(true);
|
|
771
844
|
const [isUpdating, setIsUpdating] = useState(false);
|
|
772
|
-
const [isApproving, setIsApproving] = useState(false);
|
|
773
|
-
const [isRejecting, setIsRejecting] = useState(false);
|
|
774
845
|
const [error, setError] = useState(null);
|
|
775
846
|
const [updateError, setUpdateError] = useState(null);
|
|
776
847
|
const [updateSuccess, setUpdateSuccess] = useState(false);
|
|
777
|
-
const availableStatuses = [
|
|
848
|
+
const availableStatuses = [
|
|
849
|
+
"requested",
|
|
850
|
+
"received",
|
|
851
|
+
"requires_action",
|
|
852
|
+
"completed",
|
|
853
|
+
"canceled"
|
|
854
|
+
];
|
|
778
855
|
useEffect(() => {
|
|
779
856
|
if (!id) {
|
|
780
|
-
navigate("/
|
|
857
|
+
navigate("/returns");
|
|
781
858
|
return;
|
|
782
859
|
}
|
|
783
|
-
const
|
|
860
|
+
const loadReturn = async () => {
|
|
784
861
|
try {
|
|
785
862
|
setIsLoading(true);
|
|
786
863
|
setError(null);
|
|
787
|
-
const response = await fetch(`/admin/
|
|
864
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
788
865
|
credentials: "include"
|
|
789
866
|
});
|
|
790
867
|
if (!response.ok) {
|
|
791
868
|
const message = await response.text();
|
|
792
|
-
throw new Error(message || "Unable to load
|
|
869
|
+
throw new Error(message || "Unable to load return order");
|
|
793
870
|
}
|
|
794
871
|
const payload = await response.json();
|
|
795
|
-
|
|
796
|
-
setOrder(payload.order || null);
|
|
872
|
+
setReturnOrder(payload.return);
|
|
797
873
|
setSelectedStatus("");
|
|
798
874
|
} catch (loadError) {
|
|
799
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
875
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
800
876
|
setError(message);
|
|
801
877
|
} finally {
|
|
802
878
|
setIsLoading(false);
|
|
803
879
|
}
|
|
804
880
|
};
|
|
805
|
-
void
|
|
881
|
+
void loadReturn();
|
|
806
882
|
}, [id, navigate]);
|
|
807
883
|
const handleStatusUpdate = async () => {
|
|
808
884
|
if (!id || !selectedStatus) {
|
|
@@ -812,7 +888,7 @@ const SwapDetailPage = () => {
|
|
|
812
888
|
setIsUpdating(true);
|
|
813
889
|
setUpdateError(null);
|
|
814
890
|
setUpdateSuccess(false);
|
|
815
|
-
const response = await fetch(`/admin/
|
|
891
|
+
const response = await fetch(`/admin/returns/${id}/status`, {
|
|
816
892
|
method: "POST",
|
|
817
893
|
headers: {
|
|
818
894
|
"Content-Type": "application/json"
|
|
@@ -825,17 +901,16 @@ const SwapDetailPage = () => {
|
|
|
825
901
|
throw new Error(message || "Unable to update status");
|
|
826
902
|
}
|
|
827
903
|
const payload = await response.json();
|
|
828
|
-
|
|
904
|
+
setReturnOrder(payload.return);
|
|
829
905
|
setSelectedStatus("");
|
|
830
906
|
setUpdateSuccess(true);
|
|
831
907
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
832
|
-
const detailResponse = await fetch(`/admin/
|
|
908
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
833
909
|
credentials: "include"
|
|
834
910
|
});
|
|
835
911
|
if (detailResponse.ok) {
|
|
836
912
|
const detailPayload = await detailResponse.json();
|
|
837
|
-
|
|
838
|
-
setOrder(detailPayload.order || null);
|
|
913
|
+
setReturnOrder(detailPayload.return);
|
|
839
914
|
}
|
|
840
915
|
} catch (updateErr) {
|
|
841
916
|
const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
|
|
@@ -844,90 +919,16 @@ const SwapDetailPage = () => {
|
|
|
844
919
|
setIsUpdating(false);
|
|
845
920
|
}
|
|
846
921
|
};
|
|
847
|
-
const handleApproveClick = async () => {
|
|
848
|
-
if (!id) {
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
if (!swap || !swap.order_id) {
|
|
852
|
-
setUpdateError("Swap must have an order_id to create exchange");
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
try {
|
|
856
|
-
setIsApproving(true);
|
|
857
|
-
setUpdateError(null);
|
|
858
|
-
setUpdateSuccess(false);
|
|
859
|
-
const response = await fetch(`/admin/swaps/${id}/prepare-exchange`, {
|
|
860
|
-
method: "POST",
|
|
861
|
-
headers: {
|
|
862
|
-
"Content-Type": "application/json"
|
|
863
|
-
},
|
|
864
|
-
credentials: "include"
|
|
865
|
-
});
|
|
866
|
-
if (!response.ok) {
|
|
867
|
-
const errorData = await response.json().catch(() => ({ message: "Unable to prepare swap for exchange creation" }));
|
|
868
|
-
throw new Error(errorData.message || errorData.error || "Unable to prepare swap for exchange creation");
|
|
869
|
-
}
|
|
870
|
-
const payload = await response.json();
|
|
871
|
-
setSwap(payload.swap);
|
|
872
|
-
setUpdateSuccess(true);
|
|
873
|
-
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
874
|
-
window.location.href = `/app/orders/${swap.order_id}/exchanges`;
|
|
875
|
-
} catch (updateErr) {
|
|
876
|
-
const message = updateErr instanceof Error ? updateErr.message : "Unable to prepare swap for exchange creation";
|
|
877
|
-
setUpdateError(message);
|
|
878
|
-
} finally {
|
|
879
|
-
setIsApproving(false);
|
|
880
|
-
}
|
|
881
|
-
};
|
|
882
|
-
const handleReject = async () => {
|
|
883
|
-
if (!id) {
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
try {
|
|
887
|
-
setIsRejecting(true);
|
|
888
|
-
setUpdateError(null);
|
|
889
|
-
setUpdateSuccess(false);
|
|
890
|
-
const response = await fetch(`/admin/swaps/${id}/reject`, {
|
|
891
|
-
method: "POST",
|
|
892
|
-
headers: {
|
|
893
|
-
"Content-Type": "application/json"
|
|
894
|
-
},
|
|
895
|
-
credentials: "include",
|
|
896
|
-
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
897
|
-
});
|
|
898
|
-
if (!response.ok) {
|
|
899
|
-
const message = await response.text();
|
|
900
|
-
throw new Error(message || "Unable to reject swap");
|
|
901
|
-
}
|
|
902
|
-
const payload = await response.json();
|
|
903
|
-
setSwap(payload.swap);
|
|
904
|
-
setUpdateSuccess(true);
|
|
905
|
-
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
906
|
-
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
907
|
-
credentials: "include"
|
|
908
|
-
});
|
|
909
|
-
if (detailResponse.ok) {
|
|
910
|
-
const detailPayload = await response.json();
|
|
911
|
-
setSwap(detailPayload.swap);
|
|
912
|
-
setOrder(detailPayload.order || null);
|
|
913
|
-
}
|
|
914
|
-
} catch (updateErr) {
|
|
915
|
-
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
|
|
916
|
-
setUpdateError(message);
|
|
917
|
-
} finally {
|
|
918
|
-
setIsRejecting(false);
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
922
|
if (isLoading) {
|
|
922
|
-
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
|
|
923
|
+
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..." }) }) }) });
|
|
923
924
|
}
|
|
924
|
-
if (error || !
|
|
925
|
+
if (error || !returnOrder) {
|
|
925
926
|
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: [
|
|
926
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
927
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/
|
|
927
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Return order not found" }),
|
|
928
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => navigate("/returns"), children: "Back to list" }) })
|
|
928
929
|
] }) }) });
|
|
929
930
|
}
|
|
930
|
-
const statusHistory = ((_a =
|
|
931
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
931
932
|
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: [
|
|
932
933
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
933
934
|
/* @__PURE__ */ jsxs(
|
|
@@ -935,7 +936,7 @@ const SwapDetailPage = () => {
|
|
|
935
936
|
{
|
|
936
937
|
variant: "transparent",
|
|
937
938
|
size: "small",
|
|
938
|
-
onClick: () => navigate("/
|
|
939
|
+
onClick: () => navigate("/returns"),
|
|
939
940
|
className: "w-fit",
|
|
940
941
|
children: [
|
|
941
942
|
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2" }),
|
|
@@ -945,42 +946,20 @@ const SwapDetailPage = () => {
|
|
|
945
946
|
),
|
|
946
947
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
947
948
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
948
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "
|
|
949
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children:
|
|
949
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Return Order Details" }),
|
|
950
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: returnOrder.id })
|
|
950
951
|
] }),
|
|
951
952
|
/* @__PURE__ */ jsx(
|
|
952
953
|
Badge,
|
|
953
954
|
{
|
|
954
955
|
size: "small",
|
|
955
|
-
className: `uppercase ${getStatusBadgeClass(
|
|
956
|
-
children:
|
|
956
|
+
className: `uppercase ${getStatusBadgeClass(returnOrder.status)}`,
|
|
957
|
+
children: returnOrder.status.replace("_", " ")
|
|
957
958
|
}
|
|
958
959
|
)
|
|
959
960
|
] })
|
|
960
961
|
] }),
|
|
961
|
-
|
|
962
|
-
/* @__PURE__ */ jsx(
|
|
963
|
-
Button,
|
|
964
|
-
{
|
|
965
|
-
variant: "primary",
|
|
966
|
-
onClick: handleApproveClick,
|
|
967
|
-
disabled: isApproving || isRejecting,
|
|
968
|
-
isLoading: isApproving,
|
|
969
|
-
children: "Approve Swap"
|
|
970
|
-
}
|
|
971
|
-
),
|
|
972
|
-
/* @__PURE__ */ jsx(
|
|
973
|
-
Button,
|
|
974
|
-
{
|
|
975
|
-
variant: "secondary",
|
|
976
|
-
onClick: handleReject,
|
|
977
|
-
disabled: isApproving || isRejecting,
|
|
978
|
-
isLoading: isRejecting,
|
|
979
|
-
children: "Reject Swap"
|
|
980
|
-
}
|
|
981
|
-
)
|
|
982
|
-
] }),
|
|
983
|
-
swap.status === "requested" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
962
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
984
963
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
985
964
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
986
965
|
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
@@ -993,7 +972,7 @@ const SwapDetailPage = () => {
|
|
|
993
972
|
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",
|
|
994
973
|
children: [
|
|
995
974
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select new status" }),
|
|
996
|
-
availableStatuses.filter((status) => status !==
|
|
975
|
+
availableStatuses.filter((status) => status !== returnOrder.status).map((status) => /* @__PURE__ */ jsx("option", { value: status, children: status.replace("_", " ").toUpperCase() }, status))
|
|
997
976
|
]
|
|
998
977
|
}
|
|
999
978
|
)
|
|
@@ -1012,60 +991,37 @@ const SwapDetailPage = () => {
|
|
|
1012
991
|
updateError && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
1013
992
|
updateSuccess && /* @__PURE__ */ jsx(Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
1014
993
|
] }),
|
|
1015
|
-
swap.status === "approved" && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1016
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1017
|
-
swap.exchange_id ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1018
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1019
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1020
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
1021
|
-
] }),
|
|
1022
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
1023
|
-
Button,
|
|
1024
|
-
{
|
|
1025
|
-
variant: "secondary",
|
|
1026
|
-
onClick: () => {
|
|
1027
|
-
window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
|
|
1028
|
-
},
|
|
1029
|
-
children: "View Exchange"
|
|
1030
|
-
}
|
|
1031
|
-
) })
|
|
1032
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
|
|
1033
|
-
] }),
|
|
1034
994
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1035
995
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1036
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "
|
|
996
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Information" }),
|
|
1037
997
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1038
998
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1039
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1040
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
999
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Return ID" }),
|
|
1000
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.id })
|
|
1041
1001
|
] }),
|
|
1042
1002
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1043
1003
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
1044
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1004
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.status })
|
|
1045
1005
|
] }),
|
|
1046
1006
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1047
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1048
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1007
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund Amount" }),
|
|
1008
|
+
/* @__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)}` : "—" })
|
|
1049
1009
|
] }),
|
|
1050
|
-
|
|
1010
|
+
returnOrder.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
1051
1011
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1052
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1012
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.reason })
|
|
1053
1013
|
] }),
|
|
1054
|
-
|
|
1014
|
+
returnOrder.note && /* @__PURE__ */ jsxs("div", { children: [
|
|
1055
1015
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1056
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children:
|
|
1016
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.note })
|
|
1057
1017
|
] }),
|
|
1058
1018
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1059
1019
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
1060
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
1020
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.created_at).toLocaleString() })
|
|
1061
1021
|
] }),
|
|
1062
1022
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1063
1023
|
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
1064
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(
|
|
1065
|
-
] }),
|
|
1066
|
-
swap.exchange_id && /* @__PURE__ */ jsxs("div", { children: [
|
|
1067
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1068
|
-
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: swap.exchange_id })
|
|
1024
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
1069
1025
|
] })
|
|
1070
1026
|
] })
|
|
1071
1027
|
] }),
|
|
@@ -1076,18 +1032,23 @@ const SwapDetailPage = () => {
|
|
|
1076
1032
|
{
|
|
1077
1033
|
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
1078
1034
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1035
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1036
|
+
/* @__PURE__ */ jsx(
|
|
1037
|
+
Badge,
|
|
1038
|
+
{
|
|
1039
|
+
size: "2xsmall",
|
|
1040
|
+
className: `uppercase ${getStatusBadgeClass(entry.to)}`,
|
|
1041
|
+
children: entry.to.replace("_", " ")
|
|
1042
|
+
}
|
|
1043
|
+
),
|
|
1044
|
+
entry.from && /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1045
|
+
"from ",
|
|
1046
|
+
entry.from.replace("_", " ")
|
|
1047
|
+
] })
|
|
1048
|
+
] }),
|
|
1087
1049
|
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1088
|
-
new Date(entry.
|
|
1089
|
-
entry.
|
|
1090
|
-
entry.reason && ` - ${entry.reason}`
|
|
1050
|
+
new Date(entry.changed_at).toLocaleString(),
|
|
1051
|
+
entry.changed_by && ` by ${entry.changed_by}`
|
|
1091
1052
|
] })
|
|
1092
1053
|
] })
|
|
1093
1054
|
},
|
|
@@ -1095,109 +1056,123 @@ const SwapDetailPage = () => {
|
|
|
1095
1056
|
)) }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
1096
1057
|
] })
|
|
1097
1058
|
] }),
|
|
1098
|
-
order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1059
|
+
returnOrder.order && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1099
1060
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
1100
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1101
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
/* @__PURE__ */
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
|
|
1061
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1062
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1063
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1064
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
1065
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.id })
|
|
1066
|
+
] }),
|
|
1067
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1068
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
1069
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.status || "—" })
|
|
1070
|
+
] }),
|
|
1071
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1072
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
1073
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: ((_c = returnOrder.order.customer) == null ? void 0 : _c.email) || returnOrder.order.email || "—" })
|
|
1074
|
+
] }),
|
|
1075
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1076
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
1077
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.total).toFixed(2)}` : "—" })
|
|
1078
|
+
] })
|
|
1112
1079
|
] }),
|
|
1113
|
-
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
|
|
1116
|
-
order.currency_code || "$"
|
|
1117
|
-
|
|
1080
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1081
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1082
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Subtotal" }),
|
|
1083
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.subtotal ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.subtotal).toFixed(2)}` : "—" })
|
|
1084
|
+
] }),
|
|
1085
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1086
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Tax Total" }),
|
|
1087
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.tax_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.tax_total).toFixed(2)}` : "—" })
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1090
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Shipping Total" }),
|
|
1091
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.shipping_total ? `${returnOrder.order.currency_code || "$"}${Number(returnOrder.order.shipping_total).toFixed(2)}` : "—" })
|
|
1092
|
+
] }),
|
|
1093
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1094
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Created" }),
|
|
1095
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: returnOrder.order.created_at ? new Date(returnOrder.order.created_at).toLocaleString() : "—" })
|
|
1118
1096
|
] })
|
|
1119
1097
|
] })
|
|
1120
1098
|
] })
|
|
1121
1099
|
] }),
|
|
1122
|
-
|
|
1100
|
+
returnOrder.items && returnOrder.items.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1123
1101
|
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
1124
1102
|
/* @__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: [
|
|
1125
1103
|
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1126
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item
|
|
1127
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
1128
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
1129
|
-
] }) }),
|
|
1130
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
1131
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
1132
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
1133
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
1134
|
-
] }, item.id || index)) })
|
|
1135
|
-
] }) })
|
|
1136
|
-
] }),
|
|
1137
|
-
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: [
|
|
1138
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
1139
|
-
/* @__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: [
|
|
1140
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1141
|
-
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
1104
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item" }),
|
|
1142
1105
|
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
1143
1106
|
] }) }),
|
|
1144
|
-
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
1145
|
-
|
|
1146
|
-
/* @__PURE__ */
|
|
1147
|
-
|
|
1107
|
+
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: returnOrder.items.map((item) => {
|
|
1108
|
+
var _a2, _b2;
|
|
1109
|
+
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
1110
|
+
/* @__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 }),
|
|
1111
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
1112
|
+
] }, item.id);
|
|
1113
|
+
}) })
|
|
1148
1114
|
] }) })
|
|
1115
|
+
] }),
|
|
1116
|
+
returnOrder.metadata && Object.keys(returnOrder.metadata).filter(
|
|
1117
|
+
(key) => key !== "status_history"
|
|
1118
|
+
).length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1119
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-lg", children: "Metadata" }),
|
|
1120
|
+
/* @__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: [
|
|
1121
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: key }),
|
|
1122
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "font-medium", children: typeof value === "string" ? value : JSON.stringify(value) })
|
|
1123
|
+
] }, key)) })
|
|
1149
1124
|
] })
|
|
1150
1125
|
] }) });
|
|
1151
1126
|
};
|
|
1152
1127
|
const config = defineRouteConfig({
|
|
1153
|
-
label: "
|
|
1128
|
+
label: "Return Order Details",
|
|
1154
1129
|
icon: ArrowPath
|
|
1155
1130
|
});
|
|
1156
1131
|
const i18nTranslations0 = {};
|
|
1157
1132
|
const widgetModule = { widgets: [] };
|
|
1158
1133
|
const routeModule = {
|
|
1159
1134
|
routes: [
|
|
1160
|
-
{
|
|
1161
|
-
Component: ReturnsPage,
|
|
1162
|
-
path: "/returns"
|
|
1163
|
-
},
|
|
1164
1135
|
{
|
|
1165
1136
|
Component: SwapsPage,
|
|
1166
1137
|
path: "/swaps"
|
|
1167
1138
|
},
|
|
1168
1139
|
{
|
|
1169
|
-
Component:
|
|
1170
|
-
path: "/returns
|
|
1140
|
+
Component: ReturnsPage,
|
|
1141
|
+
path: "/returns"
|
|
1171
1142
|
},
|
|
1172
1143
|
{
|
|
1173
1144
|
Component: SwapDetailPage,
|
|
1174
1145
|
path: "/swaps/:id"
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
Component: ReturnDetailPage,
|
|
1149
|
+
path: "/returns/:id"
|
|
1175
1150
|
}
|
|
1176
1151
|
]
|
|
1177
1152
|
};
|
|
1178
1153
|
const menuItemModule = {
|
|
1179
1154
|
menuItems: [
|
|
1180
1155
|
{
|
|
1181
|
-
label: config$
|
|
1182
|
-
icon: config$
|
|
1156
|
+
label: config$2.label,
|
|
1157
|
+
icon: config$2.icon,
|
|
1183
1158
|
path: "/returns",
|
|
1184
1159
|
nested: void 0
|
|
1185
1160
|
},
|
|
1186
1161
|
{
|
|
1187
|
-
label: config$
|
|
1188
|
-
icon: config$
|
|
1162
|
+
label: config$3.label,
|
|
1163
|
+
icon: config$3.icon,
|
|
1189
1164
|
path: "/swaps",
|
|
1190
1165
|
nested: void 0
|
|
1191
1166
|
},
|
|
1192
1167
|
{
|
|
1193
|
-
label: config
|
|
1194
|
-
icon: config
|
|
1168
|
+
label: config.label,
|
|
1169
|
+
icon: config.icon,
|
|
1195
1170
|
path: "/returns/:id",
|
|
1196
1171
|
nested: void 0
|
|
1197
1172
|
},
|
|
1198
1173
|
{
|
|
1199
|
-
label: config.label,
|
|
1200
|
-
icon: config.icon,
|
|
1174
|
+
label: config$1.label,
|
|
1175
|
+
icon: config$1.icon,
|
|
1201
1176
|
path: "/swaps/:id",
|
|
1202
1177
|
nested: void 0
|
|
1203
1178
|
}
|