Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3719 Rev 3748
Línea 18... Línea 18...
18
  values = {}
18
  values = {}
19
}) {
19
}) {
20
  const {
20
  const {
21
    control,
21
    control,
22
    formState: { errors, isSubmitting },
22
    formState: { errors, isSubmitting },
23
    watch,
-
 
24
    handleSubmit
23
    handleSubmit
25
  } = useForm({
24
  } = useForm({
26
    defaultValues,
25
    defaultValues,
27
    values
26
    values
28
  });
27
  });
29
  const watchedDate = watch('date', new Date());
-
 
Línea 30... Línea 28...
30
 
28
 
31
  return (
29
  return (
32
    <Form onSubmit={handleSubmit(onSubmit)}>
30
    <Form onSubmit={handleSubmit(onSubmit)}>
33
      <LoadingWrapper loading={isSubmitting} displayChildren>
31
      <LoadingWrapper loading={isSubmitting} displayChildren>
34
        <Input
32
        <Input
35
          control={control}
33
          control={control}
36
          label='Valor cuantitativo:'
34
          label='Valor cuantitativo:'
-
 
35
          name='quantitative_value'
37
          name='quantitative_value'
36
          color='secondary'
38
          type='number'
37
          type='number'
39
          rules={{ required: 'El valor es requerido' }}
38
          rules={{ required: 'El valor es requerido' }}
40
          error={errors.quantitative_value?.message}
39
          error={errors.quantitative_value?.message}
Línea 50... Línea 49...
50
 
49
 
51
        <DatetimePicker
50
        <DatetimePicker
52
          label='Fecha'
51
          label='Fecha'
53
          name='date'
52
          name='date'
54
          control={control}
53
          control={control}
55
          defaultValue={new Date(watchedDate)}
54
          color='secondary'
56
          rules={{
55
          rules={{
57
            required: { value: true, message: 'La fecha es requerida' },
56
            required: { value: true, message: 'La fecha es requerida' },
58
            validate: {
57
            validate: {
-
 
58
              noPreviousDay: (value) => {
59
              beGreaterThanToday: (value) =>
59
                const yesterday = new Date(new Date().setDate(new Date().getDate() - 1));
-
 
60
                return new Date(value) > yesterday || 'La fecha debe ser mayor a la fecha actual';
60
                new Date(value) > new Date() || 'La fecha debe ser mayor a la fecha actual'
61
              }
61
            }
62
            }
62
          }}
63
          }}
63
          displayTime
64
          displayTime
64
          parseFormat='YYYY-MM-DD HH:mm:ss'
65
          parseFormat='YYYY-MM-DD HH:mm:ss'