import { ArrowUpRightOnBox, Check, SquareTwoStack, TriangleDownMini, XMarkMini, } from "@medusajs/icons" import { Badge, Container, Drawer, Heading, IconButton, Kbd, } from "@medusajs/ui" import Primitive from "@uiw/react-json-view" import { CSSProperties, MouseEvent, Suspense, useState } from "react" import { Trans, useTranslation } from "react-i18next" type JsonViewSectionProps = { data: object title?: string } export const JsonViewSection = ({ data }: JsonViewSectionProps) => { const { t } = useTranslation() const numberOfKeys = Object.keys(data).length return ( {t("json.header")} {t("json.numberOfKeys", { count: numberOfKeys, })} , ]} /> {t("json.drawer.description")} esc } > } /> ( null )} /> ( undefined )} /> { return ( {t("general.items", { count: Object.keys(value as object).length, })} ) }} /> : { return }} /> ) } type CopiedProps = { style?: CSSProperties value: object | undefined } const Copied = ({ style, value }: CopiedProps) => { const [copied, setCopied] = useState(false) const handler = (e: MouseEvent) => { e.stopPropagation() setCopied(true) if (typeof value === "string") { navigator.clipboard.writeText(value) } else { const json = JSON.stringify(value, null, 2) navigator.clipboard.writeText(json) } setTimeout(() => { setCopied(false) }, 2000) } const styl = { whiteSpace: "nowrap", width: "20px" } if (copied) { return ( ) } return ( ) }