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