|
1
|
import { useParams } from "react-router-dom" |
|
2
|
import { RouteFocusModal } from "../../../components/modals" |
|
3
|
import { useTaxRegion } from "../../../hooks/api/tax-regions" |
|
4
|
import { TaxRegionTaxRateCreateForm } from "./components/tax-region-tax-rate-create-form" |
|
5
|
|
|
6
|
export const TaxRegionTaxRateCreate = () => { |
|
7
|
const { id, province_id } = useParams() |
|
8
|
|
|
9
|
const { tax_region, isPending, isError, error } = useTaxRegion( |
|
10
|
province_id || id! |
|
11
|
) |
|
12
|
|
|
13
|
const ready = !isPending && !!tax_region |
|
14
|
|
|
15
|
if (isError) { |
|
16
|
throw error |
|
17
|
} |
|
18
|
|
|
19
|
return ( |
|
20
|
<RouteFocusModal> |
|
21
|
{ready && ( |
|
22
|
<TaxRegionTaxRateCreateForm |
|
23
|
taxRegion={tax_region} |
|
24
|
isSublevel={!!province_id} |
|
25
|
/> |
|
26
|
)} |
|
27
|
</RouteFocusModal> |
|
28
|
) |
|
29
|
} |