import React from 'react' import type { MutableRefObject } from 'react' import { Label, Rating, type RatingProps } from '../..' interface DefaultProps { /** * ID to find this component in testing tools (e.g.: cypress, testing library, and jest). */ testId?: string /** * ID to identify input and corresponding label. */ id: string /** * The text displayed to identify the input rating. */ label: string /** * The error message displayed when an error occurs. */ error?: string /** * Component's ref. */ ratingRef?: MutableRefObject } export type RatingFieldProps = DefaultProps & RatingProps const RatingField = ({ id, label, error, disabled, length = 5, value = 0, onChange, ratingRef, testId = 'fs-rating-field', ...otherProps }: RatingFieldProps) => { const shouldDisplayError = !disabled && error && error !== '' return (
{shouldDisplayError && ( {error} )}
) } export default RatingField