({
slug,
numPreviews = 0,
heading = '',
headers = [],
parameters = [],
bodyParameters,
bodyParamExpandCallback = undefined,
clickedBodyParameterName = '',
}: Props)
| 19 | } |
| 20 | |
| 21 | export function ParameterTable({ |
| 22 | slug, |
| 23 | numPreviews = 0, |
| 24 | heading = '', |
| 25 | headers = [], |
| 26 | parameters = [], |
| 27 | bodyParameters, |
| 28 | bodyParamExpandCallback = undefined, |
| 29 | clickedBodyParameterName = '', |
| 30 | }: Props) { |
| 31 | const { t } = useTranslation(['parameter_table', 'products']) |
| 32 | const queryParams = parameters.filter((param) => param.in === 'query') |
| 33 | const pathParams = parameters.filter((param) => param.in === 'path') |
| 34 | |
| 35 | return ( |
| 36 | <> |
| 37 | {heading && ( |
| 38 | <h3 className="mt-4 mb-3 pt-3 h4" id={`${slug}--parameters`}> |
| 39 | <a href={`#${slug}--parameters`}>{heading}</a> |
| 40 | </h3> |
| 41 | )} |
| 42 | |
| 43 | <table |
| 44 | className={cx(styles.parameterTable)} |
| 45 | summary="Column one has the type of parameter and the other columns show the name, type, and description of the parameters" |
| 46 | > |
| 47 | <thead> |
| 48 | <tr> |
| 49 | <th |
| 50 | id="header" |
| 51 | scope="col" |
| 52 | className={cx(headers.length === 0 && 'visually-hidden', 'text-bold pl-0')} |
| 53 | > |
| 54 | {t('headers')} |
| 55 | </th> |
| 56 | </tr> |
| 57 | <tr className="visually-hidden"> |
| 58 | <th scope="col">{`${t('name')}, ${t('type')}, ${t('description')}`}</th> |
| 59 | </tr> |
| 60 | </thead> |
| 61 | |
| 62 | <tbody> |
| 63 | {headers.length > 0 && ( |
| 64 | <> |
| 65 | {headers.map((header, index) => ( |
| 66 | <ParameterRow |
| 67 | rowParams={header} |
| 68 | slug={slug} |
| 69 | numPreviews={numPreviews} |
| 70 | key={`${index}-${header.name}`} |
| 71 | /> |
| 72 | ))} |
| 73 | </> |
| 74 | )} |
| 75 | |
| 76 | {pathParams.length > 0 && ( |
| 77 | <> |
| 78 | <tr className="border-top-0"> |
nothing calls this directly
no test coverage detected