Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3549 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3548 stevensc 1
import React from 'react';
2
import { FormControl, FormHelperText, FormLabel, Rating } from '@mui/material';
3
 
4
import { Controller, useFormContext } from 'react-hook-form';
5
 
6
export function FormInputRating({ name = 'rating', label = '', rules = {}, readOnly = false }) {
7
  const { control } = useFormContext();
8
 
9
  return (
10
    <Controller
11
      control={control}
12
      name={name}
13
      rules={rules}
14
      render={({ field, fieldState: { error } }) => (
15
        <FormControl error={!!error}>
16
          {label && <FormLabel shrink>{label}</FormLabel>}
17
          <Rating
18
            onChange={field.onChange}
19
            value={field.value}
20
            sx={{ fontSize: 20 }}
21
            readOnly={readOnly}
22
          />
23
          {error && <FormHelperText error={!!error}>{error.message}</FormHelperText>}
24
        </FormControl>
25
      )}
26
    />
27
  );
28
}