Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3262 Rev 3269
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
2
import { Controller, useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
3
import { Button, InputLabel } from '@mui/material'
3
import { Button } from '@mui/material'
4
import Datetime from 'react-datetime'
-
 
Línea 5... Línea 4...
5
 
4
 
6
import Widget from '@components/UI/Widget'
5
import Widget from '@components/UI/Widget'
7
import Form from '@components/common/form'
6
import Form from '@components/common/form'
-
 
7
import Input from '@components/UI/inputs/Input'
8
import Input from '@components/UI/inputs/Input'
8
import Select from '@components/UI/inputs/Select'
9
import Ckeditor from '@components/UI/Ckeditor'
9
import Ckeditor from '@components/common/ckeditor/Ckeditor'
10
import TagsInput from '@components/UI/TagsInput'
10
import DatetimePicker from '@components/common/inputs/datetime-picker'
11
import LoadingWrapper from '@components/common/loading-wrapper'
-
 
12
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
-
 
13
 
-
 
Línea 14... Línea 11...
14
import 'react-datetime/css/react-datetime.css'
11
import LoadingWrapper from '@components/common/loading-wrapper'
15
 
12
 
16
export default function GoalForm({
13
export default function GoalForm({
17
  onSubmit = () => {},
14
  onSubmit = () => {},
Línea 67... Línea 64...
67
                }
64
                }
68
              }}
65
              }}
69
              error={errors.value?.message}
66
              error={errors.value?.message}
70
            />
67
            />
Línea 71... Línea 68...
71
 
68
 
-
 
69
            <Select
72
            <Controller
70
              label='Hábitos y competencias para lograr la Meta'
73
              name='skill_id'
71
              name='skill_id'
-
 
72
              control={control}
74
              control={control}
73
              options={habits}
75
              defaultValue={[]}
-
 
76
              render={({ field: { name, onChange } }) => (
-
 
77
                <>
-
 
78
                  <TagsInput
-
 
79
                    name={name}
-
 
80
                    label='Hábitos y competencias para lograr la Meta'
-
 
81
                    onChange={onChange}
-
 
82
                    suggestions={habits}
-
 
83
                  />
-
 
84
                  {errors.skill_id && (
-
 
85
                    <FormErrorFeedback>
74
              defaultValue={[]}
86
                      {errors.skill_id?.message}
-
 
87
                    </FormErrorFeedback>
-
 
88
                  )}
-
 
89
                </>
-
 
90
              )}
75
              error={errors.skill_id?.message}
Línea 91... Línea 76...
91
            />
76
            />
-
 
77
 
92
 
78
            <DatetimePicker
93
            <Controller
79
              label='Fecha de inicio'
94
              name='start_date'
80
              name='start_date'
95
              control={control}
81
              control={control}
96
              rules={{
82
              rules={{
97
                required: { value: true, message: 'La fecha es requerida' },
83
                required: { value: true, message: 'La fecha es requerida' },
98
                validate: {
84
                validate: {
99
                  beGreaterThanToday: (value) =>
85
                  beGreaterThanToday: (value) =>
100
                    new Date(value) > new Date() ||
86
                    new Date(value) > new Date() ||
101
                    'La fecha debe ser mayor a la fecha actual'
87
                    'La fecha debe ser mayor a la fecha actual'
102
                }
-
 
103
              }}
-
 
104
              render={({ field: { onChange, ref, value, name } }) => (
-
 
105
                <>
-
 
106
                  <InputLabel>Fecha de inicio</InputLabel>
-
 
107
                  <Datetime
-
 
108
                    dateFormat='DD-MM-YYYY'
-
 
109
                    onChange={(e) => onChange(e.format('YYYY-MM-DD'))}
-
 
110
                    timeFormat={false}
-
 
111
                    inputProps={{ className: 'form-control', ref, name }}
-
 
112
                    value={value}
-
 
113
                    closeOnSelect
-
 
114
                  />
-
 
115
                  {errors.start_date && (
-
 
116
                    <FormErrorFeedback>
-
 
117
                      {errors.start_date?.message}
-
 
118
                    </FormErrorFeedback>
-
 
119
                  )}
-
 
120
                </>
88
                }
Línea 121... Línea 89...
121
              )}
89
              }}
-
 
90
            />
122
            />
91
 
123
 
92
            <DatetimePicker
124
            <Controller
93
              label='Fecha de finalización'
125
              name='end_date'
94
              name='end_date'
126
              control={control}
95
              control={control}
127
              rules={{
96
              rules={{
128
                required: { value: true, message: 'La fecha es requerida' },
97
                required: { value: true, message: 'La fecha es requerida' },
129
                validate: (value, { start_date }) =>
98
                validate: (value, { start_date }) =>
130
                  new Date(value) > new Date(start_date) ||
-
 
131
                  'La fecha debe ser mayor a la fecha de inicio'
-
 
132
              }}
-
 
133
              render={({ field: { onChange, name, ref, value } }) => (
-
 
134
                <>
-
 
135
                  <InputLabel>Fecha de finalización</InputLabel>
-
 
136
                  <Datetime
-
 
137
                    dateFormat='DD-MM-YYYY'
-
 
138
                    onChange={(e) => onChange(e.format('YYYY-MM-DD'))}
-
 
139
                    timeFormat={false}
-
 
140
                    inputProps={{ className: 'form-control', ref, name }}
-
 
141
                    value={value}
-
 
142
                    closeOnSelect
-
 
143
                  />
-
 
144
                  {errors.end_date && (
-
 
145
                    <FormErrorFeedback>
-
 
146
                      {errors.end_date?.message}
-
 
147
                    </FormErrorFeedback>
-
 
148
                  )}
99
                  new Date(value) > new Date(start_date) ||
Línea 149... Línea 100...
149
                </>
100
                  'La fecha debe ser mayor a la fecha de inicio'
150
              )}
101
              }}
151
            />
102
            />