Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11152 Rev 14843
Línea 1... Línea 1...
1
import axios from 'axios'
1
import axios from 'axios'
2
import React, { useState } from 'react'
2
import React, { useState } from 'react'
3
import { Button, Modal } from 'react-bootstrap'
3
import { Button, Modal } from 'react-bootstrap'
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
-
 
5
import { useDispatch } from 'react-redux'
-
 
6
import { addNotification } from '../../../redux/notification/notification.actions'
Línea 5... Línea 7...
5
 
7
 
Línea 6... Línea 8...
6
const FooterModal = ({ isOpen, closeModal, footerUploadUrl, action }) => {
8
const FooterModal = ({ isOpen, closeModal, footerUploadUrl, action }) => {
7
 
9
 
-
 
10
	const { handleSubmit, register } = useForm()
Línea 8... Línea 11...
8
	const { handleSubmit, register } = useForm()
11
	const [error, setError] = useState()
9
	const [error, setError] = useState()
12
	const dispatch = useDispatch()
10
 
13
 
Línea 11... Línea 14...
11
	const onSubmit = ({ footer }) => {
14
	const onSubmit = ({ footer }) => {
12
		const data = new FormData()
15
		const data = new FormData()
13
		data.append('footer', footer[0])
16
		data.append('footer', footer[0])
-
 
17
 
-
 
18
		axios.post(footerUploadUrl, data)
-
 
19
			.then(({ data }) => {
-
 
20
				if (!data.success) {
14
 
21
					typeof data.data === 'string'
-
 
22
						?
-
 
23
						dispatch(addNotification({
-
 
24
							style: 'danger',
-
 
25
							msg: data.data
-
 
26
						}))
-
 
27
						: Object.entries(data.data).map(([key, value]) =>
-
 
28
							value.map(err =>
-
 
29
								dispatch(addNotification({
-
 
30
									style: 'danger',
-
 
31
									msg: `${key}: ${err}`
15
		axios.post(footerUploadUrl, data)
32
								}))
16
			.then(({ data }) => {
33
							)
17
				if (!data.success) {
34
						)
18
					return setError(data.data)
35
					return
19
				}
36
				}
Línea 55... Línea 72...
55
				<Modal.Footer>
72
				<Modal.Footer>
56
					<Button
73
					<Button
57
						variant="primary"
74
						variant="primary"
58
						type="submit"
75
						type="submit"
59
					>
76
					>
60
                        Enviar
77
						Enviar
61
					</Button>
78
					</Button>
62
					<Button
79
					<Button
63
						className='btn-tertiary'
80
						className='btn-tertiary'
64
						onClick={closeModal}
81
						onClick={closeModal}
65
					>
82
					>
66
                        Cancelar
83
						Cancelar
67
					</Button>
84
					</Button>
68
				</Modal.Footer>
85
				</Modal.Footer>
69
			</form>
86
			</form>
70
		</Modal >
87
		</Modal >
71
	)
88
	)