// @ts-nocheck import { useParams } from 'common' import { PropsWithChildren } from 'react' import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock' import { Markdown } from '../Markdown' import { useSendEventMutation } from '@/data/telemetry/send-event-mutation' import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' interface ContentSnippetProps { apikey?: string endpoint?: string selectedLanguage: 'js' | 'bash' snippet: { key: string category: string title: string description?: string js?: (apikey?: string, endpoint?: string) => string bash?: (apikey?: string, endpoint?: string) => string } } const ContentSnippet = ({ apikey, endpoint, selectedLanguage, snippet, children, }: PropsWithChildren) => { const { ref: projectRef } = useParams() const { data: org } = useSelectedOrganizationQuery() const { mutate: sendEvent } = useSendEventMutation() const codeSnippet = snippet[selectedLanguage]?.(apikey, endpoint).replaceAll( '[ref]', projectRef ?? '' ) const handleCopy = () => { sendEvent({ action: 'api_docs_code_copy_button_clicked', properties: { title: snippet.title, selectedLanguage, }, groups: { project: projectRef ?? 'Unknown', organization: org?.slug ?? 'Unknown', }, }) } return (

{snippet.title}

{snippet.description !== undefined && (
)}
{children} {codeSnippet !== undefined && (
{codeSnippet}
)}
) } export default ContentSnippet