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")} + + + + + + + + ) + }} + /> +