Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11160 Rev 14843
Línea 1... Línea 1...
1
import axios from 'axios'
1
import axios from 'axios'
2
import React, { useEffect, useState } from 'react'
2
import React, { useEffect, useState } from 'react'
3
import { Modal, Button } from 'react-bootstrap'
3
import { Modal, Button } from 'react-bootstrap'
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
5
import { CKEditor } from 'ckeditor4-react'
5
import { CKEditor } from 'ckeditor4-react'
-
 
6
import { addNotification } from '../../../redux/notification/notification.actions'
-
 
7
import { useDispatch } from 'react-redux'
Línea 6... Línea 8...
6
 
8
 
7
const OverviewModal = ({
9
const OverviewModal = ({
8
	isOpen = false,
10
	isOpen = false,
9
	closeModal = function () { },
11
	closeModal = function () { },
Línea 12... Línea 14...
12
	overview
14
	overview
13
}) => {
15
}) => {
Línea 14... Línea 16...
14
 
16
 
15
	const { register, handleSubmit, setValue, watch } = useForm()
17
	const { register, handleSubmit, setValue, watch } = useForm()
-
 
18
	const [error, setError] = useState(null)
Línea 16... Línea 19...
16
	const [error, setError] = useState(null)
19
	const dispatch = useDispatch()
17
 
20
 
18
	const onSubmit = ({ description }) => {
21
	const onSubmit = ({ description }) => {
Línea 19... Línea 22...
19
		const formData = new FormData
22
		const formData = new FormData
20
		formData.append('description', description)
23
		formData.append('description', description)
21
 
24
 
-
 
25
		axios.post(overviewUrl, formData)
-
 
26
			.then(({ data }) => {
-
 
27
				if (!data.success) {
-
 
28
					typeof data.data === 'string'
-
 
29
						?
-
 
30
						dispatch(addNotification({
-
 
31
							style: 'danger',
-
 
32
							msg: data.data
-
 
33
						}))
22
		axios.post(overviewUrl, formData)
34
						: Object.entries(data.data).map(([key, value]) =>
-
 
35
							value.map(err =>
-
 
36
								dispatch(addNotification({
-
 
37
									style: 'danger',
-
 
38
									msg: `${key}: ${err}`
-
 
39
								}))
23
			.then(({ data }) => {
40
							)
24
				if (!data.success) {
41
						)
25
					return setError('Error')
42
					return
26
				}
43
				}
27
				action(data.data.description)
44
				action(data.data.description)