Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2802 Rev 2857
Línea 5... Línea 5...
5
import { useGoals } from '@hooks'
5
import { useGoals } from '@hooks'
Línea 6... Línea 6...
6
 
6
 
7
import Modal from '@components/UI/modal/Modal'
7
import Modal from '@components/UI/modal/Modal'
8
import Input from '@components/UI/inputs/Input'
8
import Input from '@components/UI/inputs/Input'
9
import Ckeditor from '@components/UI/Ckeditor'
-
 
10
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
9
import Ckeditor from '@components/UI/Ckeditor'
Línea 11... Línea 10...
11
import TagsInput from '@components/UI/TagsInput'
10
import TagsInput from '@components/UI/TagsInput'
Línea 12... Línea 11...
12
 
11
 
Línea 28... Línea 27...
28
      name: 'Meditar'
27
      name: 'Meditar'
29
    }
28
    }
30
  ]
29
  ]
Línea 31... Línea 30...
31
 
30
 
32
  const {
31
  const {
33
    register,
32
    control,
34
    handleSubmit,
33
    handleSubmit,
35
    setValue,
-
 
36
    watch,
34
    setValue,
37
    formState: { errors }
35
    formState: { errors }
38
  } = useForm({
36
  } = useForm({
39
    defaultValues: {
37
    defaultValues: {
40
      title: '',
38
      title: '',
41
      description: '',
39
      description: '',
42
      value: 1,
40
      value: 1,
43
      finishDate: Date.now(),
41
      finishDate: Date.now(),
44
      habits: []
42
      habits: []
45
    }
43
    }
46
  })
-
 
Línea 47... Línea 44...
47
  const watchedHabits = watch('habits')
44
  })
Línea 48... Línea 45...
48
 
45
 
49
  const onSubmit = handleSubmit(({ goal }) => addGoal(goal))
46
  const onSubmit = handleSubmit(({ goal }) => addGoal(goal))
Línea 54... Línea 51...
54
      title='Propósito'
51
      title='Propósito'
55
      onClose={toggleModal}
52
      onClose={toggleModal}
56
      onAccept={onSubmit}
53
      onAccept={onSubmit}
57
    >
54
    >
58
      <Input
55
      <Input
59
        label='Titulo'
-
 
60
        name='title'
56
        name='title'
-
 
57
        label='Titulo'
61
        placeholder='Define el título de tu meta'
58
        placeholder='Define el título de tu meta'
-
 
59
        control={control}
-
 
60
        rules={{ required: 'Este campo es requerido' }}
62
        error={errors.title?.message}
61
        error={errors.title?.message}
63
        inputRef={register({ required: 'Este campo es requerido' })}
-
 
64
      />
62
      />
Línea 65... Línea 63...
65
 
63
 
66
      <Input
64
      <Input
67
        label='Valor'
65
        type='number'
-
 
66
        name='value'
68
        name='value'
67
        label='Valor'
-
 
68
        placeholder='Define un valor a meta'
-
 
69
        control={control}
69
        placeholder='Define un valor a meta'
70
        rules={{ required: 'Este campo es requerido' }}
70
        error={errors.value?.message}
-
 
71
        inputRef={register({ required: 'Este campo es requerido' })}
-
 
72
        type='number'
71
        error={errors.value?.message}
-
 
72
      />
73
      />
73
 
74
      <TagsInput
74
      <TagsInput
75
        name='habits'
75
        name='habits'
76
        label='Habitos'
-
 
77
        settedTags={watchedHabits}
76
        label='Habitos'
78
        suggestions={habits}
-
 
79
        onChange={(tags) => {
77
        suggestions={habits}
80
          setValue('habits', tags)
-
 
81
          console.log(tags)
-
 
82
        }}
78
        onChange={(tags) => setValue('habits', tags)}
83
      />
79
      />
84
      <Datetime
80
      <Datetime
85
        dateFormat='DD-MM-YYYY'
81
        dateFormat='DD-MM-YYYY'
86
        timeFormat={false}
82
        timeFormat={false}
87
        inputProps={{ className: 'form-control' }}
83
        inputProps={{ className: 'form-control' }}
88
        initialValue={Date.parse(new Date())}
84
        initialValue={Date.parse(new Date())}
89
        closeOnSelect
85
        closeOnSelect
90
      />
86
      />
91
      <Ckeditor
87
      <Ckeditor
92
        label='Descripción'
88
        label='Descripción'
-
 
89
        name='description'
-
 
90
        control={control}
93
        onReady={register('description')}
91
        rules={{ required: 'Este campo es requerido' }}
94
        onChange={(value) => setValue('description', value)}
92
        error={errors.description?.message}
95
      />
-
 
96
      {errors.description && (
-
 
97
        <FormErrorFeedback>{errors.description?.message}</FormErrorFeedback>
-
 
98
      )}
93
      />
99
    </Modal>
94
    </Modal>
100
  )
95
  )