Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3719 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3719 stevensc 1
import React from 'react';
2
 
3
import {
4
  Form,
5
  FormButton,
6
  FormFilePicker,
7
  FormInput,
8
  FormRichEditor,
9
  FormSelect
10
} from '@shared/components';
11
 
12
export function KnowledgeForm({
13
  categories = [],
14
  imageSize = '100x100',
15
  onSubmit = () => {},
16
  defaultValues = {
17
    category_id: '',
18
    title: '',
19
    description: '',
20
    image: '',
21
    attachment: ''
22
  }
23
}) {
24
  const handleSubmit = (data) => {
3741 stevensc 25
    onSubmit(data);
3719 stevensc 26
  };
27
 
28
  return (
29
    <Form onSubmit={handleSubmit} defaultValues={defaultValues} reset>
30
      <FormSelect
31
        name='category_id'
32
        label='Categoría'
33
        placeholder='Seleccione un opción'
34
        options={categories}
35
        rules={{ required: 'Por favor, seleccione una categoría' }}
36
      />
37
 
38
      <FormInput
39
        name='title'
40
        label='Título'
41
        placeholder='Ingrese el título del conocimiento'
42
        rules={{ required: 'Por favor, ingrese un título' }}
43
      />
44
 
45
      <FormRichEditor
46
        name='description'
47
        label='Descripción'
48
        rules={{ required: 'Por favor, ingrese una descripción' }}
49
      />
50
 
51
      <FormFilePicker
52
        label='Seleccione una imagen'
53
        type='image'
54
        name='image'
55
        rules={{ required: 'Por favor, seleccione una imagen' }}
56
        description={`Tamaño máximo: ${imageSize}`}
57
      />
58
 
59
      <FormFilePicker
60
        label='Seleccione un archivo'
61
        type='file'
62
        name='attachment'
63
        rules={{ required: 'Por favor, seleccione un archivo' }}
64
      />
65
 
66
      <FormButton type='submit'>Guardar</FormButton>
67
    </Form>
68
  );
69
}