|
1
|
import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared" |
|
2
|
import { useParams } from "react-router-dom" |
|
3
|
|
|
4
|
import { usePriceList } from "../../../hooks/api/price-lists" |
|
5
|
import { PriceListConfigurationSection } from "./components/price-list-configuration-section" |
|
6
|
import { PriceListGeneralSection } from "./components/price-list-general-section" |
|
7
|
import { PriceListProductSection } from "./components/price-list-product-section" |
|
8
|
import { ConfigurablePriceListProductSection } from "./components/price-list-product-section/configurable-price-list-product-section" |
|
9
|
|
|
10
|
import { TwoColumnPageSkeleton } from "../../../components/common/skeleton" |
|
11
|
import { |
|
12
|
LayoutComposer, |
|
13
|
detailPageDefaultEntries, |
|
14
|
} from "../../../components/layout-composer" |
|
15
|
import { useFeatureFlag } from "../../../providers/feature-flag-provider" |
|
16
|
|
|
17
|
export const PriceListDetails = () => { |
|
18
|
const { id } = useParams() |
|
19
|
const isViewConfigEnabled = useFeatureFlag("view_configurations") |
|
20
|
|
|
21
|
const { price_list, isLoading, isError, error } = usePriceList(id!) |
|
22
|
|
|
23
|
if (isLoading || !price_list) { |
|
24
|
return ( |
|
25
|
<TwoColumnPageSkeleton |
|
26
|
mainSections={2} |
|
27
|
sidebarSections={1} |
|
28
|
showJSON |
|
29
|
showMetadata |
|
30
|
/> |
|
31
|
) |
|
32
|
} |
|
33
|
|
|
34
|
if (isError) { |
|
35
|
throw error |
|
36
|
} |
|
37
|
|
|
38
|
return ( |
|
39
|
<LayoutComposer |
|
40
|
widgetsZonePrefix="price_list.details" |
|
41
|
preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN} |
|
42
|
data={price_list} |
|
43
|
sections={{ |
|
44
|
main: ( |
|
45
|
<> |
|
46
|
<LayoutComposer.Entry id="PriceListGeneralSection"> |
|
47
|
<PriceListGeneralSection priceList={price_list} /> |
|
48
|
</LayoutComposer.Entry> |
|
49
|
<LayoutComposer.Entry id="PriceListProductSection"> |
|
50
|
{isViewConfigEnabled ? ( |
|
51
|
<ConfigurablePriceListProductSection priceList={price_list} /> |
|
52
|
) : ( |
|
53
|
<PriceListProductSection priceList={price_list} /> |
|
54
|
)} |
|
55
|
</LayoutComposer.Entry> |
|
56
|
{detailPageDefaultEntries(price_list)} |
|
57
|
</> |
|
58
|
), |
|
59
|
side: ( |
|
60
|
<> |
|
61
|
<LayoutComposer.Entry id="PriceListConfigurationSection"> |
|
62
|
<PriceListConfigurationSection priceList={price_list} /> |
|
63
|
</LayoutComposer.Entry> |
|
64
|
</> |
|
65
|
), |
|
66
|
}} |
|
67
|
/> |
|
68
|
) |
|
69
|
} |