Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15499 Rev 15507
Línea 5... Línea 5...
5
import TableFilters from '../../../shared/table/TableFilters'
5
import TableFilters from '../../../shared/table/TableFilters'
6
import Table from '../../../shared/table/Table'
6
import Table from '../../../shared/table/Table'
Línea 7... Línea 7...
7
 
7
 
8
const IndustriesView = ({ urlsVar }) => {
8
const IndustriesView = ({ urlsVar }) => {
-
 
9
	const { linkTable, addUrl, allowAdd, allowEdit, allowDelete } = urlsVar
9
	const { linkTable, addUrl, allowAdd, allowEdit, allowDelete } = urlsVar
10
 
10
	const [companyData, setCompanyData] = useState({})
-
 
11
	const [showModal, setShowModal] = useState(false)
-
 
-
 
11
	const [industries, setIndustries] = useState({})
12
	const [showDeleteModal, setShowDeleteModal] = useState(false)
12
 
13
	const [selectItem, setSelectItem] = useState(null)
13
	const [selectItem, setSelectItem] = useState(null)
-
 
14
	const [actionLink, setActionLink] = useState(addUrl)
-
 
15
 
-
 
16
	const [showModal, setShowModal] = useState(false)
-
 
17
	const [showDeleteModal, setShowDeleteModal] = useState(false)
14
	const [actionLink, setActionLink] = useState(addUrl)
18
 
15
	const headers = [
19
	const headers = [
16
		{ key: 'name', label: 'Nombre', isSorteable: true },
20
		{ key: 'name', label: 'Nombre', isSorteable: true },
17
		{ key: 'status', label: 'Activo', isSorteable: false },
21
		{ key: 'status', label: 'Activo', isSorteable: false },
18
		{ key: 'actions', label: 'Acciones', isSorteable: false }
22
		{ key: 'actions', label: 'Acciones', isSorteable: false }
Línea 19... Línea 23...
19
	]
23
	]
20
 
24
 
21
	const getData = (params = {}) => {
25
	const getData = (params = {}) => {
22
		axios.get(linkTable, { params: params })
26
		axios.get(linkTable, { params: params })
23
			.then(({ data: response }) => {
27
			.then(({ data: response }) => {
24
				if (response.success) setCompanyData(response.data)
28
				if (response.success) setIndustries(response.data)
25
			})
29
			})
Línea 26... Línea 30...
26
			.catch((err) => console.log(err))
30
			.catch((err) => console.log(err))
27
	}
31
	}
28
 
-
 
29
	const closeModal = () => {
-
 
30
		setShowModal(false)
32
 
Línea 31... Línea 33...
31
		setSelectItem(null)
33
	const closeModal = () => {
32
		setActionLink(addUrl)
34
		setShowModal(false)
33
	}
-
 
34
 
35
	}
Línea 35... Línea 36...
35
	const closeDeleteModal = () => {
36
 
36
		setShowDeleteModal(false)
37
	const closeDeleteModal = () => {
37
		setActionLink(addUrl)
38
		setShowDeleteModal(false)
Línea 47... Línea 48...
47
		setActionLink(item.actions.link_delete)
48
		setActionLink(item.actions.link_delete)
48
		setShowDeleteModal(true)
49
		setShowDeleteModal(true)
49
	}
50
	}
Línea 50... Línea 51...
50
 
51
 
51
	const addItem = () => {
-
 
52
		setSelectItem(null)
52
	const addItem = () => {
53
		setActionLink(addUrl)
53
		setActionLink(addUrl)
54
		setShowModal(true)
54
		setShowModal(true)
Línea 55... Línea -...
55
	}
-
 
56
 
-
 
57
	const tableRendered = () => {
-
 
58
		return (
-
 
59
			<Table
-
 
60
				data={companyData.items}
-
 
61
				onEdit={editItem}
-
 
62
				onDelete={deleteItem}
-
 
63
				headers={headers}
-
 
64
				allowEdit={allowEdit}
-
 
65
				allowDelete={allowDelete}
-
 
66
			/>
-
 
67
		)
-
 
68
	}
55
	}
69
 
56
 
70
	return (
57
	return (
71
		<>
58
		<>
72
			<section className="content">
59
			<section className="content">
73
				<section className="content-header">
60
				<section className="content-header">
74
					<h1>Industrias</h1>
61
					<h1>Industrias</h1>
75
				</section>
62
				</section>
-
 
63
				<div className="container-fluid">
-
 
64
					<TableFilters data={industries} getData={getData} onAdd={addItem} allowAdd={allowAdd}>
-
 
65
						{industries.items && 
-
 
66
						function() {
-
 
67
							return (
-
 
68
								<Table
-
 
69
									data={industries.items}
-
 
70
									onEdit={editItem}
-
 
71
									onDelete={deleteItem}
76
				<div className="container-fluid">
72
									headers={headers}
-
 
73
									allowEdit={allowEdit}
-
 
74
									allowDelete={allowDelete}
-
 
75
								/>
77
					<TableFilters data={companyData} getData={getData} onAdd={addItem} allowAdd={allowAdd}>
76
							)
78
						{companyData.items && tableRendered()}
77
						}()}
79
					</TableFilters>
78
					</TableFilters>
80
				</div>
79
				</div>
81
			</section>
80
			</section>
82
			<EditModal
-
 
83
				isOpen={showModal}
-
 
84
				title='Industrias'
-
 
85
				closeModal={closeModal}
81
			<EditModal
86
				isEdit={actionLink !== addUrl}
82
				isOpen={showModal}
87
				url={actionLink}
83
				url={actionLink}
-
 
84
				currentItem={selectItem}
-
 
85
				onComplete={()=> getData()}
-
 
86
				onClose={()=> {
-
 
87
					if(selectItem) setSelectItem(null)
88
				currentItem={selectItem}
88
					closeModal()
89
				action={getData}
89
				}}
90
			/>
90
			/>
91
			<DeleteModal
91
			<DeleteModal
92
				isOpen={showDeleteModal}
92
				isOpen={showDeleteModal}