|
1
|
import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared" |
|
2
|
import { useLoaderData, useParams } from "react-router-dom" |
|
3
|
|
|
4
|
import { useTaxRegion } from "../../../hooks/api/tax-regions" |
|
5
|
import { TaxRegionProvinceDetailSection } from "./components/tax-region-province-detail-section" |
|
6
|
|
|
7
|
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton" |
|
8
|
import { LayoutComposer, detailPageDefaultEntries } from "../../../components/layout-composer" |
|
9
|
import { TaxRegionProvinceOverrideSection } from "./components/tax-region-province-override-section" |
|
10
|
import { taxRegionLoader } from "./loader" |
|
11
|
|
|
12
|
export const TaxRegionDetail = () => { |
|
13
|
const { province_id } = useParams() |
|
14
|
|
|
15
|
const initialData = useLoaderData() as Awaited< |
|
16
|
ReturnType<typeof taxRegionLoader> |
|
17
|
> |
|
18
|
|
|
19
|
const { |
|
20
|
tax_region: taxRegion, |
|
21
|
isLoading, |
|
22
|
isError, |
|
23
|
error, |
|
24
|
} = useTaxRegion(province_id!, undefined, { initialData }) |
|
25
|
|
|
26
|
if (isLoading || !taxRegion) { |
|
27
|
return <SingleColumnPageSkeleton sections={2} showJSON /> |
|
28
|
} |
|
29
|
|
|
30
|
if (isError) { |
|
31
|
throw error |
|
32
|
} |
|
33
|
|
|
34
|
return ( |
|
35
|
<LayoutComposer |
|
36
|
widgetsZonePrefix="tax.details" |
|
37
|
preferredLayoutId={CORE_LAYOUT_IDS.SINGLE_COLUMN} |
|
38
|
data={taxRegion} |
|
39
|
sections={{ |
|
40
|
main: ( |
|
41
|
<> |
|
42
|
<LayoutComposer.Entry id="TaxRegionProvinceDetailSection"> |
|
43
|
<TaxRegionProvinceDetailSection taxRegion={taxRegion} /> |
|
44
|
</LayoutComposer.Entry> |
|
45
|
<LayoutComposer.Entry id="TaxRegionProvinceOverrideSection"> |
|
46
|
<TaxRegionProvinceOverrideSection taxRegion={taxRegion} /> |
|
47
|
</LayoutComposer.Entry> |
|
48
|
{detailPageDefaultEntries(taxRegion, { metadata: false, permissions: false })} |
|
49
|
</> |
|
50
|
), |
|
51
|
}} |
|
52
|
/> |
|
53
|
) |
|
54
|
} |