Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1460 Rev 1929
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect } 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 { CKEditor } from 'ckeditor4-react'
4
import { CKEditor } from 'ckeditor4-react'
Línea 5... Línea 5...
5
 
5
 
6
import { CKEDITOR_OPTIONS, axios } from 'utils/index'
6
import { CKEDITOR_OPTIONS, axios } from 'utils/index'
Línea 7... Línea 7...
7
import { addNotification } from '../../redux/notification/notification.actions'
7
import { addNotification } from '../../redux/notification/notification.actions'
8
 
-
 
9
import Modal from 'components/UI/modal/Modal'
8
 
Línea 10... Línea 9...
10
import Spinner from 'components/UI/Spinner'
9
import Modal from 'components/UI/modal/Modal'
11
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
10
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
12
 
11
 
13
const AnswerModal = ({
12
const AnswerModal = ({
14
  show = false,
13
  show = false,
15
  currentAnswer = '',
14
  currentAnswer = '',
16
  url = '',
15
  url = '',
17
  onClose = () => null,
-
 
18
  onComplete = () => null
16
  onClose = () => null,
19
}) => {
17
  onComplete = () => null
Línea 20... Línea 18...
20
  const [loading, setLoading] = useState(false)
18
}) => {
Línea 21... Línea 19...
21
  const labels = useSelector(({ intl }) => intl.labels)
19
  const labels = useSelector(({ intl }) => intl.labels)
22
  const dispatch = useDispatch()
-
 
23
 
20
  const dispatch = useDispatch()
24
  const { register, handleSubmit, setValue, errors } = useForm()
21
 
Línea 25... Línea 22...
25
 
22
  const { register, handleSubmit, setValue, errors } = useForm()
26
  const onSubmit = handleSubmit(({ description }) => {
23
 
Línea 44... Línea 41...
44
        }
41
        }
Línea 45... Línea 42...
45
 
42
 
46
        onComplete(data)
43
        onComplete(data)
47
        onClose()
44
        onClose()
48
      })
-
 
49
      .finally(() => setLoading(false))
45
      })
Línea 50... Línea 46...
50
  })
46
  })
51
 
47
 
52
  useEffect(() => {
48
  useEffect(() => {
Línea 73... Línea 69...
73
      />
69
      />
74
      {errors.description && (
70
      {errors.description && (
75
        <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
71
        <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
76
      )}
72
      )}
Línea 77... Línea -...
77
 
-
 
78
      {loading && <Spinner />}
73
 
79
    </Modal>
74
    </Modal>
80
  )
75
  )
Línea 81... Línea 76...
81
}
76
}