Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3325 | Rev 3328 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3325 Rev 3327
Línea 9... Línea 9...
9
import DatetimePicker from '@components/common/inputs/datetime-picker'
9
import DatetimePicker from '@components/common/inputs/datetime-picker'
Línea 10... Línea 10...
10
 
10
 
11
function ProgressForm({
11
function ProgressForm({
12
  onSubmit = () => {},
12
  onSubmit = () => {},
-
 
13
  defaultValues = {
13
  defaultValues = {
14
    date: null,
14
    quantitative_value: 0,
15
    quantitative_value: 0,
15
    qualitative_description: ''
16
    qualitative_description: ''
16
  },
17
  },
17
  values = {}
18
  values = {}
Línea 20... Línea 21...
20
    control,
21
    control,
21
    formState: { errors, isSubmitting },
22
    formState: { errors, isSubmitting },
22
    handleSubmit
23
    handleSubmit
23
  } = useForm({
24
  } = useForm({
24
    defaultValues,
25
    defaultValues,
25
    values
26
    values: values ?? { ...values, date: new Date(values.date) }
26
  })
27
  })
Línea 27... Línea -...
27
 
-
 
28
  /* const getCurrentDate = () => {
-
 
29
    const date = new Date()
-
 
30
    const year = date.getFullYear()
-
 
31
    const month = String(date.getMonth() + 1).padStart(2, '0') // Enero es 0
-
 
32
    const day = String(date.getDate()).padStart(2, '0')
-
 
33
    const hours = String(date.getHours()).padStart(2, '0')
-
 
34
    const minutes = String(date.getMinutes()).padStart(2, '0')
-
 
35
    const seconds = String(date.getSeconds()).padStart(2, '0')
-
 
36
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
-
 
37
  } */
-
 
38
 
28
 
39
  return (
29
  return (
40
    <Form onSubmit={handleSubmit(onSubmit)}>
30
    <Form onSubmit={handleSubmit(onSubmit)}>
41
      <LoadingWrapper loading={isSubmitting} displayChildren>
-
 
42
        <DatetimePicker
-
 
43
          label='Fecha'
-
 
44
          name='date'
-
 
45
          control={control}
-
 
46
          rules={{
-
 
47
            required: { value: true, message: 'La fecha es requerida' },
-
 
48
            validate: {
-
 
49
              beGreaterThanToday: (value) =>
-
 
50
                new Date(value) > new Date() ||
-
 
51
                'La fecha debe ser mayor a la fecha actual'
-
 
52
            }
-
 
53
          }}
-
 
54
          displayTime
-
 
55
          parseFormat='YYYY-MM-DD HH:mm:ss'
-
 
56
        />
-
 
57
 
31
      <LoadingWrapper loading={isSubmitting} displayChildren>
58
        <Input
32
        <Input
59
          control={control}
33
          control={control}
60
          label='Valor cuantitativo:'
34
          label='Valor cuantitativo:'
61
          name='quantitative_value'
35
          name='quantitative_value'
Línea 70... Línea 44...
70
          error={errors.qualitative_description?.message}
44
          error={errors.qualitative_description?.message}
71
          rules={{ required: 'La descripción es requerida' }}
45
          rules={{ required: 'La descripción es requerida' }}
72
          label='Descripción cualitativa:'
46
          label='Descripción cualitativa:'
73
        />
47
        />
Línea -... Línea 48...
-
 
48
 
-
 
49
        <DatetimePicker
-
 
50
          label='Fecha'
-
 
51
          name='date'
-
 
52
          control={control}
-
 
53
          rules={{
-
 
54
            required: { value: true, message: 'La fecha es requerida' },
-
 
55
            validate: {
-
 
56
              beGreaterThanToday: (value) =>
-
 
57
                new Date(value) > new Date() ||
-
 
58
                'La fecha debe ser mayor a la fecha actual'
-
 
59
            }
-
 
60
          }}
-
 
61
          displayTime
-
 
62
          parseFormat='YYYY-MM-DD HH:mm:ss'
-
 
63
        />
74
 
64
 
75
        <Button color='primary' type='submit'>
65
        <Button color='primary' type='submit'>
76
          Enviar
66
          Enviar
77
        </Button>
67
        </Button>
78
      </LoadingWrapper>
68
      </LoadingWrapper>