|
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 { |
|
6
|
LayoutComposer, |
|
7
|
detailPageDefaultEntries, |
|
8
|
} from "../../../components/layout-composer" |
|
9
|
import { useProductOptionValue } from "../../../hooks/api" |
|
10
|
import { productOptionValueLoader } from "./loader.ts" |
|
11
|
import { ProductOptionValueGeneralSection } from "./components/product-option-value-general-section" |
|
12
|
|
|
13
|
export const ProductOptionValueDetail = () => { |
|
14
|
const { id, value_id } = useParams() |
|
15
|
|
|
16
|
const initialData = useLoaderData() as Awaited< |
|
17
|
ReturnType<typeof productOptionValueLoader> |
|
18
|
> |
|
19
|
|
|
20
|
const { product_option_value, isLoading, isError, error } = |
|
21
|
useProductOptionValue(id!, value_id!, undefined, { |
|
22
|
initialData, |
|
23
|
}) |
|
24
|
|
|
25
|
if (isLoading || !product_option_value) { |
|
26
|
return <SingleColumnPageSkeleton sections={1} showJSON showMetadata /> |
|
27
|
} |
|
28
|
|
|
29
|
if (isError) { |
|
30
|
throw error |
|
31
|
} |
|
32
|
|
|
33
|
return ( |
|
34
|
<LayoutComposer |
|
35
|
widgetsZonePrefix="product_option_value.details" |
|
36
|
preferredLayoutId={CORE_LAYOUT_IDS.SINGLE_COLUMN} |
|
37
|
data={product_option_value} |
|
38
|
sections={{ |
|
39
|
main: ( |
|
40
|
<> |
|
41
|
<LayoutComposer.Entry id="ProductOptionValueGeneralSection"> |
|
42
|
<ProductOptionValueGeneralSection |
|
43
|
optionId={id!} |
|
44
|
productOptionValue={product_option_value} |
|
45
|
/> |
|
46
|
</LayoutComposer.Entry> |
|
47
|
{detailPageDefaultEntries(product_option_value, { |
|
48
|
permissions: false, |
|
49
|
})} |
|
50
|
</> |
|
51
|
), |
|
52
|
}} |
|
53
|
/> |
|
54
|
) |
|
55
|
} |