Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 11961 | Rev 11965 | 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
 
11964 stevensc 17
const TableView = (props) => {
11960 stevensc 18
 
11964 stevensc 19
	console.log(props)
20
 
21
	const { add_link, table_link, permisions } = props
11960 stevensc 22
	const dispatch = useDispatch()
23
	const [modalToShow, setModalToShow] = useState('')
24
	const [actionLink, setActionLink] = useState(add_link)
25
	const [items, setItems] = useState([])
26
	const [total, setTotal] = useState(0)
27
	const [search, setSearch] = useState('')
28
	const [dataLength, setDataLength] = useState(10)
29
	const [pages, setPages] = useState({
30
		current: 1,
31
		last: 1
32
	})
33
 
34
	const getData = ({ url = '', params = {} }) => {
35
 
36
		axios.get(url, { params: { ...params } })
37
			.then(({ data }) => {
38
				if (!data.success) {
39
					return dispatch(addNotification({
40
						style: 'danger',
41
						msg: 'Ha ocurrido un error'
42
					}))
43
				}
44
 
45
				setItems(data.data.items)
46
				setTotal(data.data.total)
47
				setPages({ ...pages, last: Math.ceil(data.data.total / dataLength) })
48
			})
49
			.catch(() => dispatch(addNotification({
50
				style: 'danger',
51
				msg: 'Ha ocurrido un error'
52
			})))
53
	}
54
 
55
	useEffect(() => {
56
		getData({
57
			url: table_link,
58
			params: {
59
				search: search,
60
				length: dataLength,
61
				page: pages.current
62
			}
63
		})
64
	}, [search, dataLength, pages.current])
65
 
66
	return (
67
		<>
11961 stevensc 68
            Hello
11960 stevensc 69
		</>
70
	)
71
}
72
 
73
export default TableView