Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 14883 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
14879 stevensc 1
import axios from 'axios'
2
import React, { useState } from 'react'
3
import { useEffect } from 'react'
4
import { Button, Modal } from 'react-bootstrap'
5
import { useDispatch } from 'react-redux'
6
import { addNotification } from '../../../redux/notification/notification.actions'
7
 
8
 
14882 stevensc 9
const AppliedModal = ({ closeModal, dataLink }) => {
14879 stevensc 10
 
11
	const dispatch = useDispatch()
14884 stevensc 12
	const [data, setData] = useState([])
14879 stevensc 13
 
14
	const getData = () => {
15
		axios.get(dataLink)
16
			.then(({ data }) => {
17
				if (!data.success) {
18
					typeof data.data === 'string'
19
						?
20
						dispatch(addNotification({
21
							style: 'danger',
22
							msg: data.data
23
						}))
24
						: Object.entries(data.data).map(([key, value]) =>
25
							value.map(err =>
26
								dispatch(addNotification({
27
									style: 'danger',
28
									msg: `${key}: ${err}`
29
								}))
30
							)
31
						)
32
					return
33
				}
34
 
35
				setData(data.data)
36
			})
37
	}
38
 
39
	useEffect(() => {
40
		getData()
41
	}, [])
42
 
43
 
44
	return (
45
		<Modal size="lg" show onHide={closeModal}>
46
			<Modal.Header closeButton>
47
				<Modal.Title>Usuario que aplicaron</Modal.Title>
48
			</Modal.Header>
49
			<Modal.Body>
14883 stevensc 50
				<table className="table table-hover dataTable no-footer dtr-inline w-100">
51
					<thead>
52
						<tr>
53
							<th className="text-vertical-middle">
54
								Nombre
55
							</th>
56
							<th className="text-vertical-middle">
57
								Correo
58
							</th>
59
							<th className="text-vertical-middle">
60
								Acciones
61
							</th>
62
						</tr>
63
					</thead>
64
					<tbody>
65
						{
66
							data.map((item, index) =>
67
								<tr key={index}>
68
									<td>{`${item.first_name} ${item.last_name}`}</td>
69
									<td>{item.email}</td>
70
									<td>
71
										<a
72
											className='btn btn-default btn-view-profile'
73
											href={item.link_view}
74
											target="_blank"
75
											rel="noopener noreferrer"
76
										>
77
											<i className='fa fa-external-link' />
78
											Ver aplicación
79
										</a>
80
									</td>
81
								</tr>
82
							)}
83
					</tbody>
84
				</table >
14879 stevensc 85
			</Modal.Body>
86
			<Modal.Footer>
87
				<Button variant="danger" onClick={closeModal}>
14883 stevensc 88
					Cerrar
14879 stevensc 89
				</Button>
90
			</Modal.Footer>
91
		</Modal >
92
	)
93
}
94
 
95
export default AppliedModal