1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/components/rest/RestStatusCodes.tsx
2022-05-02 10:10:33 -07:00

48 lines
1.4 KiB
TypeScript

import cx from 'classnames'
import { useTranslation } from 'components/hooks/useTranslation'
import styles from './RestOperation.module.scss'
import { StatusCode } from './types'
type Props = {
statusCodes: Array<StatusCode>
slug: string
}
export function RestStatusCodes({ statusCodes, slug }: Props) {
const { t } = useTranslation('products')
return (
<>
<h3 className="mt-4 mb-3 pt-3 h4" id={`${slug}--status-codes`}>
<a href={`#${slug}--status-codes`}>{t('rest.reference.http_status_code')}</a>
</h3>
<table className={cx(styles.restResponseTable, 'd-block')}>
<thead>
<tr className="text-left">
<th>{t('rest.reference.status_code')}</th>
<th>{t('rest.reference.description')}</th>
</tr>
</thead>
<tbody>
{statusCodes.map((statusCode, index) => (
<tr key={`${statusCode.description}-${index}}`}>
<td>
<code>{statusCode.httpStatusCode}</code>
</td>
<td className="color-fg-muted">
{statusCode.description ? (
<div dangerouslySetInnerHTML={{ __html: statusCode.description }} />
) : (
statusCode.httpStatusMessage
)}
</td>
</tr>
))}
</tbody>
</table>
</>
)
}