Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2802 Rev 2868
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useDispatch, useSelector } from 'react-redux'
3
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
4
import { Form } from 'react-bootstrap'
-
 
5
import { Box } from '@mui/material'
-
 
Línea 6... Línea 4...
6
 
4
 
7
import { axios } from 'utils/index'
5
import { axios } from '@utils'
Línea 8... Línea 6...
8
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from '@store/notification/notification.actions'
9
 
7
 
-
 
8
import Modal from '@components/UI/modal/Modal'
10
import CKEditor from '@app/components/UI/Ckeditor'
9
import Input from '@components/UI/inputs/Input'
11
import Modal from 'components/UI/modal/Modal'
10
import Ckeditor from '@components/UI/Ckeditor'
Línea 12... Línea 11...
12
import TagsInput from 'components/UI/TagsInput'
11
import TagsInput from '@components/UI/TagsInput'
13
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
12
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
14
 
13
 
15
const QuestionModal = ({ show, url, isEdit, onClose, onComplete }) => {
14
const QuestionModal = ({ show, url, isEdit, onClose, onComplete }) => {
16
  const [questionsCategories, setQuestionsCategories] = useState([])
15
  const [questionsCategories, setQuestionsCategories] = useState([])
Línea 17... Línea 16...
17
  const [currentCategories, setCurrentCategories] = useState([])
16
  const [currentCategories, setCurrentCategories] = useState([])
18
  const labels = useSelector(({ intl }) => intl.labels)
17
  const labels = useSelector(({ intl }) => intl.labels)
-
 
18
  const dispatch = useDispatch()
19
  const dispatch = useDispatch()
19
 
20
 
20
  const {
21
  const {
-
 
22
    register,
21
    register,
23
    handleSubmit,
22
    control,
24
    setValue,
-
 
Línea 25... Línea 23...
25
    watch,
23
    handleSubmit,
26
    formState: { errors }
24
    setValue,
Línea 27... Línea 25...
27
  } = useForm()
25
    formState: { errors }
Línea 141... Línea 139...
141
      title={`${isEdit ? labels.edit : labels.add} ${labels.question}`}
139
      title={`${isEdit ? labels.edit : labels.add} ${labels.question}`}
142
      show={show}
140
      show={show}
143
      onClose={onClose}
141
      onClose={onClose}
144
      onAccept={onSubmit}
142
      onAccept={onSubmit}
145
    >
143
    >
146
      <Form.Group>
144
      <Input
147
        <Form.Label>{labels.title}</Form.Label>
-
 
148
        <Form.Control
-
 
149
          type='text'
-
 
150
          name='title'
145
        name='title'
151
          ref={register({ required: true })}
-
 
152
        />
-
 
153
 
-
 
154
        {errors.title && (
146
        control={control}
155
          <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
147
        rules={{ required: labels.error_field_empty }}
156
        )}
-
 
157
      </Form.Group>
-
 
158
 
-
 
159
      <Box mt={2}>
-
 
160
        <label>Categorías</label>
-
 
161
        <TagsInput
-
 
162
          suggestions={questionsCategories}
-
 
163
          settedTags={currentCategories}
-
 
164
          onChange={onTagsChange}
-
 
165
        />
-
 
166
        {errors.category_id && (
148
        error={errors.title?.message}
167
          <FormErrorFeedback>{errors.category_id?.message}</FormErrorFeedback>
-
 
168
        )}
-
 
169
      </Box>
-
 
170
 
-
 
171
      <CKEditor
-
 
172
        defaultValue={watchedDescription}
-
 
173
        onChange={(value) => setValue('description', value)}
-
 
174
      />
149
      />
-
 
150
 
-
 
151
      <TagsInput
-
 
152
        label='Categorías'
-
 
153
        name='category_id'
-
 
154
        onChange={onTagsChange}
-
 
155
        suggestions={questionsCategories}
-
 
156
        defaultValue={currentCategories}
-
 
157
      />
175
      {errors.description && (
158
      {errors.category_id && (
176
        <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
159
        <FormErrorFeedback>{errors.category_id?.message}</FormErrorFeedback>
177
      )}
160
      )}
-
 
161
 
-
 
162
      <Ckeditor
-
 
163
        name='description'
-
 
164
        control={control}
-
 
165
        rules={{ required: labels.error_field_empty }}
-
 
166
        error={errors.description?.message}
-
 
167
      />
178
    </Modal>
168
    </Modal>
179
  )
169
  )
180
}
170
}
Línea 181... Línea 171...
181
 
171