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