order-management 0.0.102 → 0.0.104
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 +210 -210
- package/.medusa/server/src/admin/index.mjs +210 -210
- package/.medusa/server/src/api/middlewares/inject-return-shipping.js +54 -0
- package/.medusa/server/src/api/middlewares.js +7 -1
- package/.medusa/server/src/api/store/returns/route.js +19 -8
- package/.medusa/server/src/helpers/ensure-return-to-store-option.js +255 -0
- package/.medusa/server/src/helpers/index.js +2 -1
- package/.medusa/server/src/helpers/returns.js +88 -1
- package/.medusa/server/src/utils/order-fulfillment-metadata.js +3 -2
- package/package.json +2 -1
|
@@ -4039,197 +4039,6 @@ const config$3 = adminSdk.defineRouteConfig({
|
|
|
4039
4039
|
icon: icons.CreditCard
|
|
4040
4040
|
});
|
|
4041
4041
|
const getStatusBadgeClass$2 = (status) => {
|
|
4042
|
-
const s2 = status.toLowerCase();
|
|
4043
|
-
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4044
|
-
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4045
|
-
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
4046
|
-
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4047
|
-
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
4048
|
-
};
|
|
4049
|
-
const formatAmount = (value) => {
|
|
4050
|
-
return String(value);
|
|
4051
|
-
};
|
|
4052
|
-
const RefundDetailPage = () => {
|
|
4053
|
-
const navigate = reactRouterDom.useNavigate();
|
|
4054
|
-
const params = reactRouterDom.useParams();
|
|
4055
|
-
const id = params?.id?.trim();
|
|
4056
|
-
const [detail, setDetail] = react.useState(null);
|
|
4057
|
-
const [loading, setLoading] = react.useState(!!id);
|
|
4058
|
-
const [error, setError] = react.useState(null);
|
|
4059
|
-
const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
|
|
4060
|
-
react.useEffect(() => {
|
|
4061
|
-
if (!id) {
|
|
4062
|
-
setLoading(false);
|
|
4063
|
-
return;
|
|
4064
|
-
}
|
|
4065
|
-
let cancelled = false;
|
|
4066
|
-
setLoading(true);
|
|
4067
|
-
setError(null);
|
|
4068
|
-
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
4069
|
-
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
4070
|
-
return res.json();
|
|
4071
|
-
}).then((data) => {
|
|
4072
|
-
if (!cancelled) setDetail(data);
|
|
4073
|
-
}).catch((e) => {
|
|
4074
|
-
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
4075
|
-
}).finally(() => {
|
|
4076
|
-
if (!cancelled) setLoading(false);
|
|
4077
|
-
});
|
|
4078
|
-
return () => {
|
|
4079
|
-
cancelled = true;
|
|
4080
|
-
};
|
|
4081
|
-
}, [id]);
|
|
4082
|
-
const paymentStatus = detail?.payment?.status ?? "—";
|
|
4083
|
-
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
4084
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
4085
|
-
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4086
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
4087
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
|
|
4088
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
4089
|
-
] }) }),
|
|
4090
|
-
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
4091
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
4092
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
4093
|
-
] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
4094
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4095
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
4096
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4097
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4098
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
4099
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
4100
|
-
] }),
|
|
4101
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4102
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
4103
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
4104
|
-
] }),
|
|
4105
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4106
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
4107
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
4108
|
-
] }),
|
|
4109
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4110
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
4111
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
4112
|
-
year: "numeric",
|
|
4113
|
-
month: "short",
|
|
4114
|
-
day: "numeric",
|
|
4115
|
-
hour: "numeric",
|
|
4116
|
-
minute: "2-digit",
|
|
4117
|
-
hour12: true
|
|
4118
|
-
}) })
|
|
4119
|
-
] }),
|
|
4120
|
-
detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4121
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
4122
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
4123
|
-
] }) : null
|
|
4124
|
-
] })
|
|
4125
|
-
] }),
|
|
4126
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4127
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
4128
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4129
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4130
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
4131
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
4132
|
-
] }),
|
|
4133
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4134
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
4135
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
4136
|
-
] }),
|
|
4137
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4138
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
4139
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
4140
|
-
] }),
|
|
4141
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4142
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
4143
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
4144
|
-
] }),
|
|
4145
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4146
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
4147
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4148
|
-
ui.Badge,
|
|
4149
|
-
{
|
|
4150
|
-
size: "2xsmall",
|
|
4151
|
-
className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
|
|
4152
|
-
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
4153
|
-
}
|
|
4154
|
-
) })
|
|
4155
|
-
] }),
|
|
4156
|
-
detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4157
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4158
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
4159
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
4160
|
-
] }),
|
|
4161
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4162
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
4163
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
4164
|
-
] }),
|
|
4165
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4166
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
4167
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
|
|
4168
|
-
detail.computed.refund_percentage.toFixed(1),
|
|
4169
|
-
"%"
|
|
4170
|
-
] })
|
|
4171
|
-
] })
|
|
4172
|
-
] }) : null
|
|
4173
|
-
] })
|
|
4174
|
-
] }),
|
|
4175
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4176
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
4177
|
-
detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4178
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4179
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
4180
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4181
|
-
ui.Button,
|
|
4182
|
-
{
|
|
4183
|
-
variant: "transparent",
|
|
4184
|
-
size: "small",
|
|
4185
|
-
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
4186
|
-
children: detail.order.order_number ?? detail.order.order_id
|
|
4187
|
-
}
|
|
4188
|
-
) })
|
|
4189
|
-
] }),
|
|
4190
|
-
detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4191
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
4192
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
4193
|
-
] }) : null,
|
|
4194
|
-
detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4195
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
4196
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
4197
|
-
] }) : null,
|
|
4198
|
-
detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4199
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
4200
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
|
|
4201
|
-
] }) : null,
|
|
4202
|
-
detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4203
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
4204
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
4205
|
-
] }) : null
|
|
4206
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
4207
|
-
] }),
|
|
4208
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4209
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4210
|
-
"button",
|
|
4211
|
-
{
|
|
4212
|
-
type: "button",
|
|
4213
|
-
className: "flex w-full items-center justify-between text-left",
|
|
4214
|
-
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
4215
|
-
"aria-expanded": gatewayExpanded,
|
|
4216
|
-
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
4217
|
-
children: [
|
|
4218
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
4219
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
4220
|
-
]
|
|
4221
|
-
}
|
|
4222
|
-
),
|
|
4223
|
-
gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
4224
|
-
] })
|
|
4225
|
-
] }) : null
|
|
4226
|
-
] }) });
|
|
4227
|
-
};
|
|
4228
|
-
const config$2 = adminSdk.defineRouteConfig({
|
|
4229
|
-
label: "Refund details",
|
|
4230
|
-
icon: icons.Receipt
|
|
4231
|
-
});
|
|
4232
|
-
const getStatusBadgeClass$1 = (status) => {
|
|
4233
4042
|
const statusLower = status.toLowerCase();
|
|
4234
4043
|
if (statusLower === "requested") {
|
|
4235
4044
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -4362,7 +4171,7 @@ const ReturnDetailPage = () => {
|
|
|
4362
4171
|
ui.Badge,
|
|
4363
4172
|
{
|
|
4364
4173
|
size: "small",
|
|
4365
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4174
|
+
className: `uppercase ${getStatusBadgeClass$2(returnOrder.status)}`,
|
|
4366
4175
|
children: returnOrder.status.replace(/_/g, " ")
|
|
4367
4176
|
}
|
|
4368
4177
|
)
|
|
@@ -4445,7 +4254,7 @@ const ReturnDetailPage = () => {
|
|
|
4445
4254
|
ui.Badge,
|
|
4446
4255
|
{
|
|
4447
4256
|
size: "2xsmall",
|
|
4448
|
-
className: `uppercase ${getStatusBadgeClass$
|
|
4257
|
+
className: `uppercase ${getStatusBadgeClass$2(entry.status)}`,
|
|
4449
4258
|
children: entry.status.replace(/_/g, " ")
|
|
4450
4259
|
}
|
|
4451
4260
|
) }),
|
|
@@ -4507,11 +4316,11 @@ const ReturnDetailPage = () => {
|
|
|
4507
4316
|
updateSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-ui-border-success bg-ui-bg-success-subtle p-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-success", children: "Action completed successfully" }) })
|
|
4508
4317
|
] }) });
|
|
4509
4318
|
};
|
|
4510
|
-
const config$
|
|
4319
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
4511
4320
|
label: "Return Order Details",
|
|
4512
4321
|
icon: icons.CheckCircle
|
|
4513
4322
|
});
|
|
4514
|
-
const getStatusBadgeClass = (status) => {
|
|
4323
|
+
const getStatusBadgeClass$1 = (status) => {
|
|
4515
4324
|
const statusLower = status.toLowerCase();
|
|
4516
4325
|
if (statusLower === "requested") {
|
|
4517
4326
|
return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
@@ -4648,7 +4457,7 @@ const SwapDetailPage = () => {
|
|
|
4648
4457
|
ui.Badge,
|
|
4649
4458
|
{
|
|
4650
4459
|
size: "small",
|
|
4651
|
-
className: `uppercase ${getStatusBadgeClass(swap.status)}`,
|
|
4460
|
+
className: `uppercase ${getStatusBadgeClass$1(swap.status)}`,
|
|
4652
4461
|
children: swap.status.replace(/_/g, " ")
|
|
4653
4462
|
}
|
|
4654
4463
|
)
|
|
@@ -4716,7 +4525,7 @@ const SwapDetailPage = () => {
|
|
|
4716
4525
|
ui.Badge,
|
|
4717
4526
|
{
|
|
4718
4527
|
size: "2xsmall",
|
|
4719
|
-
className: `uppercase ${getStatusBadgeClass(entry.status)}`,
|
|
4528
|
+
className: `uppercase ${getStatusBadgeClass$1(entry.status)}`,
|
|
4720
4529
|
children: entry.status.replace(/_/g, " ")
|
|
4721
4530
|
}
|
|
4722
4531
|
) }),
|
|
@@ -4785,10 +4594,201 @@ const SwapDetailPage = () => {
|
|
|
4785
4594
|
] })
|
|
4786
4595
|
] }) });
|
|
4787
4596
|
};
|
|
4788
|
-
const config = adminSdk.defineRouteConfig({
|
|
4597
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
4789
4598
|
label: "Swap Details",
|
|
4790
4599
|
icon: icons.ArrowPath
|
|
4791
4600
|
});
|
|
4601
|
+
const getStatusBadgeClass = (status) => {
|
|
4602
|
+
const s2 = status.toLowerCase();
|
|
4603
|
+
if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
|
|
4604
|
+
if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
|
|
4605
|
+
if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
|
|
4606
|
+
if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
|
|
4607
|
+
return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
|
|
4608
|
+
};
|
|
4609
|
+
const formatAmount = (value) => {
|
|
4610
|
+
return String(value);
|
|
4611
|
+
};
|
|
4612
|
+
const RefundDetailPage = () => {
|
|
4613
|
+
const navigate = reactRouterDom.useNavigate();
|
|
4614
|
+
const params = reactRouterDom.useParams();
|
|
4615
|
+
const id = params?.id?.trim();
|
|
4616
|
+
const [detail, setDetail] = react.useState(null);
|
|
4617
|
+
const [loading, setLoading] = react.useState(!!id);
|
|
4618
|
+
const [error, setError] = react.useState(null);
|
|
4619
|
+
const [gatewayExpanded, setGatewayExpanded] = react.useState(false);
|
|
4620
|
+
react.useEffect(() => {
|
|
4621
|
+
if (!id) {
|
|
4622
|
+
setLoading(false);
|
|
4623
|
+
return;
|
|
4624
|
+
}
|
|
4625
|
+
let cancelled = false;
|
|
4626
|
+
setLoading(true);
|
|
4627
|
+
setError(null);
|
|
4628
|
+
fetch(`/admin/refunds/${id}`, { credentials: "include" }).then((res) => {
|
|
4629
|
+
if (!res.ok) throw new Error(res.statusText || "Failed to load");
|
|
4630
|
+
return res.json();
|
|
4631
|
+
}).then((data) => {
|
|
4632
|
+
if (!cancelled) setDetail(data);
|
|
4633
|
+
}).catch((e) => {
|
|
4634
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
|
|
4635
|
+
}).finally(() => {
|
|
4636
|
+
if (!cancelled) setLoading(false);
|
|
4637
|
+
});
|
|
4638
|
+
return () => {
|
|
4639
|
+
cancelled = true;
|
|
4640
|
+
};
|
|
4641
|
+
}, [id]);
|
|
4642
|
+
const paymentStatus = detail?.payment?.status ?? "—";
|
|
4643
|
+
const hasGatewayData = detail?.payment?.payment_data && typeof detail.payment.payment_data === "object" && Object.keys(detail.payment.payment_data).length > 0;
|
|
4644
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
|
|
4645
|
+
/* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
4646
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/refunds"), children: "← Refunds" }),
|
|
4647
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refund details" }),
|
|
4648
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle font-mono", children: id ?? "—" })
|
|
4649
|
+
] }) }),
|
|
4650
|
+
error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
|
|
4651
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
|
|
4652
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/refunds"), children: "Back to list" })
|
|
4653
|
+
] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
4654
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4655
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Refund summary" }),
|
|
4656
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4657
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4658
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund ID" }),
|
|
4659
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.id })
|
|
4660
|
+
] }),
|
|
4661
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4662
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
|
|
4663
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.refund.amount) })
|
|
4664
|
+
] }),
|
|
4665
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4666
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Note" }),
|
|
4667
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.refund.note ?? "—" })
|
|
4668
|
+
] }),
|
|
4669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4670
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created at" }),
|
|
4671
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.refund.created_at).toLocaleDateString("en-US", {
|
|
4672
|
+
year: "numeric",
|
|
4673
|
+
month: "short",
|
|
4674
|
+
day: "numeric",
|
|
4675
|
+
hour: "numeric",
|
|
4676
|
+
minute: "2-digit",
|
|
4677
|
+
hour12: true
|
|
4678
|
+
}) })
|
|
4679
|
+
] }),
|
|
4680
|
+
detail.refund.created_by ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4681
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created by" }),
|
|
4682
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.refund.created_by })
|
|
4683
|
+
] }) : null
|
|
4684
|
+
] })
|
|
4685
|
+
] }),
|
|
4686
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4687
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Payment summary" }),
|
|
4688
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4689
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4690
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment amount" }),
|
|
4691
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.payment_amount) })
|
|
4692
|
+
] }),
|
|
4693
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4694
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Captured amount" }),
|
|
4695
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.captured_amount) })
|
|
4696
|
+
] }),
|
|
4697
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4698
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refunded amount" }),
|
|
4699
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.payment.refunded_amount) })
|
|
4700
|
+
] }),
|
|
4701
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4702
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
|
|
4703
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment.provider_id || "—" })
|
|
4704
|
+
] }),
|
|
4705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4706
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
|
|
4707
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4708
|
+
ui.Badge,
|
|
4709
|
+
{
|
|
4710
|
+
size: "2xsmall",
|
|
4711
|
+
className: `uppercase ${getStatusBadgeClass(paymentStatus)}`,
|
|
4712
|
+
children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
|
|
4713
|
+
}
|
|
4714
|
+
) })
|
|
4715
|
+
] }),
|
|
4716
|
+
detail.computed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4717
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4718
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Full refund" }),
|
|
4719
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.computed.is_full_refund ? "Yes" : "No" })
|
|
4720
|
+
] }),
|
|
4721
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4722
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Remaining refundable" }),
|
|
4723
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.computed.remaining_refundable_amount) })
|
|
4724
|
+
] }),
|
|
4725
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4726
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Refund %" }),
|
|
4727
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "mt-1 block", children: [
|
|
4728
|
+
detail.computed.refund_percentage.toFixed(1),
|
|
4729
|
+
"%"
|
|
4730
|
+
] })
|
|
4731
|
+
] })
|
|
4732
|
+
] }) : null
|
|
4733
|
+
] })
|
|
4734
|
+
] }),
|
|
4735
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4736
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Order summary" }),
|
|
4737
|
+
detail.order ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
4738
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4739
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order" }),
|
|
4740
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4741
|
+
ui.Button,
|
|
4742
|
+
{
|
|
4743
|
+
variant: "transparent",
|
|
4744
|
+
size: "small",
|
|
4745
|
+
onClick: () => navigate(`/orders/${detail.order.order_id}`),
|
|
4746
|
+
children: detail.order.order_number ?? detail.order.order_id
|
|
4747
|
+
}
|
|
4748
|
+
) })
|
|
4749
|
+
] }),
|
|
4750
|
+
detail.order.total != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4751
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Total" }),
|
|
4752
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: formatAmount(detail.order.total) })
|
|
4753
|
+
] }) : null,
|
|
4754
|
+
detail.order.customer_id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4755
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Customer ID" }),
|
|
4756
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block font-mono text-sm", children: detail.order.customer_id })
|
|
4757
|
+
] }) : null,
|
|
4758
|
+
detail.order.region ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4759
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Region" }),
|
|
4760
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.region })
|
|
4761
|
+
] }) : null,
|
|
4762
|
+
detail.order.fulfillment_status ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4763
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Fulfillment status" }),
|
|
4764
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.order.fulfillment_status })
|
|
4765
|
+
] }) : null
|
|
4766
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No order linked to this refund." })
|
|
4767
|
+
] }),
|
|
4768
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
|
|
4769
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4770
|
+
"button",
|
|
4771
|
+
{
|
|
4772
|
+
type: "button",
|
|
4773
|
+
className: "flex w-full items-center justify-between text-left",
|
|
4774
|
+
onClick: () => setGatewayExpanded((prev) => !prev),
|
|
4775
|
+
"aria-expanded": gatewayExpanded,
|
|
4776
|
+
"aria-label": gatewayExpanded ? "Collapse gateway data" : "Expand gateway data",
|
|
4777
|
+
children: [
|
|
4778
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg", children: "Gateway data" }),
|
|
4779
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: gatewayExpanded ? "Collapse" : "Expand" })
|
|
4780
|
+
]
|
|
4781
|
+
}
|
|
4782
|
+
),
|
|
4783
|
+
gatewayExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4", children: hasGatewayData ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.payment.payment_data, null, 2) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No gateway payload for this payment." }) })
|
|
4784
|
+
] })
|
|
4785
|
+
] }) : null
|
|
4786
|
+
] }) });
|
|
4787
|
+
};
|
|
4788
|
+
const config = adminSdk.defineRouteConfig({
|
|
4789
|
+
label: "Refund details",
|
|
4790
|
+
icon: icons.Receipt
|
|
4791
|
+
});
|
|
4792
4792
|
const i18nTranslations0 = {};
|
|
4793
4793
|
const widgetModule = { widgets: [
|
|
4794
4794
|
{
|
|
@@ -4839,19 +4839,19 @@ const routeModule = {
|
|
|
4839
4839
|
path: "/payments/:id",
|
|
4840
4840
|
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
4841
4841
|
},
|
|
4842
|
-
{
|
|
4843
|
-
Component: RefundDetailPage,
|
|
4844
|
-
path: "/refunds/:id",
|
|
4845
|
-
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
4846
|
-
},
|
|
4847
4842
|
{
|
|
4848
4843
|
Component: ReturnDetailPage,
|
|
4849
4844
|
path: "/returns/:id",
|
|
4850
|
-
handle: { label: config$
|
|
4845
|
+
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
4851
4846
|
},
|
|
4852
4847
|
{
|
|
4853
4848
|
Component: SwapDetailPage,
|
|
4854
4849
|
path: "/swaps/:id",
|
|
4850
|
+
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
4851
|
+
},
|
|
4852
|
+
{
|
|
4853
|
+
Component: RefundDetailPage,
|
|
4854
|
+
path: "/refunds/:id",
|
|
4855
4855
|
handle: { label: config.label, translationNs: config.translationNs }
|
|
4856
4856
|
}
|
|
4857
4857
|
]
|
|
@@ -4907,24 +4907,24 @@ const menuItemModule = {
|
|
|
4907
4907
|
translationNs: void 0
|
|
4908
4908
|
},
|
|
4909
4909
|
{
|
|
4910
|
-
label: config
|
|
4911
|
-
icon: config
|
|
4910
|
+
label: config.label,
|
|
4911
|
+
icon: config.icon,
|
|
4912
4912
|
path: "/refunds/:id",
|
|
4913
4913
|
nested: void 0,
|
|
4914
4914
|
rank: void 0,
|
|
4915
4915
|
translationNs: void 0
|
|
4916
4916
|
},
|
|
4917
4917
|
{
|
|
4918
|
-
label: config$
|
|
4919
|
-
icon: config$
|
|
4918
|
+
label: config$2.label,
|
|
4919
|
+
icon: config$2.icon,
|
|
4920
4920
|
path: "/returns/:id",
|
|
4921
4921
|
nested: void 0,
|
|
4922
4922
|
rank: void 0,
|
|
4923
4923
|
translationNs: void 0
|
|
4924
4924
|
},
|
|
4925
4925
|
{
|
|
4926
|
-
label: config.label,
|
|
4927
|
-
icon: config.icon,
|
|
4926
|
+
label: config$1.label,
|
|
4927
|
+
icon: config$1.icon,
|
|
4928
4928
|
path: "/swaps/:id",
|
|
4929
4929
|
nested: void 0,
|
|
4930
4930
|
rank: void 0,
|