Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
6788 stevensc 1
import React, { useState } from 'react'
6680 stevensc 2
import TableFilters from "../components/TableFilters"
6628 stevensc 3
 
6680 stevensc 4
const JobsTableView = ({ allowAdd, allowEdit, allowDelete, link_table, link_add }) => {
5
 
6
    const [companyData, setCompanyData] = useState({});
7
    const [showModal, setShowModal] = useState(false);
8
    const [showDeleteModal, setShowDeleteModal] = useState(false);
9
    const [actionLink, setActionLink] = useState(link_add);
10
    const headers = [
11
        { key: "last_date_of_application", label: "Último día de aplicación", isSorteable: true },
12
        { key: "title", label: "Título", isSorteable: true },
13
        { key: "details", label: "Detalles", isSorteable: true },
14
        { key: "actions", label: "Acciones", isSorteable: false }
15
    ]
16
 
17
    const getData = (search, start, length) => {
18
        axios.get(
19
            link_table,
20
            {
21
                params: {
22
                    search: search,
23
                    start: start,
24
                    length: length
25
                }
26
            })
27
            .then(({ data }) => {
28
                if (data.success) {
29
                    setCompanyData(data.data)
30
 
31
                    return data.data
32
                }
33
            })
34
            .catch((err) => console.log(err))
35
    }
36
 
37
    const closeModal = () => {
38
        setShowModal(false)
39
        setActionLink(link_add)
40
    }
41
 
42
    const closeDeleteModal = () => {
43
        setShowDeleteModal(false)
44
        setActionLink(link_add)
45
    }
46
 
47
    const deleteItem = (item) => {
48
        setActionLink(item.actions.link_delete);
49
        setShowDeleteModal(true);
50
    }
51
 
52
    const addItem = () => {
53
        setActionLink(link_add)
54
        setShowModal(true);
55
    }
56
 
6628 stevensc 57
    return (
58
        <>
59
            <section className="content-header">
60
                <div className="container-fluid">
61
                    <div className="row mb-2">
62
                        <div className="col-sm-12">
6680 stevensc 63
                            <h1>Empleos</h1>
6628 stevensc 64
                        </div>
65
                    </div>
66
                </div>
67
            </section>
6680 stevensc 68
            <TableFilters
69
                data={companyData}
70
                getData={getData}
71
                onDelete={deleteItem}
72
                onAdd={addItem}
73
                headers={headers}
74
                allowAdd={allowAdd}
75
                allowEdit={allowEdit}
76
                allowDelete={allowDelete}
77
            />
78
            <DeleteModal
79
                isOpen={showDeleteModal}
80
                closeModal={closeDeleteModal}
81
                url={actionLink}
82
                action={getData}
83
            />
6628 stevensc 84
        </>
85
    )
86
}
87
 
88
export default JobsTableView