import cx from 'classnames' import { useTranslation } from 'components/hooks/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 } export function ParameterTable({ slug, numPreviews, heading = '', headers = [], parameters, bodyParameters, }: Props) { const { t } = useTranslation(['parameter_table', 'products']) const queryParams = parameters.filter((param) => param.in === 'query') const pathParams = parameters.filter((param) => param.in === 'path') return ( <> {heading && (

{heading}

)} {headers.length > 0 && ( <> {headers.map((header, index) => ( ))} )} {pathParams.length > 0 && ( <> {pathParams.map((param, index) => ( ))} )} {queryParams.length > 0 && ( <> {queryParams.map((param, index) => ( ))} )} {bodyParameters.length > 0 && ( <> {bodyParameters.map((param, index) => ( ))} )}
{t('headers')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
{t('path')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
{t('query')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
{t('body')}
{`${t('name')}, ${t('type')}, ${t('description')}`}
) }