order-management 0.0.23 → 0.0.25
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 +591 -521
- package/.medusa/server/src/admin/index.mjs +592 -522
- package/.medusa/server/src/api/admin/swaps/[id]/approve/route.js +49 -23
- package/.medusa/server/src/api/admin/swaps/[id]/route.js +10 -1
- package/.medusa/server/src/api/admin/swaps/[id]/shipping-options/route.js +105 -0
- package/.medusa/server/src/api/admin/swaps/validators.js +2 -1
- package/.medusa/server/src/api/store/orders/[order_id]/swaps/route.js +2 -1
- package/.medusa/server/src/api/store/swaps/route.js +2 -1
- package/.medusa/server/src/helpers/index.js +2 -1
- package/.medusa/server/src/helpers/order-exchange-data.js +233 -0
- package/.medusa/server/src/modules/swap/service.js +1 -1
- package/.medusa/server/src/workflows/steps/swap/create-medusa-exchange-step.js +271 -27
- package/.medusa/server/src/workflows/steps/swap/create-medusa-return-step.js +639 -28
- package/.medusa/server/src/workflows/steps/swap/update-swap-exchange-details-step.js +12 -2
- package/.medusa/server/src/workflows/steps/swap/validate-swap-items-step.js +102 -4
- package/.medusa/server/src/workflows/swaps/approve-swap-workflow.js +56 -12
- package/package.json +1 -1
- package/.medusa/server/src/api/admin/swaps/[id]/confirm-exchange/route.js +0 -109
- package/.medusa/server/src/workflows/swaps/confirm-exchange-workflow.js +0 -51
|
@@ -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,63 +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
|
-
const availableStatuses = [
|
|
462
|
+
const availableStatuses = [
|
|
463
|
+
"requested",
|
|
464
|
+
"received",
|
|
465
|
+
"requires_action",
|
|
466
|
+
"completed",
|
|
467
|
+
"canceled"
|
|
468
|
+
];
|
|
466
469
|
react.useEffect(() => {
|
|
467
470
|
if (!id) {
|
|
468
|
-
navigate("/
|
|
471
|
+
navigate("/returns");
|
|
469
472
|
return;
|
|
470
473
|
}
|
|
471
|
-
const
|
|
474
|
+
const loadReturn = async () => {
|
|
472
475
|
try {
|
|
473
476
|
setIsLoading(true);
|
|
474
477
|
setError(null);
|
|
475
|
-
const response = await fetch(`/admin/
|
|
478
|
+
const response = await fetch(`/admin/returns/${id}`, {
|
|
476
479
|
credentials: "include"
|
|
477
480
|
});
|
|
478
481
|
if (!response.ok) {
|
|
479
482
|
const message = await response.text();
|
|
480
|
-
throw new Error(message || "Unable to load
|
|
483
|
+
throw new Error(message || "Unable to load return order");
|
|
481
484
|
}
|
|
482
485
|
const payload = await response.json();
|
|
483
|
-
|
|
484
|
-
setOrder(payload.order || null);
|
|
486
|
+
setReturnOrder(payload.return);
|
|
485
487
|
setSelectedStatus("");
|
|
486
488
|
} catch (loadError) {
|
|
487
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
489
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load return order";
|
|
488
490
|
setError(message);
|
|
489
491
|
} finally {
|
|
490
492
|
setIsLoading(false);
|
|
491
493
|
}
|
|
492
494
|
};
|
|
493
|
-
void
|
|
495
|
+
void loadReturn();
|
|
494
496
|
}, [id, navigate]);
|
|
495
497
|
const handleStatusUpdate = async () => {
|
|
496
498
|
if (!id || !selectedStatus) {
|
|
@@ -500,7 +502,7 @@ const SwapDetailPage = () => {
|
|
|
500
502
|
setIsUpdating(true);
|
|
501
503
|
setUpdateError(null);
|
|
502
504
|
setUpdateSuccess(false);
|
|
503
|
-
const response = await fetch(`/admin/
|
|
505
|
+
const response = await fetch(`/admin/returns/${id}/status`, {
|
|
504
506
|
method: "POST",
|
|
505
507
|
headers: {
|
|
506
508
|
"Content-Type": "application/json"
|
|
@@ -513,17 +515,16 @@ const SwapDetailPage = () => {
|
|
|
513
515
|
throw new Error(message || "Unable to update status");
|
|
514
516
|
}
|
|
515
517
|
const payload = await response.json();
|
|
516
|
-
|
|
518
|
+
setReturnOrder(payload.return);
|
|
517
519
|
setSelectedStatus("");
|
|
518
520
|
setUpdateSuccess(true);
|
|
519
521
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
520
|
-
const detailResponse = await fetch(`/admin/
|
|
522
|
+
const detailResponse = await fetch(`/admin/returns/${id}`, {
|
|
521
523
|
credentials: "include"
|
|
522
524
|
});
|
|
523
525
|
if (detailResponse.ok) {
|
|
524
526
|
const detailPayload = await detailResponse.json();
|
|
525
|
-
|
|
526
|
-
setOrder(detailPayload.order || null);
|
|
527
|
+
setReturnOrder(detailPayload.return);
|
|
527
528
|
}
|
|
528
529
|
} catch (updateErr) {
|
|
529
530
|
const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
|
|
@@ -532,96 +533,16 @@ const SwapDetailPage = () => {
|
|
|
532
533
|
setIsUpdating(false);
|
|
533
534
|
}
|
|
534
535
|
};
|
|
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
536
|
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
|
|
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..." }) }) }) });
|
|
617
538
|
}
|
|
618
|
-
if (error || !
|
|
539
|
+
if (error || !returnOrder) {
|
|
619
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: [
|
|
620
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "
|
|
621
|
-
/* @__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" }) })
|
|
622
543
|
] }) }) });
|
|
623
544
|
}
|
|
624
|
-
const statusHistory = ((_a =
|
|
545
|
+
const statusHistory = ((_a = returnOrder.metadata) == null ? void 0 : _a.status_history) || [];
|
|
625
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: [
|
|
626
547
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
627
548
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -629,7 +550,7 @@ const SwapDetailPage = () => {
|
|
|
629
550
|
{
|
|
630
551
|
variant: "transparent",
|
|
631
552
|
size: "small",
|
|
632
|
-
onClick: () => navigate("/
|
|
553
|
+
onClick: () => navigate("/returns"),
|
|
633
554
|
className: "w-fit",
|
|
634
555
|
children: [
|
|
635
556
|
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
@@ -639,42 +560,20 @@ const SwapDetailPage = () => {
|
|
|
639
560
|
),
|
|
640
561
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
641
562
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
642
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "
|
|
643
|
-
/* @__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 })
|
|
644
565
|
] }),
|
|
645
566
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
646
567
|
ui.Badge,
|
|
647
568
|
{
|
|
648
569
|
size: "small",
|
|
649
|
-
className: `uppercase ${getStatusBadgeClass$1(
|
|
650
|
-
children:
|
|
570
|
+
className: `uppercase ${getStatusBadgeClass$1(returnOrder.status)}`,
|
|
571
|
+
children: returnOrder.status.replace("_", " ")
|
|
651
572
|
}
|
|
652
573
|
)
|
|
653
574
|
] })
|
|
654
575
|
] }),
|
|
655
|
-
|
|
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: [
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
678
577
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
679
578
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
680
579
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
@@ -687,7 +586,7 @@ const SwapDetailPage = () => {
|
|
|
687
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",
|
|
688
587
|
children: [
|
|
689
588
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
|
|
690
|
-
availableStatuses.filter((status) => status !==
|
|
589
|
+
availableStatuses.filter((status) => status !== returnOrder.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace("_", " ").toUpperCase() }, status))
|
|
691
590
|
]
|
|
692
591
|
}
|
|
693
592
|
)
|
|
@@ -706,73 +605,37 @@ const SwapDetailPage = () => {
|
|
|
706
605
|
updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
707
606
|
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
708
607
|
] }),
|
|
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
|
-
] }),
|
|
741
608
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
742
609
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
743
|
-
/* @__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" }),
|
|
744
611
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
745
612
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
746
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
747
|
-
/* @__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 })
|
|
748
615
|
] }),
|
|
749
616
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
750
617
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
751
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
618
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.status })
|
|
752
619
|
] }),
|
|
753
620
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
754
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
755
|
-
/* @__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)}` : "—" })
|
|
756
623
|
] }),
|
|
757
|
-
|
|
624
|
+
returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
758
625
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
759
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
626
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
|
|
760
627
|
] }),
|
|
761
|
-
|
|
628
|
+
returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
762
629
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
763
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
630
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
|
|
764
631
|
] }),
|
|
765
632
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
766
633
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
767
|
-
/* @__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() })
|
|
768
635
|
] }),
|
|
769
636
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
770
637
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
771
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(
|
|
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 })
|
|
638
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(returnOrder.updated_at).toLocaleString() })
|
|
776
639
|
] })
|
|
777
640
|
] })
|
|
778
641
|
] }),
|
|
@@ -783,18 +646,23 @@ const SwapDetailPage = () => {
|
|
|
783
646
|
{
|
|
784
647
|
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
785
648
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
786
|
-
/* @__PURE__ */ jsxRuntime.
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
+
] }),
|
|
794
663
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
795
|
-
new Date(entry.
|
|
796
|
-
entry.
|
|
797
|
-
entry.reason && ` - ${entry.reason}`
|
|
664
|
+
new Date(entry.changed_at).toLocaleString(),
|
|
665
|
+
entry.changed_by && ` by ${entry.changed_by}`
|
|
798
666
|
] })
|
|
799
667
|
] })
|
|
800
668
|
},
|
|
@@ -802,62 +670,76 @@ const SwapDetailPage = () => {
|
|
|
802
670
|
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
803
671
|
] })
|
|
804
672
|
] }),
|
|
805
|
-
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: [
|
|
806
674
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
807
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
808
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
809
|
-
/* @__PURE__ */ jsxRuntime.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
/* @__PURE__ */ jsxRuntime.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
/* @__PURE__ */ jsxRuntime.
|
|
818
|
-
|
|
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
|
+
] })
|
|
819
693
|
] }),
|
|
820
|
-
|
|
821
|
-
/* @__PURE__ */ jsxRuntime.
|
|
822
|
-
|
|
823
|
-
order.currency_code || "$"
|
|
824
|
-
|
|
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() : "—" })
|
|
825
710
|
] })
|
|
826
711
|
] })
|
|
827
712
|
] })
|
|
828
713
|
] }),
|
|
829
|
-
|
|
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: [
|
|
830
715
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
831
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: [
|
|
832
717
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
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
|
|
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" })
|
|
836
|
-
] }) }),
|
|
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)) })
|
|
842
|
-
] }) })
|
|
843
|
-
] }),
|
|
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" }),
|
|
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" }),
|
|
849
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" })
|
|
850
720
|
] }) }),
|
|
851
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children:
|
|
852
|
-
|
|
853
|
-
/* @__PURE__ */ jsxRuntime.
|
|
854
|
-
|
|
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
|
+
}) })
|
|
855
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)) })
|
|
856
738
|
] })
|
|
857
739
|
] }) });
|
|
858
740
|
};
|
|
859
741
|
const config$1 = adminSdk.defineRouteConfig({
|
|
860
|
-
label: "
|
|
742
|
+
label: "Return Order Details",
|
|
861
743
|
icon: icons.ArrowPath
|
|
862
744
|
});
|
|
863
745
|
const getStatusBadgeClass = (status) => {
|
|
@@ -865,65 +747,67 @@ const getStatusBadgeClass = (status) => {
|
|
|
865
747
|
if (statusLower === "requested") {
|
|
866
748
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
867
749
|
}
|
|
868
|
-
if (statusLower === "
|
|
750
|
+
if (statusLower === "approved") {
|
|
869
751
|
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
870
752
|
}
|
|
871
|
-
if (statusLower === "
|
|
753
|
+
if (statusLower === "rejected") {
|
|
872
754
|
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
873
755
|
}
|
|
874
756
|
if (statusLower === "completed") {
|
|
875
757
|
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
876
758
|
}
|
|
877
|
-
if (statusLower === "
|
|
759
|
+
if (statusLower === "cancelled") {
|
|
878
760
|
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
879
761
|
}
|
|
880
762
|
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
881
763
|
};
|
|
882
|
-
const
|
|
883
|
-
var _a, _b
|
|
764
|
+
const SwapDetailPage = () => {
|
|
765
|
+
var _a, _b;
|
|
884
766
|
const navigate = reactRouterDom.useNavigate();
|
|
885
767
|
const { id } = reactRouterDom.useParams();
|
|
886
|
-
const [
|
|
768
|
+
const [swap, setSwap] = react.useState(null);
|
|
769
|
+
const [order, setOrder] = react.useState(null);
|
|
887
770
|
const [selectedStatus, setSelectedStatus] = react.useState("");
|
|
888
771
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
889
772
|
const [isUpdating, setIsUpdating] = react.useState(false);
|
|
773
|
+
const [isApproving, setIsApproving] = react.useState(false);
|
|
774
|
+
const [isRejecting, setIsRejecting] = react.useState(false);
|
|
890
775
|
const [error, setError] = react.useState(null);
|
|
891
776
|
const [updateError, setUpdateError] = react.useState(null);
|
|
892
777
|
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
"canceled"
|
|
899
|
-
];
|
|
778
|
+
const [showShippingModal, setShowShippingModal] = react.useState(false);
|
|
779
|
+
const [shippingOptions, setShippingOptions] = react.useState([]);
|
|
780
|
+
const [selectedShippingOptionId, setSelectedShippingOptionId] = react.useState("");
|
|
781
|
+
const [isLoadingShippingOptions, setIsLoadingShippingOptions] = react.useState(false);
|
|
782
|
+
const availableStatuses = ["requested", "approved", "rejected"];
|
|
900
783
|
react.useEffect(() => {
|
|
901
784
|
if (!id) {
|
|
902
|
-
navigate("/
|
|
785
|
+
navigate("/swaps");
|
|
903
786
|
return;
|
|
904
787
|
}
|
|
905
|
-
const
|
|
788
|
+
const loadSwap = async () => {
|
|
906
789
|
try {
|
|
907
790
|
setIsLoading(true);
|
|
908
791
|
setError(null);
|
|
909
|
-
const response = await fetch(`/admin/
|
|
792
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
910
793
|
credentials: "include"
|
|
911
794
|
});
|
|
912
795
|
if (!response.ok) {
|
|
913
796
|
const message = await response.text();
|
|
914
|
-
throw new Error(message || "Unable to load
|
|
797
|
+
throw new Error(message || "Unable to load swap");
|
|
915
798
|
}
|
|
916
799
|
const payload = await response.json();
|
|
917
|
-
|
|
800
|
+
setSwap(payload.swap);
|
|
801
|
+
setOrder(payload.order || null);
|
|
918
802
|
setSelectedStatus("");
|
|
919
803
|
} catch (loadError) {
|
|
920
|
-
const message = loadError instanceof Error ? loadError.message : "Unable to load
|
|
804
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
921
805
|
setError(message);
|
|
922
806
|
} finally {
|
|
923
807
|
setIsLoading(false);
|
|
924
808
|
}
|
|
925
809
|
};
|
|
926
|
-
void
|
|
810
|
+
void loadSwap();
|
|
927
811
|
}, [id, navigate]);
|
|
928
812
|
const handleStatusUpdate = async () => {
|
|
929
813
|
if (!id || !selectedStatus) {
|
|
@@ -933,7 +817,7 @@ const ReturnDetailPage = () => {
|
|
|
933
817
|
setIsUpdating(true);
|
|
934
818
|
setUpdateError(null);
|
|
935
819
|
setUpdateSuccess(false);
|
|
936
|
-
const response = await fetch(`/admin/
|
|
820
|
+
const response = await fetch(`/admin/swaps/${id}/status`, {
|
|
937
821
|
method: "POST",
|
|
938
822
|
headers: {
|
|
939
823
|
"Content-Type": "application/json"
|
|
@@ -946,16 +830,17 @@ const ReturnDetailPage = () => {
|
|
|
946
830
|
throw new Error(message || "Unable to update status");
|
|
947
831
|
}
|
|
948
832
|
const payload = await response.json();
|
|
949
|
-
|
|
833
|
+
setSwap(payload.swap);
|
|
950
834
|
setSelectedStatus("");
|
|
951
835
|
setUpdateSuccess(true);
|
|
952
836
|
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
953
|
-
const detailResponse = await fetch(`/admin/
|
|
837
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
954
838
|
credentials: "include"
|
|
955
839
|
});
|
|
956
840
|
if (detailResponse.ok) {
|
|
957
841
|
const detailPayload = await detailResponse.json();
|
|
958
|
-
|
|
842
|
+
setSwap(detailPayload.swap);
|
|
843
|
+
setOrder(detailPayload.order || null);
|
|
959
844
|
}
|
|
960
845
|
} catch (updateErr) {
|
|
961
846
|
const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
|
|
@@ -964,234 +849,419 @@ const ReturnDetailPage = () => {
|
|
|
964
849
|
setIsUpdating(false);
|
|
965
850
|
}
|
|
966
851
|
};
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
852
|
+
const handleApproveClick = async () => {
|
|
853
|
+
if (!id) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
setShowShippingModal(true);
|
|
857
|
+
setSelectedShippingOptionId("");
|
|
858
|
+
setUpdateError(null);
|
|
859
|
+
try {
|
|
860
|
+
setIsLoadingShippingOptions(true);
|
|
861
|
+
const response = await fetch(`/admin/swaps/${id}/shipping-options`, {
|
|
862
|
+
credentials: "include"
|
|
863
|
+
});
|
|
864
|
+
if (!response.ok) {
|
|
865
|
+
const message = await response.text();
|
|
866
|
+
throw new Error(message || "Unable to fetch shipping options");
|
|
867
|
+
}
|
|
868
|
+
const payload = await response.json();
|
|
869
|
+
setShippingOptions(payload.shipping_options || []);
|
|
870
|
+
} catch (fetchError) {
|
|
871
|
+
const message = fetchError instanceof Error ? fetchError.message : "Unable to fetch shipping options";
|
|
872
|
+
setUpdateError(message);
|
|
873
|
+
setShowShippingModal(false);
|
|
874
|
+
} finally {
|
|
875
|
+
setIsLoadingShippingOptions(false);
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
const handleApproveConfirm = async () => {
|
|
879
|
+
if (!id || !selectedShippingOptionId) {
|
|
880
|
+
setUpdateError("Please select a shipping option");
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
try {
|
|
884
|
+
setIsApproving(true);
|
|
885
|
+
setUpdateError(null);
|
|
886
|
+
setUpdateSuccess(false);
|
|
887
|
+
const response = await fetch(`/admin/swaps/${id}/approve`, {
|
|
888
|
+
method: "POST",
|
|
889
|
+
headers: {
|
|
890
|
+
"Content-Type": "application/json"
|
|
891
|
+
},
|
|
892
|
+
credentials: "include",
|
|
893
|
+
body: JSON.stringify({
|
|
894
|
+
shipping_option_id: selectedShippingOptionId
|
|
895
|
+
})
|
|
896
|
+
});
|
|
897
|
+
if (!response.ok) {
|
|
898
|
+
const errorData = await response.json().catch(() => ({ message: "Unable to approve swap" }));
|
|
899
|
+
throw new Error(errorData.message || errorData.error || "Unable to approve swap");
|
|
900
|
+
}
|
|
901
|
+
const payload = await response.json();
|
|
902
|
+
setSwap(payload.swap);
|
|
903
|
+
setUpdateSuccess(true);
|
|
904
|
+
setShowShippingModal(false);
|
|
905
|
+
setSelectedShippingOptionId("");
|
|
906
|
+
setTimeout(() => setUpdateSuccess(false), 5e3);
|
|
907
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
908
|
+
credentials: "include"
|
|
909
|
+
});
|
|
910
|
+
if (detailResponse.ok) {
|
|
911
|
+
const detailPayload = await detailResponse.json();
|
|
912
|
+
setSwap(detailPayload.swap);
|
|
913
|
+
setOrder(detailPayload.order || null);
|
|
914
|
+
}
|
|
915
|
+
} catch (updateErr) {
|
|
916
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to approve swap";
|
|
917
|
+
setUpdateError(message);
|
|
918
|
+
} finally {
|
|
919
|
+
setIsApproving(false);
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
const handleReject = async () => {
|
|
923
|
+
if (!id) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
try {
|
|
927
|
+
setIsRejecting(true);
|
|
928
|
+
setUpdateError(null);
|
|
929
|
+
setUpdateSuccess(false);
|
|
930
|
+
const response = await fetch(`/admin/swaps/${id}/reject`, {
|
|
931
|
+
method: "POST",
|
|
932
|
+
headers: {
|
|
933
|
+
"Content-Type": "application/json"
|
|
934
|
+
},
|
|
935
|
+
credentials: "include",
|
|
936
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
937
|
+
});
|
|
938
|
+
if (!response.ok) {
|
|
939
|
+
const message = await response.text();
|
|
940
|
+
throw new Error(message || "Unable to reject swap");
|
|
941
|
+
}
|
|
942
|
+
const payload = await response.json();
|
|
943
|
+
setSwap(payload.swap);
|
|
944
|
+
setUpdateSuccess(true);
|
|
945
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
946
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
947
|
+
credentials: "include"
|
|
948
|
+
});
|
|
949
|
+
if (detailResponse.ok) {
|
|
950
|
+
const detailPayload = await response.json();
|
|
951
|
+
setSwap(detailPayload.swap);
|
|
952
|
+
setOrder(detailPayload.order || null);
|
|
953
|
+
}
|
|
954
|
+
} catch (updateErr) {
|
|
955
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
|
|
956
|
+
setUpdateError(message);
|
|
957
|
+
} finally {
|
|
958
|
+
setIsRejecting(false);
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
if (isLoading) {
|
|
962
|
+
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..." }) }) }) });
|
|
963
|
+
}
|
|
964
|
+
if (error || !swap) {
|
|
965
|
+
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: [
|
|
966
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
967
|
+
/* @__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" }) })
|
|
968
|
+
] }) }) });
|
|
969
|
+
}
|
|
970
|
+
const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
|
|
971
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full p-6", children: [
|
|
972
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
973
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
974
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
975
|
+
ui.Button,
|
|
976
|
+
{
|
|
977
|
+
variant: "transparent",
|
|
978
|
+
size: "small",
|
|
979
|
+
onClick: () => navigate("/swaps"),
|
|
980
|
+
className: "w-fit",
|
|
981
|
+
children: [
|
|
982
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
983
|
+
"Back to list"
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
988
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
|
|
990
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
991
|
+
] }),
|
|
992
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
993
|
+
ui.Badge,
|
|
994
|
+
{
|
|
995
|
+
size: "small",
|
|
996
|
+
className: `uppercase ${getStatusBadgeClass(swap.status)}`,
|
|
997
|
+
children: swap.status.replace(/_/g, " ")
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
] })
|
|
1001
|
+
] }),
|
|
1002
|
+
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
1025
1003
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1026
1004
|
ui.Button,
|
|
1027
1005
|
{
|
|
1028
1006
|
variant: "primary",
|
|
1029
|
-
onClick:
|
|
1030
|
-
disabled:
|
|
1031
|
-
isLoading:
|
|
1032
|
-
children: "
|
|
1007
|
+
onClick: handleApproveClick,
|
|
1008
|
+
disabled: isApproving || isRejecting,
|
|
1009
|
+
isLoading: isApproving,
|
|
1010
|
+
children: "Approve Swap"
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1014
|
+
ui.Button,
|
|
1015
|
+
{
|
|
1016
|
+
variant: "secondary",
|
|
1017
|
+
onClick: handleReject,
|
|
1018
|
+
disabled: isApproving || isRejecting,
|
|
1019
|
+
isLoading: isRejecting,
|
|
1020
|
+
children: "Reject Swap"
|
|
1033
1021
|
}
|
|
1034
1022
|
)
|
|
1035
1023
|
] }),
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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)}` : "—" })
|
|
1054
|
-
] }),
|
|
1055
|
-
returnOrder.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1056
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1057
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.reason })
|
|
1058
|
-
] }),
|
|
1059
|
-
returnOrder.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1060
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1061
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: returnOrder.note })
|
|
1024
|
+
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1025
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
1026
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
1027
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
1028
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
|
|
1029
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1030
|
+
"select",
|
|
1031
|
+
{
|
|
1032
|
+
value: selectedStatus,
|
|
1033
|
+
onChange: (event) => setSelectedStatus(event.target.value),
|
|
1034
|
+
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",
|
|
1035
|
+
children: [
|
|
1036
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
|
|
1037
|
+
availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
1038
|
+
]
|
|
1039
|
+
}
|
|
1040
|
+
)
|
|
1062
1041
|
] }),
|
|
1042
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1043
|
+
ui.Button,
|
|
1044
|
+
{
|
|
1045
|
+
variant: "primary",
|
|
1046
|
+
onClick: handleStatusUpdate,
|
|
1047
|
+
disabled: !selectedStatus || isUpdating,
|
|
1048
|
+
isLoading: isUpdating,
|
|
1049
|
+
children: "Update Status"
|
|
1050
|
+
}
|
|
1051
|
+
)
|
|
1052
|
+
] }),
|
|
1053
|
+
updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
1054
|
+
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
1055
|
+
] }),
|
|
1056
|
+
swap.status === "approved" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1057
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Exchange Information" }),
|
|
1058
|
+
swap.exchange_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1063
1059
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1064
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "
|
|
1065
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children:
|
|
1060
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
1066
1062
|
] }),
|
|
1067
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1064
|
+
ui.Button,
|
|
1065
|
+
{
|
|
1066
|
+
variant: "secondary",
|
|
1067
|
+
onClick: () => {
|
|
1068
|
+
window.open(`/app/orders/${swap.order_id}/exchanges/${swap.exchange_id}`, "_blank");
|
|
1069
|
+
},
|
|
1070
|
+
children: "View Exchange"
|
|
1071
|
+
}
|
|
1072
|
+
) })
|
|
1073
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange is being created. Please refresh the page to see the exchange details." }) })
|
|
1072
1074
|
] }),
|
|
1073
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
1074
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1075
|
-
|
|
1076
|
-
"div",
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1076
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1077
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
|
|
1078
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1079
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
1082
|
+
] }),
|
|
1083
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1084
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
1085
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
1086
|
+
] }),
|
|
1087
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1088
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
1089
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
1090
|
+
] }),
|
|
1091
|
+
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1092
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
1093
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
1094
|
+
] }),
|
|
1095
|
+
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
1097
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
1098
|
+
] }),
|
|
1099
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
1101
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
1102
|
+
] }),
|
|
1103
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1104
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
1105
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
1106
|
+
] }),
|
|
1107
|
+
swap.exchange_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1108
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Exchange ID" }),
|
|
1109
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.exchange_id })
|
|
1110
|
+
] })
|
|
1111
|
+
] })
|
|
1112
|
+
] }),
|
|
1113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1114
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
1115
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1116
|
+
"div",
|
|
1117
|
+
{
|
|
1118
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
1119
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1120
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1082
1121
|
ui.Badge,
|
|
1083
1122
|
{
|
|
1084
1123
|
size: "2xsmall",
|
|
1085
|
-
className: `uppercase ${getStatusBadgeClass(entry.
|
|
1086
|
-
children: entry.
|
|
1124
|
+
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
1125
|
+
children: entry.status.replace(/_/g, " ")
|
|
1087
1126
|
}
|
|
1088
|
-
),
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
entry.
|
|
1127
|
+
) }),
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1129
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
1130
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
1131
|
+
entry.reason && ` - ${entry.reason}`
|
|
1092
1132
|
] })
|
|
1093
|
-
] }),
|
|
1094
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1095
|
-
new Date(entry.changed_at).toLocaleString(),
|
|
1096
|
-
entry.changed_by && ` by ${entry.changed_by}`
|
|
1097
1133
|
] })
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
] })
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
1106
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
1134
|
+
},
|
|
1135
|
+
index
|
|
1136
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
1137
|
+
] })
|
|
1138
|
+
] }),
|
|
1139
|
+
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
1107
1141
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1108
1142
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1109
1143
|
/* @__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:
|
|
1144
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
1111
1145
|
] }),
|
|
1112
1146
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1113
1147
|
/* @__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:
|
|
1148
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
1115
1149
|
] }),
|
|
1116
1150
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1117
1151
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
1118
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((
|
|
1152
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
|
|
1119
1153
|
] }),
|
|
1120
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1154
|
+
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1121
1155
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
1122
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
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() : "—" })
|
|
1156
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
1157
|
+
order.currency_code || "$",
|
|
1158
|
+
(Number(order.total) / 100).toFixed(2)
|
|
1159
|
+
] })
|
|
1141
1160
|
] })
|
|
1142
1161
|
] })
|
|
1143
|
-
] })
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4
|
|
1162
|
+
] }),
|
|
1163
|
+
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: [
|
|
1164
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
1165
|
+
/* @__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: [
|
|
1166
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1167
|
+
/* @__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" }),
|
|
1168
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
1169
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
1170
|
+
] }) }),
|
|
1171
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
1174
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
1175
|
+
] }, item.id || index)) })
|
|
1176
|
+
] }) })
|
|
1177
|
+
] }),
|
|
1178
|
+
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: [
|
|
1179
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
1180
|
+
/* @__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: [
|
|
1181
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1182
|
+
/* @__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" }),
|
|
1183
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
1184
|
+
] }) }),
|
|
1185
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1186
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
1156
1187
|
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
1157
|
-
] }, item.
|
|
1158
|
-
}) })
|
|
1159
|
-
] })
|
|
1188
|
+
] }, item.variant_id || index)) })
|
|
1189
|
+
] }) })
|
|
1190
|
+
] })
|
|
1160
1191
|
] }),
|
|
1161
|
-
|
|
1162
|
-
(
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1192
|
+
showShippingModal && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full max-w-md rounded-lg border border-ui-border-base bg-ui-bg-base p-6 shadow-lg", children: [
|
|
1193
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
|
|
1194
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Select Shipping Option" }),
|
|
1195
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Please select a shipping option for the exchange. This is required to create the exchange." })
|
|
1196
|
+
] }),
|
|
1197
|
+
isLoadingShippingOptions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading shipping options..." }) }) : shippingOptions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: "No shipping options available for this order's region." }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-6", children: [
|
|
1198
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "Shipping Option" }),
|
|
1199
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1200
|
+
ui.Select,
|
|
1201
|
+
{
|
|
1202
|
+
value: selectedShippingOptionId,
|
|
1203
|
+
onValueChange: setSelectedShippingOptionId,
|
|
1204
|
+
children: [
|
|
1205
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "Select a shipping option" }) }),
|
|
1206
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: shippingOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: option.id, children: option.name }, option.id)) })
|
|
1207
|
+
]
|
|
1208
|
+
}
|
|
1209
|
+
)
|
|
1210
|
+
] }),
|
|
1211
|
+
updateError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-error", children: updateError }) }),
|
|
1212
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
1213
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1214
|
+
ui.Button,
|
|
1215
|
+
{
|
|
1216
|
+
variant: "secondary",
|
|
1217
|
+
onClick: () => {
|
|
1218
|
+
setShowShippingModal(false);
|
|
1219
|
+
setSelectedShippingOptionId("");
|
|
1220
|
+
setUpdateError(null);
|
|
1221
|
+
},
|
|
1222
|
+
disabled: isApproving,
|
|
1223
|
+
className: "flex-1",
|
|
1224
|
+
children: "Cancel"
|
|
1225
|
+
}
|
|
1226
|
+
),
|
|
1227
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1228
|
+
ui.Button,
|
|
1229
|
+
{
|
|
1230
|
+
variant: "primary",
|
|
1231
|
+
onClick: handleApproveConfirm,
|
|
1232
|
+
disabled: !selectedShippingOptionId || isApproving || isLoadingShippingOptions,
|
|
1233
|
+
isLoading: isApproving,
|
|
1234
|
+
className: "flex-1",
|
|
1235
|
+
children: "Confirm & Approve"
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
] })
|
|
1239
|
+
] }) })
|
|
1240
|
+
] });
|
|
1171
1241
|
};
|
|
1172
1242
|
const config = adminSdk.defineRouteConfig({
|
|
1173
|
-
label: "
|
|
1243
|
+
label: "Swap Details",
|
|
1174
1244
|
icon: icons.ArrowPath
|
|
1175
1245
|
});
|
|
1176
1246
|
const i18nTranslations0 = {};
|
|
1177
1247
|
const widgetModule = { widgets: [] };
|
|
1178
1248
|
const routeModule = {
|
|
1179
1249
|
routes: [
|
|
1180
|
-
{
|
|
1181
|
-
Component: SwapsPage,
|
|
1182
|
-
path: "/swaps"
|
|
1183
|
-
},
|
|
1184
1250
|
{
|
|
1185
1251
|
Component: ReturnsPage,
|
|
1186
1252
|
path: "/returns"
|
|
1187
1253
|
},
|
|
1188
1254
|
{
|
|
1189
|
-
Component:
|
|
1190
|
-
path: "/swaps
|
|
1255
|
+
Component: SwapsPage,
|
|
1256
|
+
path: "/swaps"
|
|
1191
1257
|
},
|
|
1192
1258
|
{
|
|
1193
1259
|
Component: ReturnDetailPage,
|
|
1194
1260
|
path: "/returns/:id"
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
Component: SwapDetailPage,
|
|
1264
|
+
path: "/swaps/:id"
|
|
1195
1265
|
}
|
|
1196
1266
|
]
|
|
1197
1267
|
};
|
|
@@ -1200,25 +1270,25 @@ const menuItemModule = {
|
|
|
1200
1270
|
{
|
|
1201
1271
|
label: config$2.label,
|
|
1202
1272
|
icon: config$2.icon,
|
|
1203
|
-
path: "/
|
|
1273
|
+
path: "/swaps",
|
|
1204
1274
|
nested: void 0
|
|
1205
1275
|
},
|
|
1206
1276
|
{
|
|
1207
1277
|
label: config$3.label,
|
|
1208
1278
|
icon: config$3.icon,
|
|
1209
|
-
path: "/
|
|
1279
|
+
path: "/returns",
|
|
1210
1280
|
nested: void 0
|
|
1211
1281
|
},
|
|
1212
1282
|
{
|
|
1213
1283
|
label: config.label,
|
|
1214
1284
|
icon: config.icon,
|
|
1215
|
-
path: "/
|
|
1285
|
+
path: "/swaps/:id",
|
|
1216
1286
|
nested: void 0
|
|
1217
1287
|
},
|
|
1218
1288
|
{
|
|
1219
1289
|
label: config$1.label,
|
|
1220
1290
|
icon: config$1.icon,
|
|
1221
|
-
path: "/
|
|
1291
|
+
path: "/returns/:id",
|
|
1222
1292
|
nested: void 0
|
|
1223
1293
|
}
|
|
1224
1294
|
]
|