Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3549 | Rev 3555 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import { FormControl, FormHelperText, FormLabel, Rating } from '@mui/material';

export function FormInputRating({ name = 'rating', label = '', rules = {}, readOnly = false }) {
  const { control } = useFormContext();

  return (
    <Controller
      control={control}
      name={name}
      rules={rules}
      render={({ field, fieldState: { error } }) => (
        <FormControl error={!!error} variant='standard' fullWidth>
          {label && <FormLabel shrink>{label}</FormLabel>}
          <Rating
            onChange={(_, value) => field.onChange(value)}
            value={field.value}
            sx={{ fontSize: 20 }}
            readOnly={readOnly}
          />
          {error && <FormHelperText error={!!error}>{error.message}</FormHelperText>}
        </FormControl>
      )}
    />
  );
}