|
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 { useSalesChannel } from "../../../hooks/api/sales-channels" |
|
7
|
import { SalesChannelGeneralSection } from "./components/sales-channel-general-section" |
|
8
|
import { SalesChannelProductSection } from "./components/sales-channel-product-section" |
|
9
|
import { salesChannelLoader } from "./loader" |
|
10
|
|
|
11
|
export const SalesChannelDetail = () => { |
|
12
|
const initialData = useLoaderData() as Awaited< |
|
13
|
ReturnType<typeof salesChannelLoader> |
|
14
|
> |
|
15
|
|
|
16
|
const { id } = useParams() |
|
17
|
const { sales_channel, isPending: isLoading } = useSalesChannel(id!, { |
|
18
|
initialData, |
|
19
|
}) |
|
20
|
|
|
21
|
if (isLoading || !sales_channel) { |
|
22
|
return <SingleColumnPageSkeleton sections={2} showJSON showMetadata /> |
|
23
|
} |
|
24
|
|
|
25
|
return ( |
|
26
|
<LayoutComposer |
|
27
|
widgetsZonePrefix="sales_channel.details" |
|
28
|
preferredLayoutId={CORE_LAYOUT_IDS.SINGLE_COLUMN} |
|
29
|
data={sales_channel} |
|
30
|
sections={{ |
|
31
|
main: ( |
|
32
|
<> |
|
33
|
<LayoutComposer.Entry id="SalesChannelGeneralSection"> |
|
34
|
<SalesChannelGeneralSection salesChannel={sales_channel} /> |
|
35
|
</LayoutComposer.Entry> |
|
36
|
<LayoutComposer.Entry id="SalesChannelProductSection"> |
|
37
|
<SalesChannelProductSection salesChannel={sales_channel} /> |
|
38
|
</LayoutComposer.Entry> |
|
39
|
{detailPageDefaultEntries(sales_channel, { permissions: false })} |
|
40
|
</> |
|
41
|
), |
|
42
|
}} |
|
43
|
/> |
|
44
|
) |
|
45
|
} |