import { InformationCircleSolid } from "@medusajs/icons" import { HookData, HookDataMap } from "@/types/hooks" import { EnumType, FunctionType, ObjectType } from "@/types/props" import { InlineCode, Table, Tooltip } from "docs-ui" const HookTable = ({ props }: { props: HookDataMap }) => { return ( Value Type Description {/* eslint-disable-next-line react/prop-types */} {props.map((propData, index) => ( ))}
) } const Row = ({ value, type, description }: HookData) => { const isEnum = (t: unknown): t is EnumType => { return (t as EnumType).type !== undefined && (t as EnumType).type === "enum" } const isObject = (t: unknown): t is ObjectType => { return ( (t as ObjectType).type !== undefined && (t as ObjectType).type === "object" ) } const isFunction = (t: unknown): t is FunctionType => { return ( (t as FunctionType).type !== undefined && (t as FunctionType).type === "function" ) } const isComplexType = isEnum(type) || isObject(type) || isFunction(type) return ( {value} {!isComplexType && type.toString()} {isEnum(type) && ( `"${v}"`).join(" | ")} className="font-mono" >
enum
)} {isObject(type) && ( {type.shape}} className="font-mono max-w-[500px]" >
{type.name}
)} {isFunction(type) && ( {type.signature}} className="font-mono max-w-[500px]" >
function
)}
{description}
) } export { HookTable }