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