Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1459 stevensc 1
import React from 'react'
2
import { Controller } from 'react-hook-form'
3
 
4
import FormErrorFeedback from './FormErrorFeedback'
5
import TextInput from '../inputs/TextInput'
6
 
7
const FormInputText = ({
8
  control = null,
9
  name = '',
10
  placeholder = '',
11
  defaultValue = '',
12
  rules = {
13
    required: { value: true, message: 'This field is required' }
14
  },
15
  error = '',
16
  icon: Icon = null,
17
  label = '',
18
  type = 'text'
19
}) => {
20
  return (
21
    <Controller
22
      name={name}
23
      control={control}
24
      rules={rules}
25
      defaultValue={defaultValue}
26
      render={(field) => (
27
        <>
28
          <TextInput
29
            onChange={field.onChange}
30
            onBlur={field.onBlur}
31
            value={field.value}
32
            name={field.name}
33
            inputRef={field.ref}
34
            id={field.name}
35
            placeholder={placeholder}
36
            icon={Icon}
37
            label={label}
38
            sx={{
39
              mb: error ? 0 : 1
40
            }}
41
            type={type}
42
          />
43
 
44
          {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
45
        </>
46
      )}
47
    />
48
  )
49
}
50
 
51
export default FormInputText