Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3269 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3269 Rev 3719
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react';
2
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form';
3
import { Button } from '@mui/material'
3
import { Button } from '@mui/material';
4
 
4
 
5
import Widget from '@components/UI/Widget'
5
import Widget from '@components/UI/Widget';
6
import Form from '@components/common/form'
6
import Form from '@components/common/form';
7
import LoadingWrapper from '@components/common/loading-wrapper'
7
import LoadingWrapper from '@components/common/loading-wrapper';
8
import Input from '@components/UI/inputs/Input'
8
import Input from '@components/UI/inputs/Input';
9
import Ckeditor from '@components/common/ckeditor/Ckeditor'
9
import Ckeditor from '@components/common/ckeditor/Ckeditor';
10
 
10
 
11
export default function PurposeForm({
11
export default function PurposeForm({ onSubmit = () => {}, defaultValues = {}, values = {} }) {
12
  onSubmit = () => {},
-
 
13
  defaultValues = {},
-
 
14
  values = {}
-
 
15
}) {
-
 
16
  const {
12
  const {
17
    control,
13
    control,
18
    handleSubmit,
14
    handleSubmit,
19
    formState: { errors, isSubmitting }
15
    formState: { errors, isSubmitting }
20
  } = useForm({
16
  } = useForm({
21
    defaultValues,
17
    defaultValues,
22
    values
18
    values
23
  })
19
  });
24
 
20
 
25
  return (
21
  return (
26
    <Widget>
22
    <Widget>
27
      <Widget.Body>
23
      <Widget.Body>
28
        <Form onSubmit={handleSubmit(onSubmit)}>
24
        <Form onSubmit={handleSubmit(onSubmit)}>
29
          <LoadingWrapper loading={isSubmitting}>
25
          <LoadingWrapper loading={isSubmitting}>
30
            <Input
26
            <Input
31
              label='Título del Propósito'
27
              label='Título del Propósito'
32
              name='name'
28
              name='name'
33
              control={control}
29
              control={control}
34
              error={errors.name?.message}
30
              error={errors.name?.message}
35
              rules={{ required: 'El titulo es requerido' }}
31
              rules={{ required: 'El titulo es requerido' }}
36
            />
32
            />
37
 
33
 
38
            <Ckeditor
34
            <Ckeditor
39
              label='Descripción'
35
              label='Descripción'
40
              name='description'
36
              name='description'
41
              control={control}
37
              control={control}
42
              error={errors.description?.message}
38
              error={errors.description?.message}
43
              rules={{ required: 'La descripción es requerida' }}
39
              rules={{ required: 'La descripción es requerida' }}
44
            />
40
            />
45
 
41
 
46
            <Button type='submit' color='primary'>
42
            <Button type='submit' color='primary'>
47
              Enviar
43
              Enviar
48
            </Button>
44
            </Button>
49
          </LoadingWrapper>
45
          </LoadingWrapper>
50
        </Form>
46
        </Form>
51
      </Widget.Body>
47
      </Widget.Body>
52
    </Widget>
48
    </Widget>
53
  )
49
  );
54
}
50
}