|
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 { useTaxRate } from "../../../hooks/api/tax-rates" |
|
6
|
import { TaxRegionTaxRateEditForm } from "./components/tax-region-tax-rate-edit-form" |
|
7
|
|
|
8
|
export const TaxRegionEdit = () => { |
|
9
|
const { t } = useTranslation() |
|
10
|
const { province_id, tax_rate_id } = useParams() |
|
11
|
|
|
12
|
const { tax_rate, isPending, isError, error } = useTaxRate(tax_rate_id!) |
|
13
|
|
|
14
|
const ready = !isPending && !!tax_rate |
|
15
|
|
|
16
|
if (isError) { |
|
17
|
throw error |
|
18
|
} |
|
19
|
|
|
20
|
return ( |
|
21
|
<RouteDrawer> |
|
22
|
<RouteDrawer.Header> |
|
23
|
<RouteDrawer.Title asChild> |
|
24
|
<Heading>{t("taxRegions.taxRates.edit.header")}</Heading> |
|
25
|
</RouteDrawer.Title> |
|
26
|
<RouteDrawer.Description className="sr-only"> |
|
27
|
{t("taxRegions.taxRates.edit.hint")} |
|
28
|
</RouteDrawer.Description> |
|
29
|
</RouteDrawer.Header> |
|
30
|
{ready && ( |
|
31
|
<TaxRegionTaxRateEditForm |
|
32
|
taxRate={tax_rate} |
|
33
|
isSublevel={!!province_id} |
|
34
|
/> |
|
35
|
)} |
|
36
|
</RouteDrawer> |
|
37
|
) |
|
38
|
} |