1 import { Spinner } from "@medusajs/icons"
2 import { Container } from "@medusajs/ui"
3 import * as React from "react"
4
5 import { HookRegistry } from "@/specs/hooks"
6 import Feedback from "../Feedback"
7
8 type HookValuesProps = {
9 hook: string
10 hideFeedback?: boolean
11 }
12
13 const HookValues = ({ hook, hideFeedback = false }: HookValuesProps) => {
14 const Props = React.useMemo(() => {
15 const Table = HookRegistry[hook]?.table
16
17 if (!Table) {
18 return (
19 <div className="flex min-h-[200px] w-full items-center justify-center">
20 <p className="txt-compact-small">
21 No API reference found for{" "}
22 <span className="txt-compact-small-plus">{hook}</span>
23 </p>
24 </div>
25 )
26 }
27
28 return <Table />
29 }, [hook])
30
31 return (
32 <>
33 <Container className="mb-6 mt-8 overflow-hidden p-0">
34 <React.Suspense
35 fallback={
36 <div className="text-medusa-fg-muted flex flex-1 items-center justify-center">
37 <Spinner className="animate-spin" />
38 </div>
39 }
40 >
41 {Props}
42 </React.Suspense>
43 </Container>
44 {!hideFeedback && (
45 <Feedback title={`props of ${hook}`} showDottedSeparator={false} />
46 )}
47 </>
48 )
49 }
50
51 export { HookValues }