Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15393 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 15393 Rev 15530
Línea 1... Línea -...
1
import React, { useState } from 'react'
-
 
2
import axios from 'axios'
1
import axios from 'axios'
3
import EditModal from '../../groups-types/view/EditModal'
2
import React, { useState } from 'react'
4
import TableContainer from '../../company-sizes/view/TableContainer'
-
 
5
import DeleteModal from '../../../shared/DeleteModal'
3
import DeleteModal from '../../../shared/DeleteModal'
-
 
4
import Table from '../../../shared/table/Table'
-
 
5
import TableFilters from '../../../shared/table/TableFilters'
-
 
6
import EditModal from '../../groups-types/view/EditModal'
Línea 6... Línea -...
6
 
-
 
7
const HobbiesAndInterestsView = ({ urlsVar }) => {
-
 
8
 
7
 
9
	const { linkTable, addUrl, allowAdd, allowEdit, allowDelete } = urlsVar
8
const HobbiesAndInterestsView = ({ linkTable, addUrl, allowAdd, allowEdit, allowDelete }) => {
10
	const [companyData, setCompanyData] = useState({})
-
 
11
	const [showModal, setShowModal] = useState(false)
-
 
12
	const [showDeleteModal, setShowDeleteModal] = useState(false)
9
	const [hobbiesAndInterests, setHobbiesAndInterests] = useState({})
13
	const [selectItem, setSelectItem] = useState(null)
10
	const [selectItem, setSelectItem] = useState(null)
-
 
11
	const [actionLink, setActionLink] = useState(addUrl)
-
 
12
	const [showModal, setShowModal] = useState(false)
-
 
13
	const [showDeleteModal, setShowDeleteModal] = useState(false)
14
	const [actionLink, setActionLink] = useState(addUrl)
14
 
15
	const headers = [
15
	const headers = [
16
		{ key: 'name', label: 'Nombre', isSorteable: true },
16
		{ key: 'name', label: 'Nombre', isSorteable: true },
17
		{ key: 'status', label: 'Activo', isSorteable: false },
17
		{ key: 'status', label: 'Activo', isSorteable: false },
18
		{ key: 'actions', label: 'Acciones', isSorteable: false }
18
		{ key: 'actions', label: 'Acciones', isSorteable: false }
Línea 19... Línea 19...
19
	]
19
	]
20
 
-
 
21
	const getData = (search, start, length) => {
-
 
22
		axios.get(
-
 
23
			linkTable,
-
 
24
			{
20
 
25
				params: {
-
 
26
					search: search,
-
 
27
					start: start,
-
 
28
					length: length
-
 
29
				}
21
	const getData = (params) => {
30
			})
-
 
31
			.then(({ data }) => {
22
		axios.get(linkTable, { params: params })
32
				if (data.success) {
-
 
33
					setCompanyData(data.data)
-
 
34
 
-
 
35
					return data.data
23
			.then(({ data }) => {
36
				}
24
				if (data.success) setHobbiesAndInterests(data.data)
37
			})
25
			})
Línea 38... Línea 26...
38
			.catch((err) => console.log(err))
26
			.catch((err) => console.log(err))
39
	}
27
	}
40
 
-
 
41
	const closeModal = () => {
-
 
42
		setShowModal(false)
28
 
Línea 43... Línea 29...
43
		setSelectItem(null)
29
	const closeModal = () => {
44
		setActionLink(addUrl)
30
		setShowModal(false)
45
	}
-
 
46
 
31
	}
Línea 47... Línea 32...
47
	const closeDeleteModal = () => {
32
 
48
		setShowDeleteModal(false)
33
	const closeDeleteModal = () => {
49
		setActionLink(addUrl)
34
		setShowDeleteModal(false)
Línea 59... Línea 44...
59
		setActionLink(item.actions.link_delete)
44
		setActionLink(item.actions.link_delete)
60
		setShowDeleteModal(true)
45
		setShowDeleteModal(true)
61
	}
46
	}
Línea 62... Línea 47...
62
 
47
 
63
	const addItem = () => {
-
 
64
		setSelectItem(null)
48
	const addItem = () => {
65
		setActionLink(addUrl)
49
		setActionLink(addUrl)
66
		setShowModal(true)
50
		setShowModal(true)
Línea 67... Línea 51...
67
	}
51
	}
68
 
52
 
69
	return (
53
	return (
70
		<>
54
		<>
-
 
55
			<section className="content">
-
 
56
				<section className="content-header">
71
			<section className="content">
57
					<h1>Pasatiempos e Intereses</h1>
-
 
58
				</section>
-
 
59
				<section className="container-fluid">
-
 
60
					<TableFilters data={hobbiesAndInterests} getData={getData} onAdd={addItem} allowAdd={allowAdd}>
-
 
61
						{hobbiesAndInterests.items &&
-
 
62
							function () {
-
 
63
								return (
-
 
64
									<Table
72
				<section className="content-header">
65
										data={hobbiesAndInterests.items}
-
 
66
										onEdit={editItem}
73
					<div className="container-fluid">
67
										onDelete={deleteItem}
74
						<div className="row mb-2">
68
										headers={headers}
75
							<div className="col-sm-12">
69
										allowEdit={allowEdit}
76
								<h1>Pasatiempos e Intereses</h1>
70
										allowDelete={allowDelete}
77
							</div>
71
									/>
-
 
72
								)
78
						</div>
73
							}()}
79
					</div>
-
 
80
				</section>
-
 
81
				<TableContainer
-
 
82
					data={companyData}
-
 
83
					getData={getData}
-
 
84
					onEdit={editItem}
-
 
85
					onDelete={deleteItem}
-
 
86
					onAdd={addItem}
-
 
87
					headers={headers}
-
 
88
					allowAdd={allowAdd}
-
 
89
					allowEdit={allowEdit}
-
 
90
					allowDelete={allowDelete}
74
					</TableFilters>
91
				/>
75
				</section>
92
			</section>
-
 
93
			<EditModal
76
			</section>
94
				isOpen={showModal}
77
			<EditModal
95
				title='Pasatiempos e Intereses'
-
 
96
				closeModal={closeModal}
-
 
97
				isEdit={actionLink !== addUrl}
78
				title='Pasatiempos e Intereses'
-
 
79
				isOpen={showModal}
98
				url={actionLink}
80
				currentItem={selectItem}
-
 
81
				url={actionLink}
-
 
82
				onComplete={getData}
-
 
83
				onClose={() => {
-
 
84
					if (selectItem) setSelectItem(null)
99
				currentItem={selectItem}
85
					closeModal()
100
				action={getData}
86
				}}
101
			/>
87
			/>
102
			<DeleteModal
88
			<DeleteModal
103
				isOpen={showDeleteModal}
89
				isOpen={showDeleteModal}