Rev 11961 | Rev 11965 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable no-mixed-spaces-and-tabs */
import React, { useState, useEffect } from 'react'
import { Card } from 'react-bootstrap'
import { LengthFilter, SearchInput, Table, TablePagination } from '../../../recruitment_and_selection/components/TableComponents'
import { addNotification } from '../../../redux/notification/notification.actions'
import DeleteModal from '../../../shared/DeleteModal'
import axios from 'axios'
import { useDispatch } from 'react-redux'
const headers = [
{ key: 'name', label: 'Nombre', isSorteable: true },
{ key: 'job_description', label: 'Descripción', isSorteable: true },
{ key: 'status', label: 'Estatus', isSorteable: false },
{ key: 'actions', label: 'Acciones', isSorteable: false }
]
const TableView = (props) => {
console.log(props)
const { add_link, table_link, permisions } = props
const dispatch = useDispatch()
const [modalToShow, setModalToShow] = useState('')
const [actionLink, setActionLink] = useState(add_link)
const [items, setItems] = useState([])
const [total, setTotal] = useState(0)
const [search, setSearch] = useState('')
const [dataLength, setDataLength] = useState(10)
const [pages, setPages] = useState({
current: 1,
last: 1
})
const getData = ({ url = '', params = {} }) => {
axios.get(url, { params: { ...params } })
.then(({ data }) => {
if (!data.success) {
return dispatch(addNotification({
style: 'danger',
msg: 'Ha ocurrido un error'
}))
}
setItems(data.data.items)
setTotal(data.data.total)
setPages({ ...pages, last: Math.ceil(data.data.total / dataLength) })
})
.catch(() => dispatch(addNotification({
style: 'danger',
msg: 'Ha ocurrido un error'
})))
}
useEffect(() => {
getData({
url: table_link,
params: {
search: search,
length: dataLength,
page: pages.current
}
})
}, [search, dataLength, pages.current])
return (
<>
Hello
</>
)
}
export default TableView