import cx from 'classnames' import { useTranslation } from 'components/hooks/useTranslation' import { ChildBodyParametersRows } from './ChildBodyParametersRows' import type { ChildParameter } from './types' type Props = { rowParams: ChildParameter slug: string numPreviews?: number isChild?: boolean rowIndex?: number } export function ParameterRow({ rowParams, slug, numPreviews = 0, rowIndex = 0, isChild = false, }: Props) { const { t } = useTranslation(['parameter_table', 'products']) // This will be true if `rowParams` does not have a key called `default` // and it will be true if it does and its actual value is `undefined`. const hasDefault = rowParams.default !== undefined return ( <>
0 && isChild ? 'pt-3 border-top color-border-muted' : ''}` )} >
{rowParams.name} {rowParams.type} {rowParams.isRequired ? ( {t('required')} ) : null}
{numPreviews > 0 && ( {numPreviews > 1 ? ` ${t('see_preview_notices')}` : ` ${t('see_preview_notice')}`} )}
{hasDefault && (

{t('default')}: {typeof rowParams.default === 'string' ? // In the schema, the default value for strings can // potentially be the empty string so we handle this case // in particular by rendering it as "". Otherwise we would // display an empty code block which could be confusing. rowParams.default || '""' : JSON.stringify(rowParams.default)}

)} {rowParams.enum && rowParams.enum.length && (

{rowParams.enum.length > 1 ? ( <> {t('enum_description_title')}: {rowParams.enum.map((item, index, array) => ( {item} {index !== array.length - 1 && ','}{' '} ))} ) : ( <> {t('single_enum_description')}: {rowParams.enum[0]} )}

)}
{rowParams.childParamsGroups && rowParams.childParamsGroups.length > 0 && ( )} ) }