import cx from 'classnames' import { useTranslation } from '@/languages/components/useTranslation' import { ParameterRow } from './ParameterRow' import { BodyParameter, ChildParameter, Parameter } from './types' import styles from './ParameterTable.module.scss' type Props = { slug: string numPreviews?: number heading?: string headers?: Array parameters?: Array bodyParameters: Array bodyParamExpandCallback?: (target: HTMLDetailsElement) => void clickedBodyParameterName?: string | undefined variant?: 'rest' | 'webhooks' } export function ParameterTable({ slug, numPreviews = 0, heading = '', headers = [], parameters = [], bodyParameters, bodyParamExpandCallback = undefined, clickedBodyParameterName = '', variant = 'rest', }: Props) { const { t } = useTranslation(['parameter_table']) const queryParams = parameters.filter((param) => param.in === 'query') const pathParams = parameters.filter((param) => param.in === 'path') return ( <> {heading && (

{heading}

)} {headers.length > 0 && ( <> {/*

{t('headers')}

*/} {headers.map((header, index) => ( ))}
{t('headers')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
)} {pathParams.length > 0 && ( <> {/*

{t('path')}

*/} {pathParams.map((param, index) => ( ))}
{t('path')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
)} {queryParams.length > 0 && ( <> {/*

{t('query')}

*/} {queryParams.map((param, index) => ( ))}
{t('query')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
)} {bodyParameters.length > 0 && ( <> {/*

{variant === 'rest' ? t('body') : t('webhook-body')}

*/} {bodyParameters.map((param, index) => ( ))}
{variant === 'rest' ? t('body') : t('webhook-body')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
)} ) }