Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3548 | Rev 3554 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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