|
1
|
import { Heading } from "@medusajs/ui" |
|
2
|
import { useTranslation } from "react-i18next" |
|
3
|
import { useParams } from "react-router-dom" |
|
4
|
import { RouteDrawer } from "../../../components/modals" |
|
5
|
import { useRefundReason } from "../../../hooks/api/refund-reasons" |
|
6
|
import { RefundReasonEditForm } from "./components/refund-reason-edit-form" |
|
7
|
|
|
8
|
export const RefundReasonEdit = () => { |
|
9
|
const { id } = useParams() |
|
10
|
const { t } = useTranslation() |
|
11
|
|
|
12
|
const { refund_reason, isPending, isError, error } = useRefundReason(id!) |
|
13
|
|
|
14
|
const ready = !isPending && !!refund_reason |
|
15
|
|
|
16
|
if (isError) { |
|
17
|
throw error |
|
18
|
} |
|
19
|
|
|
20
|
return ( |
|
21
|
<RouteDrawer> |
|
22
|
<RouteDrawer.Header> |
|
23
|
<RouteDrawer.Title asChild> |
|
24
|
<Heading>{t("refundReasons.edit.header")}</Heading> |
|
25
|
</RouteDrawer.Title> |
|
26
|
<RouteDrawer.Description className="sr-only"> |
|
27
|
{t("refundReasons.edit.subtitle")} |
|
28
|
</RouteDrawer.Description> |
|
29
|
</RouteDrawer.Header> |
|
30
|
{ready && <RefundReasonEditForm refundReason={refund_reason} />} |
|
31
|
</RouteDrawer> |
|
32
|
) |
|
33
|
} |