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