Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 11960 | Rev 11964 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
11960 stevensc 1
/* eslint-disable no-mixed-spaces-and-tabs */
2
import React, { useState, useEffect } from 'react'
3
import { Card } from 'react-bootstrap'
4
import { LengthFilter, SearchInput, Table, TablePagination } from '../../../recruitment_and_selection/components/TableComponents'
5
import { addNotification } from '../../../redux/notification/notification.actions'
6
import DeleteModal from '../../../shared/DeleteModal'
7
import axios from 'axios'
8
import { useDispatch } from 'react-redux'
9
 
10
const headers = [
11
	{ key: 'name', label: 'Nombre', isSorteable: true },
12
	{ key: 'job_description', label: 'Descripción', isSorteable: true },
13
	{ key: 'status', label: 'Estatus', isSorteable: false },
14
	{ key: 'actions', label: 'Acciones', isSorteable: false }
15
]
16
 
17
const TableView = ({ add_link, table_link, permisions }) => {
18
 
19
	const dispatch = useDispatch()
20
	const [modalToShow, setModalToShow] = useState('')
21
	const [actionLink, setActionLink] = useState(add_link)
22
	const [items, setItems] = useState([])
23
	const [total, setTotal] = useState(0)
24
	const [search, setSearch] = useState('')
25
	const [dataLength, setDataLength] = useState(10)
26
	const [pages, setPages] = useState({
27
		current: 1,
28
		last: 1
29
	})
30
 
31
	const getData = ({ url = '', params = {} }) => {
32
 
33
		axios.get(url, { params: { ...params } })
34
			.then(({ data }) => {
35
				if (!data.success) {
36
					return dispatch(addNotification({
37
						style: 'danger',
38
						msg: 'Ha ocurrido un error'
39
					}))
40
				}
41
 
42
				setItems(data.data.items)
43
				setTotal(data.data.total)
44
				setPages({ ...pages, last: Math.ceil(data.data.total / dataLength) })
45
			})
46
			.catch(() => dispatch(addNotification({
47
				style: 'danger',
48
				msg: 'Ha ocurrido un error'
49
			})))
50
	}
51
 
52
	useEffect(() => {
53
		getData({
54
			url: table_link,
55
			params: {
56
				search: search,
57
				length: dataLength,
58
				page: pages.current
59
			}
60
		})
61
	}, [search, dataLength, pages.current])
62
 
63
	return (
64
		<>
11961 stevensc 65
            Hello
11960 stevensc 66
		</>
67
	)
68
}
69
 
70
export default TableView