import { useRouter } from 'next/router' import slugger from 'github-slugger' import { CheckCircleFillIcon } from '@primer/octicons-react' import cx from 'classnames' import { Link } from 'components/Link' import { useTranslation } from 'components/hooks/useTranslation' import { RestPreviewNotice } from './RestPreviewNotice' import styles from './RestOperation.module.scss' import { RestParameterTable } from './RestParameterTable' import { RestCodeSamples } from './RestCodeSamples' import { RestStatusCodes } from './RestStatusCodes' import { Operation } from './types' type Props = { operation: Operation } export function RestOperation({ operation }: Props) { const slug = slugger.slug(operation.title) const { t } = useTranslation('products') const router = useRouter() const numPreviews = operation.previews.length const hasStatusCodes = operation.statusCodes.length > 0 const hasCodeSamples = operation.codeExamples.length > 0 const hasParameters = operation.parameters.length > 0 || operation.bodyParameters.length > 0 return (

{operation.title}

{operation.enabledForGitHubApps && (
{t('rest.reference.works_with') + ' '} GitHub Apps
)}
{hasParameters && ( )} {hasStatusCodes && }
{hasCodeSamples && } {numPreviews > 0 && }
) }