Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3324 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3320 stevensc 1
import React from 'react'
2
import { useForm } from 'react-hook-form'
3
 
4
import Form from '@components/common/form'
5
import Input from '@components/UI/inputs/Input'
6
import Button from '@components/UI/buttons/Buttons'
7
import Ckeditor from '@components/common/ckeditor/Ckeditor'
8
import LoadingWrapper from '@components/common/loading-wrapper'
9
 
10
function ProgressForm({
11
  onSubmit = () => {},
12
  defaultValues = {
13
    quantitative_value: 0,
14
    qualitative_description: ''
15
  },
16
  values = {}
17
}) {
18
  const {
19
    control,
20
    formState: { errors, isSubmitting },
21
    handleSubmit
22
  } = useForm({
23
    defaultValues,
24
    values
25
  })
26
 
27
  const getCurrentDate = () => {
28
    const date = new Date()
29
    const year = date.getFullYear()
30
    const month = String(date.getMonth() + 1).padStart(2, '0') // Enero es 0
31
    const day = String(date.getDate()).padStart(2, '0')
32
    const hours = String(date.getHours()).padStart(2, '0')
33
    const minutes = String(date.getMinutes()).padStart(2, '0')
34
    const seconds = String(date.getSeconds()).padStart(2, '0')
35
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
36
  }
37
 
38
  return (
39
    <Form onSubmit={handleSubmit(onSubmit)}>
40
      <LoadingWrapper loading={isSubmitting} displayChildren>
41
        <Input
42
          control={control}
43
          label='Valor cuantitativo:'
44
          name='quantitative_value'
45
          type='number'
46
          rules={{ required: 'El valor es requerido' }}
47
          error={errors.quantitative_value?.message}
48
        />
49
 
50
        <Ckeditor
51
          control={control}
52
          name='qualitative_description'
53
          error={errors.qualitative_description?.message}
54
          rules={{ required: 'La descripción es requerida' }}
55
          label='Descripción cualitativa:'
56
        />
57
 
58
        <Button color='primary' type='submit'>
59
          Enviar
60
        </Button>
61
      </LoadingWrapper>
62
    </Form>
63
  )
64
}
65
 
66
export default ProgressForm