Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
3476 stevensc 1
import React from 'react';
2
import { Controller, useFormContext } from 'react-hook-form';
3
import { FormControl, InputLabel } from '@mui/material';
4
 
5
import { FilePicker } from '../file-picker';
6
 
7
export function FormFilePicker({
8
  label = '',
9
  name = 'file',
10
  type = 'image',
11
  multiple = false,
12
  maxFiles = 1,
13
  description = 'Arrastra el archivo aqui, o haga click para seleccionar',
14
  rules = {}
15
}) {
16
  const { control } = useFormContext();
17
 
18
  return (
19
    <Controller
20
      control={control}
21
      name={name}
22
      rules={rules}
23
      render={({ field: { onChange, value } }) => (
24
        <FormControl variant='standard' fullWidth>
25
          {label && <InputLabel shrink>{label}</InputLabel>}
26
 
27
          <FilePicker
28
            type={type}
29
            multiple={multiple}
30
            maxFiles={maxFiles}
31
            description={description}
3670 stevensc 32
            defaultFiles={multiple ? value : [value]}
3476 stevensc 33
            onChange={onChange}
34
          />
35
        </FormControl>
36
      )}
37
    />
38
  );
39
}