import FormRating from '@material-hu/components/design-system/Rating/form';

import useRules from 'src/hooks/useRules';
import { useLokaliseTranslation } from 'src/utils/i18n';

type Props = {
  name: string;
  required?: boolean;
  formFilled?: boolean;
};

export const StarRatingInput = ({ name, required, formFilled }: Props) => {
  const { t } = useLokaliseTranslation('validations');

  return (
    <FormRating
      name={name}
      rules={useRules({
        requiredWithMessage: required && !formFilled ? t('required') : false,
      })}
      inputProps={{
        disabled: formFilled,
      }}
    />
  );
};

export default StarRatingInput;
