import { useTranslation } from 'components/hooks/useTranslation' import { ChildBodyParametersRows } from './ChildBodyParametersRows' import type { ChildParamsGroup } from './types' type Props = { name: string type: string | string[] description: string isRequired?: boolean defaultValue?: string enumValues?: string[] slug: string childParamsGroups?: ChildParamsGroup[] | null numPreviews?: number isChild?: boolean } export function ParameterRow({ name, type, description, isRequired, defaultValue, enumValues, slug, childParamsGroups = null, numPreviews = 0, isChild = false, }: Props) { const { t } = useTranslation('products') return ( <>
{name} {Array.isArray(type) ? type.join(' or ') : type} {isRequired ? ( {t('rest.reference.required')} ) : null}
{numPreviews > 0 && ( {numPreviews > 1 ? ` ${t('rest.reference.see_preview_notices')}` : ` ${t('rest.reference.see_preview_notice')}`} )}
{defaultValue && (

{t('rest.reference.default')}: {defaultValue.toString()}

)} {enumValues && (

{t('rest.reference.enum_description_title')}: {enumValues.map((item, index) => { return index !== enumValues.length - 1 ? ( {item},{' '} ) : ( {item} ) })}

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