From edf29b3bd22de1a0f6a7e4eb8715641cd17b7956 Mon Sep 17 00:00:00 2001 From: William Bouchard <46496014+willbouch@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:06:42 -0400 Subject: [PATCH] feat(dashboard): select refund reason in refund form (#13587) CLOSES CORE-1211 This PR quickly allows the user to select a refund a reason when creating a refund CleanShot 2025-09-23 at 14 36 39@2x CleanShot 2025-09-23 at 14 36 26@2x --- .changeset/tame-gifts-provide.md | 5 +++ .../create-refund-form/create-refund-form.tsx | 40 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .changeset/tame-gifts-provide.md diff --git a/.changeset/tame-gifts-provide.md b/.changeset/tame-gifts-provide.md new file mode 100644 index 0000000000..a9e11e6879 --- /dev/null +++ b/.changeset/tame-gifts-provide.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +feat(dashboard): select refund reason in refund form diff --git a/packages/admin/dashboard/src/routes/orders/order-create-refund/components/create-refund-form/create-refund-form.tsx b/packages/admin/dashboard/src/routes/orders/order-create-refund/components/create-refund-form/create-refund-form.tsx index b750e1030e..11c2b41f1a 100644 --- a/packages/admin/dashboard/src/routes/orders/order-create-refund/components/create-refund-form/create-refund-form.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-create-refund/components/create-refund-form/create-refund-form.tsx @@ -17,7 +17,7 @@ import * as zod from "zod" import { Form } from "../../../../../components/common/form" import { RouteDrawer, useRouteModal } from "../../../../../components/modals" import { KeyboundForm } from "../../../../../components/utilities/keybound-form" -import { useRefundPayment } from "../../../../../hooks/api" +import { useRefundPayment, useRefundReasons } from "../../../../../hooks/api" import { currencies } from "../../../../../lib/data/currencies" import { formatCurrency } from "../../../../../lib/format-currency" import { formatProvider } from "../../../../../lib/format-provider" @@ -35,11 +35,13 @@ const CreateRefundSchema = zod.object({ float: zod.number().or(zod.null()), }), note: zod.string().optional(), + refund_reason_id: zod.string().optional(), }) export const CreateRefundForm = ({ order }: CreateRefundFormProps) => { const { t } = useTranslation() const { handleSuccess } = useRouteModal() + const { refund_reasons } = useRefundReasons() const [searchParams] = useSearchParams() const [paymentId, setPaymentId] = useState( @@ -62,6 +64,7 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => { float: paymentAmount, }, note: "", + refund_reason_id: "", }, resolver: zodResolver(CreateRefundSchema), }) @@ -90,6 +93,7 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => { { amount: data.amount.float!, note: data.note, + refund_reason_id: data.refund_reason_id, }, { onSuccess: () => { @@ -208,6 +212,40 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => { }} /> + { + return ( + + {t("fields.refundReason")} + + + + + + + + ) + }} + /> +