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