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