Rev 1490 | AutorÃa | Ultima modificación | Ver Log |
import React from 'react'
import { Controller } from 'react-hook-form'
import { InputAdornment, TextField } from '@mui/material'
import FormErrorFeedback from './FormErrorFeedback'
const FormInputText = ({
name = '',
control = null,
rules = {
required: { value: true, message: 'This field is required' }
},
defaultValue = '',
error = '',
icon: Icon = null,
...rest
}) => {
return (
<Controller
name={name}
control={control}
rules={rules}
defaultValue={defaultValue}
render={({ ref, name, value, onChange, onBlur }) => (
<>
<TextField
id={name}
name={name}
inputRef={ref}
value={value}
onChange={onChange}
onBlur={onBlur}
InputProps={{
startAdornment: Icon ? (
<InputAdornment position='start'>
<Icon />
</InputAdornment>
) : null
}}
fullWidth
{...rest}
/>
{error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
</>
)}
/>
)
}
export default FormInputText