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