Skip to content

Commit edf29b3

Browse files
authored
feat(dashboard): select refund reason in refund form (medusajs#13587)
CLOSES CORE-1211 This PR quickly allows the user to select a refund a reason when creating a refund <img width="1106" height="1618" alt="CleanShot 2025-09-23 at 14 36 39@2x" src="https://github.com/user-attachments/assets/7cb9a53e-82ca-44d3-8267-874153f8d9ac" /> <img width="1870" height="1082" alt="CleanShot 2025-09-23 at 14 36 26@2x" src="https://github.com/user-attachments/assets/ea8d39b2-07e6-4295-ae52-da16b5d0d265" />
1 parent 294c375 commit edf29b3

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

.changeset/tame-gifts-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/dashboard": patch
3+
---
4+
5+
feat(dashboard): select refund reason in refund form

packages/admin/dashboard/src/routes/orders/order-create-refund/components/create-refund-form/create-refund-form.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import * as zod from "zod"
1717
import { Form } from "../../../../../components/common/form"
1818
import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
1919
import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
20-
import { useRefundPayment } from "../../../../../hooks/api"
20+
import { useRefundPayment, useRefundReasons } from "../../../../../hooks/api"
2121
import { currencies } from "../../../../../lib/data/currencies"
2222
import { formatCurrency } from "../../../../../lib/format-currency"
2323
import { formatProvider } from "../../../../../lib/format-provider"
@@ -35,11 +35,13 @@ const CreateRefundSchema = zod.object({
3535
float: zod.number().or(zod.null()),
3636
}),
3737
note: zod.string().optional(),
38+
refund_reason_id: zod.string().optional(),
3839
})
3940

4041
export const CreateRefundForm = ({ order }: CreateRefundFormProps) => {
4142
const { t } = useTranslation()
4243
const { handleSuccess } = useRouteModal()
44+
const { refund_reasons } = useRefundReasons()
4345

4446
const [searchParams] = useSearchParams()
4547
const [paymentId, setPaymentId] = useState<string | undefined>(
@@ -62,6 +64,7 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => {
6264
float: paymentAmount,
6365
},
6466
note: "",
67+
refund_reason_id: "",
6568
},
6669
resolver: zodResolver(CreateRefundSchema),
6770
})
@@ -90,6 +93,7 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => {
9093
{
9194
amount: data.amount.float!,
9295
note: data.note,
96+
refund_reason_id: data.refund_reason_id,
9397
},
9498
{
9599
onSuccess: () => {
@@ -208,6 +212,40 @@ export const CreateRefundForm = ({ order }: CreateRefundFormProps) => {
208212
}}
209213
/>
210214

215+
<Form.Field
216+
control={form.control}
217+
name="refund_reason_id"
218+
render={({ field }) => {
219+
return (
220+
<Form.Item>
221+
<Form.Label>{t("fields.refundReason")}</Form.Label>
222+
223+
<Form.Control>
224+
<Select
225+
dir={direction}
226+
value={field.value}
227+
onValueChange={field.onChange}
228+
>
229+
<Select.Trigger>
230+
<Select.Value />
231+
</Select.Trigger>
232+
233+
<Select.Content>
234+
{refund_reasons?.map((reason) => (
235+
<Select.Item key={reason.id} value={reason.id}>
236+
{reason.label}
237+
</Select.Item>
238+
))}
239+
</Select.Content>
240+
</Select>
241+
</Form.Control>
242+
243+
<Form.ErrorMessage />
244+
</Form.Item>
245+
)
246+
}}
247+
/>
248+
211249
<Form.Field
212250
control={form.control}
213251
name={`note`}

0 commit comments

Comments
 (0)