1
0
mirror of synced 2025-12-31 15:04:15 -05:00
Files
docs/components/rest/RestStatusCodes.tsx

45 lines
1.3 KiB
TypeScript

import cx from 'classnames'
import { CodeResponse } from './types'
import { useTranslation } from 'components/hooks/useTranslation'
import styles from './RestResponseTable.module.scss'
type Props = {
heading: string
responses: Array<CodeResponse>
}
export function RestStatusCodes({ heading, responses }: Props) {
const { t } = useTranslation('products')
return (
<>
<h4>{heading}</h4>
<table className={cx(styles.restResponseTable)}>
<thead>
<tr className="text-left">
<th>{t('rest.reference.http_status_code')}</th>
<th>{t('rest.reference.description')}</th>
</tr>
</thead>
<tbody>
{responses.map((response, index) => (
<tr key={`${response.description}-${index}}`}>
<td>
<code>{response.httpStatusCode}</code>
</td>
<td>
{response.description &&
response.description.toLowerCase() !== '<p>response</p>' ? (
<div dangerouslySetInnerHTML={{ __html: response.description }} />
) : (
response.httpStatusMessage
)}
</td>
</tr>
))}
</tbody>
</table>
</>
)
}