Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7774 | Rev 11131 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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