order-management 0.0.17 → 0.0.18
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 +638 -5
- package/.medusa/server/src/admin/index.mjs +638 -5
- package/.medusa/server/src/api/admin/swaps/[id]/approve/route.js +45 -0
- package/.medusa/server/src/api/admin/swaps/[id]/reject/route.js +43 -0
- package/.medusa/server/src/api/admin/swaps/[id]/route.js +70 -0
- package/.medusa/server/src/api/admin/swaps/[id]/status/route.js +45 -0
- package/.medusa/server/src/api/admin/swaps/route.js +51 -0
- package/.medusa/server/src/api/admin/swaps/validators.js +22 -0
- package/.medusa/server/src/api/store/guest-orders/[id]/invoice/route.js +17 -5
- package/.medusa/server/src/api/store/guest-orders/[id]/returns/route.js +17 -5
- package/.medusa/server/src/api/store/guest-orders/[id]/route.js +17 -5
- package/.medusa/server/src/api/store/guest-orders/route.js +17 -5
- package/.medusa/server/src/api/store/orders/[order_id]/swaps/route.js +107 -0
- package/.medusa/server/src/api/store/otp/request/route.js +12 -5
- package/.medusa/server/src/api/store/swaps/[id]/cancel/route.js +64 -0
- package/.medusa/server/src/api/store/swaps/[id]/route.js +112 -0
- package/.medusa/server/src/api/store/swaps/route.js +117 -0
- package/.medusa/server/src/helpers/index.js +18 -0
- package/.medusa/server/src/helpers/swaps.js +88 -0
- package/.medusa/server/src/modules/swap/index.js +13 -0
- package/.medusa/server/src/modules/swap/migrations/Migration20260121164326.js +49 -0
- package/.medusa/server/src/modules/swap/models/swap.js +21 -0
- package/.medusa/server/src/modules/swap/service.js +154 -0
- package/.medusa/server/src/services/otp-service.js +16 -5
- package/.medusa/server/src/subscribers/send-order-email.js +27 -8
- package/.medusa/server/src/workflows/index.js +8 -2
- package/.medusa/server/src/workflows/steps/swap/calculate-difference-step.js +56 -0
- package/.medusa/server/src/workflows/steps/swap/create-swap-step.js +29 -0
- package/.medusa/server/src/workflows/steps/swap/index.js +16 -0
- package/.medusa/server/src/workflows/steps/swap/retrieve-swap-step.js +26 -0
- package/.medusa/server/src/workflows/steps/swap/update-swap-status-step.js +25 -0
- package/.medusa/server/src/workflows/steps/swap/validate-order-step.js +47 -0
- package/.medusa/server/src/workflows/steps/swap/validate-swap-items-step.js +41 -0
- package/.medusa/server/src/workflows/swaps/approve-swap-workflow.js +38 -0
- package/.medusa/server/src/workflows/swaps/create-swap-workflow.js +46 -0
- package/.medusa/server/src/workflows/swaps/types.js +3 -0
- package/.medusa/server/src/workflows/swaps/update-swap-status-workflow.js +23 -0
- package/README.md +208 -0
- package/package.json +1 -1
- package/.medusa/server/src/utils/resolve-options.js +0 -101
|
@@ -5,6 +5,217 @@ const adminSdk = require("@medusajs/admin-sdk");
|
|
|
5
5
|
const ui = require("@medusajs/ui");
|
|
6
6
|
const icons = require("@medusajs/icons");
|
|
7
7
|
const reactRouterDom = require("react-router-dom");
|
|
8
|
+
const useDebounce$1 = (value, delay) => {
|
|
9
|
+
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
12
|
+
return () => clearTimeout(handler);
|
|
13
|
+
}, [value, delay]);
|
|
14
|
+
return debouncedValue;
|
|
15
|
+
};
|
|
16
|
+
const getStatusBadgeClass$3 = (status) => {
|
|
17
|
+
const statusLower = status.toLowerCase();
|
|
18
|
+
if (statusLower === "requested") {
|
|
19
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
20
|
+
}
|
|
21
|
+
if (statusLower === "approved") {
|
|
22
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
23
|
+
}
|
|
24
|
+
if (statusLower === "rejected") {
|
|
25
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
26
|
+
}
|
|
27
|
+
if (statusLower === "completed") {
|
|
28
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
29
|
+
}
|
|
30
|
+
if (statusLower === "cancelled") {
|
|
31
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
32
|
+
}
|
|
33
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
34
|
+
};
|
|
35
|
+
const SwapsPage = () => {
|
|
36
|
+
const navigate = reactRouterDom.useNavigate();
|
|
37
|
+
const [items, setItems] = react.useState([]);
|
|
38
|
+
const [statusFilter, setStatusFilter] = react.useState("all");
|
|
39
|
+
const [searchQuery, setSearchQuery] = react.useState("");
|
|
40
|
+
const debouncedSearchQuery = useDebounce$1(searchQuery, 300);
|
|
41
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
42
|
+
const [isFetchingMore, setIsFetchingMore] = react.useState(false);
|
|
43
|
+
const [error, setError] = react.useState(null);
|
|
44
|
+
const [offset, setOffset] = react.useState(0);
|
|
45
|
+
const [count, setCount] = react.useState(0);
|
|
46
|
+
const limit = 50;
|
|
47
|
+
const loadSwaps = react.useCallback(
|
|
48
|
+
async (nextOffset, replace = false) => {
|
|
49
|
+
var _a;
|
|
50
|
+
try {
|
|
51
|
+
if (replace) {
|
|
52
|
+
setIsLoading(true);
|
|
53
|
+
} else {
|
|
54
|
+
setIsFetchingMore(true);
|
|
55
|
+
}
|
|
56
|
+
setError(null);
|
|
57
|
+
const params = new URLSearchParams();
|
|
58
|
+
params.set("limit", String(limit));
|
|
59
|
+
params.set("offset", String(nextOffset));
|
|
60
|
+
if (statusFilter !== "all") {
|
|
61
|
+
params.set("status", statusFilter);
|
|
62
|
+
}
|
|
63
|
+
if (debouncedSearchQuery.trim()) {
|
|
64
|
+
params.set("order_id", debouncedSearchQuery.trim());
|
|
65
|
+
}
|
|
66
|
+
const response = await fetch(
|
|
67
|
+
`/admin/swaps?${params.toString()}`,
|
|
68
|
+
{ credentials: "include" }
|
|
69
|
+
);
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const message = await response.text();
|
|
72
|
+
throw new Error(message || "Unable to load swaps");
|
|
73
|
+
}
|
|
74
|
+
const payload = await response.json();
|
|
75
|
+
setCount(payload.count ?? 0);
|
|
76
|
+
setOffset(nextOffset + (((_a = payload.swaps) == null ? void 0 : _a.length) ?? 0));
|
|
77
|
+
setItems(
|
|
78
|
+
(prev) => replace ? payload.swaps ?? [] : [...prev, ...payload.swaps ?? []]
|
|
79
|
+
);
|
|
80
|
+
} catch (loadError) {
|
|
81
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swaps";
|
|
82
|
+
setError(message);
|
|
83
|
+
} finally {
|
|
84
|
+
setIsLoading(false);
|
|
85
|
+
setIsFetchingMore(false);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[statusFilter, debouncedSearchQuery]
|
|
89
|
+
);
|
|
90
|
+
react.useEffect(() => {
|
|
91
|
+
void loadSwaps(0, true);
|
|
92
|
+
}, [statusFilter, debouncedSearchQuery, loadSwaps]);
|
|
93
|
+
const hasMore = react.useMemo(() => offset < count, [offset, count]);
|
|
94
|
+
const availableStatuses = react.useMemo(() => {
|
|
95
|
+
const statuses = /* @__PURE__ */ new Set();
|
|
96
|
+
items.forEach((item) => statuses.add(item.status));
|
|
97
|
+
return Array.from(statuses).sort();
|
|
98
|
+
}, [items]);
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swaps" }),
|
|
103
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "View and manage all customer swap requests" })
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadSwaps(0, true), children: "Refresh" })
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
+
ui.Input,
|
|
110
|
+
{
|
|
111
|
+
placeholder: "Search by swap ID or order ID",
|
|
112
|
+
value: searchQuery,
|
|
113
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
114
|
+
className: "md:max-w-sm"
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
118
|
+
"select",
|
|
119
|
+
{
|
|
120
|
+
value: statusFilter,
|
|
121
|
+
onChange: (event) => setStatusFilter(event.target.value),
|
|
122
|
+
className: "h-9 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 md:max-w-xs",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Statuses" }),
|
|
125
|
+
availableStatuses.map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
) })
|
|
129
|
+
] }),
|
|
130
|
+
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
ui.Button,
|
|
134
|
+
{
|
|
135
|
+
variant: "secondary",
|
|
136
|
+
onClick: () => loadSwaps(0, true),
|
|
137
|
+
children: "Try again"
|
|
138
|
+
}
|
|
139
|
+
) })
|
|
140
|
+
] }) : null,
|
|
141
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swaps..." }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No swaps yet" }),
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Swap requests created by customers will appear here." })
|
|
144
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Swap ID" }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Difference Due" }),
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
|
|
152
|
+
] }) }),
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((swap) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
154
|
+
"tr",
|
|
155
|
+
{
|
|
156
|
+
className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
|
|
157
|
+
onClick: () => navigate(`/swaps/${swap.id}`),
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: swap.id }) }) }),
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: swap.order_id }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
+
ui.Badge,
|
|
163
|
+
{
|
|
164
|
+
size: "2xsmall",
|
|
165
|
+
className: `uppercase ${getStatusBadgeClass$3(swap.status)}`,
|
|
166
|
+
children: swap.status.replace(/_/g, " ")
|
|
167
|
+
}
|
|
168
|
+
) }),
|
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: (() => {
|
|
170
|
+
const amount = swap.difference_due;
|
|
171
|
+
if (amount == null || amount === void 0) {
|
|
172
|
+
return "—";
|
|
173
|
+
}
|
|
174
|
+
const displayAmount = Number(amount) / 100;
|
|
175
|
+
const currency = swap.currency_code || "$";
|
|
176
|
+
const sign = displayAmount >= 0 ? "+" : "";
|
|
177
|
+
return `${sign}${currency}${displayAmount.toFixed(2)}`;
|
|
178
|
+
})() }),
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(swap.created_at).toLocaleDateString("en-US", {
|
|
180
|
+
year: "numeric",
|
|
181
|
+
month: "short",
|
|
182
|
+
day: "numeric",
|
|
183
|
+
hour: "numeric",
|
|
184
|
+
minute: "2-digit",
|
|
185
|
+
hour12: true
|
|
186
|
+
}) }),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
ui.Button,
|
|
189
|
+
{
|
|
190
|
+
variant: "transparent",
|
|
191
|
+
size: "small",
|
|
192
|
+
onClick: (e) => {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
navigate(`/swaps/${swap.id}`);
|
|
195
|
+
},
|
|
196
|
+
children: "View"
|
|
197
|
+
}
|
|
198
|
+
) })
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
swap.id
|
|
202
|
+
)) })
|
|
203
|
+
] }) }),
|
|
204
|
+
hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
205
|
+
ui.Button,
|
|
206
|
+
{
|
|
207
|
+
variant: "secondary",
|
|
208
|
+
isLoading: isFetchingMore,
|
|
209
|
+
onClick: () => loadSwaps(offset, false),
|
|
210
|
+
children: "Load more"
|
|
211
|
+
}
|
|
212
|
+
) }) : null
|
|
213
|
+
] }) });
|
|
214
|
+
};
|
|
215
|
+
const config$3 = adminSdk.defineRouteConfig({
|
|
216
|
+
label: "Swaps",
|
|
217
|
+
icon: icons.ArrowPath
|
|
218
|
+
});
|
|
8
219
|
const useDebounce = (value, delay) => {
|
|
9
220
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
10
221
|
react.useEffect(() => {
|
|
@@ -13,7 +224,7 @@ const useDebounce = (value, delay) => {
|
|
|
13
224
|
}, [value, delay]);
|
|
14
225
|
return debouncedValue;
|
|
15
226
|
};
|
|
16
|
-
const getStatusBadgeClass$
|
|
227
|
+
const getStatusBadgeClass$2 = (status) => {
|
|
17
228
|
const statusLower = status.toLowerCase();
|
|
18
229
|
if (statusLower === "requested") {
|
|
19
230
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -165,7 +376,7 @@ const ReturnsPage = () => {
|
|
|
165
376
|
ui.Badge,
|
|
166
377
|
{
|
|
167
378
|
size: "2xsmall",
|
|
168
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
379
|
+
className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
|
|
169
380
|
children: returnOrder.status.replace(/_/g, " ")
|
|
170
381
|
}
|
|
171
382
|
) }),
|
|
@@ -214,10 +425,412 @@ const ReturnsPage = () => {
|
|
|
214
425
|
) }) : null
|
|
215
426
|
] }) });
|
|
216
427
|
};
|
|
217
|
-
const config$
|
|
428
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
218
429
|
label: "Return Orders",
|
|
219
430
|
icon: icons.ArrowPath
|
|
220
431
|
});
|
|
432
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
433
|
+
const statusLower = status.toLowerCase();
|
|
434
|
+
if (statusLower === "requested") {
|
|
435
|
+
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
436
|
+
}
|
|
437
|
+
if (statusLower === "approved") {
|
|
438
|
+
return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
439
|
+
}
|
|
440
|
+
if (statusLower === "rejected") {
|
|
441
|
+
return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
442
|
+
}
|
|
443
|
+
if (statusLower === "completed") {
|
|
444
|
+
return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
445
|
+
}
|
|
446
|
+
if (statusLower === "cancelled") {
|
|
447
|
+
return "bg-ui-tag-grey-bg text-ui-tag-grey-text";
|
|
448
|
+
}
|
|
449
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
450
|
+
};
|
|
451
|
+
const SwapDetailPage = () => {
|
|
452
|
+
var _a, _b;
|
|
453
|
+
const navigate = reactRouterDom.useNavigate();
|
|
454
|
+
const { id } = reactRouterDom.useParams();
|
|
455
|
+
const [swap, setSwap] = react.useState(null);
|
|
456
|
+
const [order, setOrder] = react.useState(null);
|
|
457
|
+
const [selectedStatus, setSelectedStatus] = react.useState("");
|
|
458
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
459
|
+
const [isUpdating, setIsUpdating] = react.useState(false);
|
|
460
|
+
const [isApproving, setIsApproving] = react.useState(false);
|
|
461
|
+
const [isRejecting, setIsRejecting] = react.useState(false);
|
|
462
|
+
const [error, setError] = react.useState(null);
|
|
463
|
+
const [updateError, setUpdateError] = react.useState(null);
|
|
464
|
+
const [updateSuccess, setUpdateSuccess] = react.useState(false);
|
|
465
|
+
const availableStatuses = [
|
|
466
|
+
"requested",
|
|
467
|
+
"approved",
|
|
468
|
+
"rejected",
|
|
469
|
+
"return_started",
|
|
470
|
+
"return_shipped",
|
|
471
|
+
"return_received",
|
|
472
|
+
"new_items_shipped",
|
|
473
|
+
"completed",
|
|
474
|
+
"cancelled"
|
|
475
|
+
];
|
|
476
|
+
react.useEffect(() => {
|
|
477
|
+
if (!id) {
|
|
478
|
+
navigate("/swaps");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const loadSwap = async () => {
|
|
482
|
+
try {
|
|
483
|
+
setIsLoading(true);
|
|
484
|
+
setError(null);
|
|
485
|
+
const response = await fetch(`/admin/swaps/${id}`, {
|
|
486
|
+
credentials: "include"
|
|
487
|
+
});
|
|
488
|
+
if (!response.ok) {
|
|
489
|
+
const message = await response.text();
|
|
490
|
+
throw new Error(message || "Unable to load swap");
|
|
491
|
+
}
|
|
492
|
+
const payload = await response.json();
|
|
493
|
+
setSwap(payload.swap);
|
|
494
|
+
setOrder(payload.order || null);
|
|
495
|
+
setSelectedStatus("");
|
|
496
|
+
} catch (loadError) {
|
|
497
|
+
const message = loadError instanceof Error ? loadError.message : "Unable to load swap";
|
|
498
|
+
setError(message);
|
|
499
|
+
} finally {
|
|
500
|
+
setIsLoading(false);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
void loadSwap();
|
|
504
|
+
}, [id, navigate]);
|
|
505
|
+
const handleStatusUpdate = async () => {
|
|
506
|
+
if (!id || !selectedStatus) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
try {
|
|
510
|
+
setIsUpdating(true);
|
|
511
|
+
setUpdateError(null);
|
|
512
|
+
setUpdateSuccess(false);
|
|
513
|
+
const response = await fetch(`/admin/swaps/${id}/status`, {
|
|
514
|
+
method: "POST",
|
|
515
|
+
headers: {
|
|
516
|
+
"Content-Type": "application/json"
|
|
517
|
+
},
|
|
518
|
+
credentials: "include",
|
|
519
|
+
body: JSON.stringify({ status: selectedStatus })
|
|
520
|
+
});
|
|
521
|
+
if (!response.ok) {
|
|
522
|
+
const message = await response.text();
|
|
523
|
+
throw new Error(message || "Unable to update status");
|
|
524
|
+
}
|
|
525
|
+
const payload = await response.json();
|
|
526
|
+
setSwap(payload.swap);
|
|
527
|
+
setSelectedStatus("");
|
|
528
|
+
setUpdateSuccess(true);
|
|
529
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
530
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
531
|
+
credentials: "include"
|
|
532
|
+
});
|
|
533
|
+
if (detailResponse.ok) {
|
|
534
|
+
const detailPayload = await detailResponse.json();
|
|
535
|
+
setSwap(detailPayload.swap);
|
|
536
|
+
setOrder(detailPayload.order || null);
|
|
537
|
+
}
|
|
538
|
+
} catch (updateErr) {
|
|
539
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to update status";
|
|
540
|
+
setUpdateError(message);
|
|
541
|
+
} finally {
|
|
542
|
+
setIsUpdating(false);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const handleApprove = async () => {
|
|
546
|
+
if (!id) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
try {
|
|
550
|
+
setIsApproving(true);
|
|
551
|
+
setUpdateError(null);
|
|
552
|
+
setUpdateSuccess(false);
|
|
553
|
+
const response = await fetch(`/admin/swaps/${id}/approve`, {
|
|
554
|
+
method: "POST",
|
|
555
|
+
headers: {
|
|
556
|
+
"Content-Type": "application/json"
|
|
557
|
+
},
|
|
558
|
+
credentials: "include"
|
|
559
|
+
});
|
|
560
|
+
if (!response.ok) {
|
|
561
|
+
const message = await response.text();
|
|
562
|
+
throw new Error(message || "Unable to approve swap");
|
|
563
|
+
}
|
|
564
|
+
const payload = await response.json();
|
|
565
|
+
setSwap(payload.swap);
|
|
566
|
+
setUpdateSuccess(true);
|
|
567
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
568
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
569
|
+
credentials: "include"
|
|
570
|
+
});
|
|
571
|
+
if (detailResponse.ok) {
|
|
572
|
+
const detailPayload = await response.json();
|
|
573
|
+
setSwap(detailPayload.swap);
|
|
574
|
+
setOrder(detailPayload.order || null);
|
|
575
|
+
}
|
|
576
|
+
} catch (updateErr) {
|
|
577
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to approve swap";
|
|
578
|
+
setUpdateError(message);
|
|
579
|
+
} finally {
|
|
580
|
+
setIsApproving(false);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
const handleReject = async () => {
|
|
584
|
+
if (!id) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
setIsRejecting(true);
|
|
589
|
+
setUpdateError(null);
|
|
590
|
+
setUpdateSuccess(false);
|
|
591
|
+
const response = await fetch(`/admin/swaps/${id}/reject`, {
|
|
592
|
+
method: "POST",
|
|
593
|
+
headers: {
|
|
594
|
+
"Content-Type": "application/json"
|
|
595
|
+
},
|
|
596
|
+
credentials: "include",
|
|
597
|
+
body: JSON.stringify({ reason: "Rejected by admin" })
|
|
598
|
+
});
|
|
599
|
+
if (!response.ok) {
|
|
600
|
+
const message = await response.text();
|
|
601
|
+
throw new Error(message || "Unable to reject swap");
|
|
602
|
+
}
|
|
603
|
+
const payload = await response.json();
|
|
604
|
+
setSwap(payload.swap);
|
|
605
|
+
setUpdateSuccess(true);
|
|
606
|
+
setTimeout(() => setUpdateSuccess(false), 3e3);
|
|
607
|
+
const detailResponse = await fetch(`/admin/swaps/${id}`, {
|
|
608
|
+
credentials: "include"
|
|
609
|
+
});
|
|
610
|
+
if (detailResponse.ok) {
|
|
611
|
+
const detailPayload = await response.json();
|
|
612
|
+
setSwap(detailPayload.swap);
|
|
613
|
+
setOrder(detailPayload.order || null);
|
|
614
|
+
}
|
|
615
|
+
} catch (updateErr) {
|
|
616
|
+
const message = updateErr instanceof Error ? updateErr.message : "Unable to reject swap";
|
|
617
|
+
setUpdateError(message);
|
|
618
|
+
} finally {
|
|
619
|
+
setIsRejecting(false);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
if (isLoading) {
|
|
623
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading swap..." }) }) }) });
|
|
624
|
+
}
|
|
625
|
+
if (error || !swap) {
|
|
626
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
627
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error || "Swap not found" }),
|
|
628
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => navigate("/swaps"), children: "Back to list" }) })
|
|
629
|
+
] }) }) });
|
|
630
|
+
}
|
|
631
|
+
const statusHistory = ((_a = swap.metadata) == null ? void 0 : _a.status_history) || [];
|
|
632
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 p-6", children: [
|
|
633
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3", children: [
|
|
634
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
635
|
+
ui.Button,
|
|
636
|
+
{
|
|
637
|
+
variant: "transparent",
|
|
638
|
+
size: "small",
|
|
639
|
+
onClick: () => navigate("/swaps"),
|
|
640
|
+
className: "w-fit",
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowLeft, { className: "mr-2" }),
|
|
643
|
+
"Back to list"
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:flex-row md:items-center md:justify-between", children: [
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
649
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Swap Details" }),
|
|
650
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: swap.id })
|
|
651
|
+
] }),
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
653
|
+
ui.Badge,
|
|
654
|
+
{
|
|
655
|
+
size: "small",
|
|
656
|
+
className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
|
|
657
|
+
children: swap.status.replace(/_/g, " ")
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
] })
|
|
661
|
+
] }),
|
|
662
|
+
swap.status === "requested" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
663
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
664
|
+
ui.Button,
|
|
665
|
+
{
|
|
666
|
+
variant: "primary",
|
|
667
|
+
onClick: handleApprove,
|
|
668
|
+
disabled: isApproving || isRejecting,
|
|
669
|
+
isLoading: isApproving,
|
|
670
|
+
children: "Approve Swap"
|
|
671
|
+
}
|
|
672
|
+
),
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
674
|
+
ui.Button,
|
|
675
|
+
{
|
|
676
|
+
variant: "secondary",
|
|
677
|
+
onClick: handleReject,
|
|
678
|
+
disabled: isApproving || isRejecting,
|
|
679
|
+
isLoading: isRejecting,
|
|
680
|
+
children: "Reject Swap"
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
] }),
|
|
684
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Update Status" }),
|
|
686
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end", children: [
|
|
687
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
688
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "mb-2 block text-sm font-medium text-ui-fg-base", children: "New Status" }),
|
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
690
|
+
"select",
|
|
691
|
+
{
|
|
692
|
+
value: selectedStatus,
|
|
693
|
+
onChange: (event) => setSelectedStatus(event.target.value),
|
|
694
|
+
className: "h-9 w-full rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive",
|
|
695
|
+
children: [
|
|
696
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select new status" }),
|
|
697
|
+
availableStatuses.filter((status) => status !== swap.status).map((status) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: status, children: status.replace(/_/g, " ").toUpperCase() }, status))
|
|
698
|
+
]
|
|
699
|
+
}
|
|
700
|
+
)
|
|
701
|
+
] }),
|
|
702
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
703
|
+
ui.Button,
|
|
704
|
+
{
|
|
705
|
+
variant: "primary",
|
|
706
|
+
onClick: handleStatusUpdate,
|
|
707
|
+
disabled: !selectedStatus || isUpdating,
|
|
708
|
+
isLoading: isUpdating,
|
|
709
|
+
children: "Update Status"
|
|
710
|
+
}
|
|
711
|
+
)
|
|
712
|
+
] }),
|
|
713
|
+
updateError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-error", children: updateError }),
|
|
714
|
+
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-success", children: "Status updated successfully" })
|
|
715
|
+
] }),
|
|
716
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
|
|
717
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Swap Information" }),
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
721
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Swap ID" }),
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.id })
|
|
723
|
+
] }),
|
|
724
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Status" }),
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.status })
|
|
727
|
+
] }),
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Difference Due" }),
|
|
730
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.difference_due != null ? `${swap.currency_code || "$"}${(Number(swap.difference_due) / 100).toFixed(2)}` : "—" })
|
|
731
|
+
] }),
|
|
732
|
+
swap.reason && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Reason" }),
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.reason })
|
|
735
|
+
] }),
|
|
736
|
+
swap.note && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
737
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Note" }),
|
|
738
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: swap.note })
|
|
739
|
+
] }),
|
|
740
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
741
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Created" }),
|
|
742
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.created_at).toLocaleString() })
|
|
743
|
+
] }),
|
|
744
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
745
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Last Updated" }),
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: new Date(swap.updated_at).toLocaleString() })
|
|
747
|
+
] })
|
|
748
|
+
] })
|
|
749
|
+
] }),
|
|
750
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
751
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Status History" }),
|
|
752
|
+
statusHistory.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: statusHistory.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
753
|
+
"div",
|
|
754
|
+
{
|
|
755
|
+
className: "flex items-center justify-between border-b border-ui-border-subtle pb-2 last:border-0",
|
|
756
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
757
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
758
|
+
ui.Badge,
|
|
759
|
+
{
|
|
760
|
+
size: "2xsmall",
|
|
761
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
762
|
+
children: entry.status.replace(/_/g, " ")
|
|
763
|
+
}
|
|
764
|
+
) }),
|
|
765
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
766
|
+
new Date(entry.timestamp).toLocaleString(),
|
|
767
|
+
entry.admin_id && ` by ${entry.admin_id}`,
|
|
768
|
+
entry.reason && ` - ${entry.reason}`
|
|
769
|
+
] })
|
|
770
|
+
] })
|
|
771
|
+
},
|
|
772
|
+
index
|
|
773
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "No status history available" })
|
|
774
|
+
] })
|
|
775
|
+
] }),
|
|
776
|
+
order && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
777
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Related Order Information" }),
|
|
778
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
779
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
780
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order ID" }),
|
|
781
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.id })
|
|
782
|
+
] }),
|
|
783
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
784
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Status" }),
|
|
785
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: order.status || "—" })
|
|
786
|
+
] }),
|
|
787
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
788
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Customer" }),
|
|
789
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-medium", children: ((_b = order.customer) == null ? void 0 : _b.email) || order.email || "—" })
|
|
790
|
+
] }),
|
|
791
|
+
order.total && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
792
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Order Total" }),
|
|
793
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "font-medium", children: [
|
|
794
|
+
order.currency_code || "$",
|
|
795
|
+
(Number(order.total) / 100).toFixed(2)
|
|
796
|
+
] })
|
|
797
|
+
] })
|
|
798
|
+
] })
|
|
799
|
+
] }),
|
|
800
|
+
swap.return_items && swap.return_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
801
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "Return Items" }),
|
|
802
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
803
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
804
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Item ID" }),
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" }),
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Reason" })
|
|
807
|
+
] }) }),
|
|
808
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.return_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
809
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.id }),
|
|
810
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity }),
|
|
811
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.reason || "—" })
|
|
812
|
+
] }, item.id || index)) })
|
|
813
|
+
] }) })
|
|
814
|
+
] }),
|
|
815
|
+
swap.new_items && swap.new_items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-base p-6", children: [
|
|
816
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "mb-4 text-lg", children: "New Items" }),
|
|
817
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
|
|
818
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
819
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Variant ID" }),
|
|
820
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Quantity" })
|
|
821
|
+
] }) }),
|
|
822
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: swap.new_items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: item.variant_id }),
|
|
824
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: item.quantity })
|
|
825
|
+
] }, item.variant_id || index)) })
|
|
826
|
+
] }) })
|
|
827
|
+
] })
|
|
828
|
+
] }) });
|
|
829
|
+
};
|
|
830
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
831
|
+
label: "Swap Details",
|
|
832
|
+
icon: icons.ArrowPath
|
|
833
|
+
});
|
|
221
834
|
const getStatusBadgeClass = (status) => {
|
|
222
835
|
const statusLower = status.toLowerCase();
|
|
223
836
|
if (statusLower === "requested") {
|
|
@@ -535,10 +1148,18 @@ const i18nTranslations0 = {};
|
|
|
535
1148
|
const widgetModule = { widgets: [] };
|
|
536
1149
|
const routeModule = {
|
|
537
1150
|
routes: [
|
|
1151
|
+
{
|
|
1152
|
+
Component: SwapsPage,
|
|
1153
|
+
path: "/swaps"
|
|
1154
|
+
},
|
|
538
1155
|
{
|
|
539
1156
|
Component: ReturnsPage,
|
|
540
1157
|
path: "/returns"
|
|
541
1158
|
},
|
|
1159
|
+
{
|
|
1160
|
+
Component: SwapDetailPage,
|
|
1161
|
+
path: "/swaps/:id"
|
|
1162
|
+
},
|
|
542
1163
|
{
|
|
543
1164
|
Component: ReturnDetailPage,
|
|
544
1165
|
path: "/returns/:id"
|
|
@@ -548,16 +1169,28 @@ const routeModule = {
|
|
|
548
1169
|
const menuItemModule = {
|
|
549
1170
|
menuItems: [
|
|
550
1171
|
{
|
|
551
|
-
label: config$
|
|
552
|
-
icon: config$
|
|
1172
|
+
label: config$2.label,
|
|
1173
|
+
icon: config$2.icon,
|
|
553
1174
|
path: "/returns",
|
|
554
1175
|
nested: void 0
|
|
555
1176
|
},
|
|
1177
|
+
{
|
|
1178
|
+
label: config$3.label,
|
|
1179
|
+
icon: config$3.icon,
|
|
1180
|
+
path: "/swaps",
|
|
1181
|
+
nested: void 0
|
|
1182
|
+
},
|
|
556
1183
|
{
|
|
557
1184
|
label: config.label,
|
|
558
1185
|
icon: config.icon,
|
|
559
1186
|
path: "/returns/:id",
|
|
560
1187
|
nested: void 0
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
label: config$1.label,
|
|
1191
|
+
icon: config$1.icon,
|
|
1192
|
+
path: "/swaps/:id",
|
|
1193
|
+
nested: void 0
|
|
561
1194
|
}
|
|
562
1195
|
]
|
|
563
1196
|
};
|