Proyectos de Subversion LeadersLinked - SPA

Rev

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

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