|
1
|
import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared" |
|
2
|
import { useLoaderData, useParams } from "react-router-dom" |
|
3
|
|
|
4
|
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton" |
|
5
|
import { LayoutComposer, detailPageDefaultEntries } from "../../../components/layout-composer" |
|
6
|
import { useShippingProfile } from "../../../hooks/api/shipping-profiles" |
|
7
|
import { ShippingProfileGeneralSection } from "./components/shipping-profile-general-section" |
|
8
|
|
|
9
|
import { shippingProfileLoader } from "./loader" |
|
10
|
|
|
11
|
export const ShippingProfileDetail = () => { |
|
12
|
const { shipping_profile_id } = useParams() |
|
13
|
|
|
14
|
const initialData = useLoaderData() as Awaited< |
|
15
|
ReturnType<typeof shippingProfileLoader> |
|
16
|
> |
|
17
|
|
|
18
|
const { shipping_profile, isLoading, isError, error } = useShippingProfile( |
|
19
|
shipping_profile_id!, |
|
20
|
undefined, |
|
21
|
{ initialData } |
|
22
|
) |
|
23
|
|
|
24
|
if (isLoading || !shipping_profile) { |
|
25
|
return <SingleColumnPageSkeleton sections={1} showJSON showMetadata /> |
|
26
|
} |
|
27
|
|
|
28
|
if (isError) { |
|
29
|
throw error |
|
30
|
} |
|
31
|
|
|
32
|
return ( |
|
33
|
<LayoutComposer |
|
34
|
widgetsZonePrefix="shipping_profile.details" |
|
35
|
preferredLayoutId={CORE_LAYOUT_IDS.SINGLE_COLUMN} |
|
36
|
data={shipping_profile} |
|
37
|
sections={{ |
|
38
|
main: ( |
|
39
|
<> |
|
40
|
<LayoutComposer.Entry id="ShippingProfileGeneralSection"> |
|
41
|
<ShippingProfileGeneralSection profile={shipping_profile} /> |
|
42
|
</LayoutComposer.Entry> |
|
43
|
{detailPageDefaultEntries(shipping_profile, { permissions: false })} |
|
44
|
</> |
|
45
|
), |
|
46
|
}} |
|
47
|
/> |
|
48
|
) |
|
49
|
} |