1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/components/rest/RestStatusCodes.tsx
2022-04-11 16:09:03 +00:00

46 lines
1.3 KiB
TypeScript

import cx from 'classnames'
import { StatusCode } from './types'
import { useTranslation } from 'components/hooks/useTranslation'
import styles from './RestResponseTable.module.scss'
type Props = {
heading: string
statusCodes: Array<StatusCode>
}
export function RestStatusCodes({ heading, statusCodes }: 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>
{statusCodes.map((statusCode, index) => {
return (
<tr key={`${statusCode.description}-${index}}`}>
<td>
<code>{statusCode.httpStatusCode}</code>
</td>
<td>
{statusCode.description ? (
<div dangerouslySetInnerHTML={{ __html: statusCode.description }} />
) : (
statusCode.httpStatusMessage
)}
</td>
</tr>
)
})}
</tbody>
</table>
</>
)
}