Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14927 Rev 15126
Línea 1... Línea 1...
1
/* eslint-disable no-mixed-spaces-and-tabs */
1
/* eslint-disable no-mixed-spaces-and-tabs */
2
import React, { useState, useEffect } from 'react'
2
import React, { useState, useEffect } from 'react'
3
import axios from 'axios'
3
import axios from 'axios'
4
import { Card } from 'react-bootstrap'
4
import { Card } from 'react-bootstrap'
5
import { LengthFilter, SearchInput, Table, TablePagination } from '../../components/TableComponents'
5
import { LengthFilter, SearchInput, Table, TablePagination } from '../../components/TableComponents'
6
import { useHistory, useRouteMatch } from 'react-router-dom'
-
 
7
import { addNotification } from '../../../redux/notification/notification.actions'
6
import { addNotification } from '../../../redux/notification/notification.actions'
8
import { useDispatch } from 'react-redux'
7
import { useDispatch } from 'react-redux'
9
import DeleteModal from '../../../shared/DeleteModal'
8
import DeleteModal from '../../../shared/DeleteModal'
Línea 10... Línea 9...
10
 
9
 
Línea 15... Línea 14...
15
	{ key: 'vacancy', label: 'Vacantes', isSorteable: true },
14
	{ key: 'vacancy', label: 'Vacantes', isSorteable: true },
16
	{ key: 'points', label: 'Evaluación', isSorteable: true },
15
	{ key: 'points', label: 'Evaluación', isSorteable: true },
17
	{ key: 'actions', label: 'Acciones', isSorteable: false }
16
	{ key: 'actions', label: 'Acciones', isSorteable: false }
18
]
17
]
Línea -... Línea 18...
-
 
18
 
-
 
19
const points = {
-
 
20
	0: '0%',
-
 
21
	1: '25%',
-
 
22
	2: '50%',
-
 
23
	3: '75%',
-
 
24
	4: '100%'
-
 
25
}
19
 
26
 
-
 
27
const TableView = ({
-
 
28
	table_link,
-
 
29
	permisions,
-
 
30
	vacancies,
-
 
31
	setActionLink,
-
 
32
	add_link,
-
 
33
	setAction
Línea 20... Línea -...
20
const TableView = ({ table_link, permisions, vacancies, setActionLink, add_link }) => {
-
 
21
 
-
 
22
	const history = useHistory()
34
}) => {
23
	const { url } = useRouteMatch()
35
 
24
	const dispatch = useDispatch()
36
	const dispatch = useDispatch()
25
	const [showDeleteModal, setShowDeleteModal] = useState(false)
37
	const [showDeleteModal, setShowDeleteModal] = useState(false)
26
	const [currentVacancy, setCurrentVacancy] = useState((vacancies.length > 0) ? vacancies[0].uuid : '')
38
	const [currentVacancy, setCurrentVacancy] = useState((vacancies.length > 0) ? vacancies[0].uuid : '')
27
	const [deleteLink, setDeleteLink] = useState('')
39
	const [deleteLink, setDeleteLink] = useState('')
28
	const [items, setItems] = useState([])
40
	const [items, setItems] = useState([])
29
	const [total, setTotal] = useState(0)
41
	const [total, setTotal] = useState(0)
30
	const [search, setSearch] = useState('')
42
	const [search, setSearch] = useState('')
31
	const [startItem, setStartItem] = useState(1)
43
	const [startItem, setStartItem] = useState(1)
32
	const [lastItem, setLastItem] = useState(10)
-
 
33
	const [dataLength, setDataLength] = useState(10)
-
 
34
	const points = {
-
 
35
		0: '0%',
-
 
36
		1: '25%',
-
 
37
		2: '50%',
-
 
38
		3: '75%',
-
 
39
		4: '100%'
44
	const [lastItem, setLastItem] = useState(10)
40
	}
-
 
41
	const [pages, setPages] = useState({
-
 
42
		current: 1,
-
 
Línea 43... Línea 45...
43
		last: 1
45
	const [dataLength, setDataLength] = useState(10)
44
	})
-
 
45
 
46
	const [pages, setPages] = useState({ current: 1, last: 1 })
46
	const getData = ({ url = '', params = {} }) => {
47
 
47
 
48
	const getData = ({ url = '', params = {} }) => {
48
		axios.get(url, { params: { ...params } })
49
		axios.get(url, { params: { ...params } })
49
			.then(({ data }) => {
50
			.then(({ data }) => {
Línea 78... Línea 79...
78
	useEffect(() => {
79
	useEffect(() => {
79
		setActionLink(add_link.replace('UUID_PLACEHOLDER', currentVacancy))
80
		setActionLink(add_link.replace('UUID_PLACEHOLDER', currentVacancy))
80
	}, [currentVacancy])
81
	}, [currentVacancy])
Línea 81... Línea 82...
81
 
82
 
82
	useEffect(() => {
83
	useEffect(() => {
83
		if (pages.current > 1) {
84
		pages.current > 1
84
			setStartItem((dataLength * (pages.current - 1)) + 1)
-
 
85
		} else {
85
			? setStartItem((dataLength * (pages.current - 1)) + 1)
86
			setStartItem(1)
-
 
87
		}
86
			: setStartItem(1)
Línea 88... Línea 87...
88
	}, [pages.current])
87
	}, [pages.current])
89
 
88
 
90
	useEffect(() => {
89
	useEffect(() => {
91
		if (items) {
90
		if (items) {
92
			if (startItem > 1) {
-
 
93
				setLastItem(startItem + (items.length - 1))
91
			startItem > 1
94
			} else {
-
 
95
				setLastItem(items.length)
92
				? setLastItem(startItem + (items.length - 1))
96
			}
93
				: setLastItem(items.length)
Línea 97... Línea 94...
97
		}
94
		}
98
	}, [items])
95
	}, [items])
Línea 110... Línea 107...
110
											<label>Vacantes</label>
107
											<label>Vacantes</label>
111
											<select
108
											<select
112
												className="form-control"
109
												className="form-control"
113
												value={currentVacancy}
110
												value={currentVacancy}
114
												onChange={(e) => setCurrentVacancy(e.target.value)}
111
												onChange={(e) => setCurrentVacancy(e.target.value)}
115
												defaultValue={vacancies[0].uuid}
112
												defaultValue={vacancies[0].uuid}>
116
											>
113
												{vacancies.map((vacancy) =>
117
												{
114
													<option
118
													vacancies.map((vacancy) => (
115
														key={vacancy.uuid}
119
														<option key={vacancy.uuid} value={vacancy.uuid}>{vacancy.name}</option>
116
														value={vacancy.uuid}>
-
 
117
														{vacancy.name}
120
													))
118
													</option>
121
												}
119
												)}
122
											</select>
120
											</select>
123
										</div>
121
										</div>
124
									</div>
122
									</div>
125
									<div className="row justify-content-end" style={{ gap: '10px' }}>
123
									<div className="row justify-content-end" style={{ gap: '10px' }}>
126
										{
-
 
127
											permisions.allowAdd
124
										{permisions.allowAdd &&
128
											&&
-
 
129
											<label
125
											<label
130
												className='d-flex align-items-center'
126
												className='d-flex align-items-center'
131
												onClick={() => history.push(`${url}/add`)}
127
												onClick={() => setAction('add')}
132
												style={{ cursor: 'pointer' }}
128
												style={{ cursor: 'pointer' }}>
133
											>
-
 
134
												<i className="fa fa-plus mr-2" />
129
												<i className="fa fa-plus mr-2" />
135
												Agregar
130
												Agregar
136
											</label>
131
											</label>
137
										}
132
										}
138
										<label
133
										<label
Línea 157... Línea 152...
157
									</div>
152
									</div>
158
								</Card.Header>
153
								</Card.Header>
159
								<Card.Body>
154
								<Card.Body>
160
									<div className="table-responsive">
155
									<div className="table-responsive">
161
										<Table data={items} headers={headers} setData={setItems}>
156
										<Table data={items} headers={headers} setData={setItems}>
162
											{
-
 
163
												items.map((item) => (
157
											{items.map((item) => (
164
													<tr key={item.uuid}>
158
												<tr key={item.uuid}>
165
														<td>{`${item.first_name} ${item.last_name}`}</td>
159
													<td>{`${item.first_name} ${item.last_name}`}</td>
166
														<td>{item.email}</td>
160
													<td>{item.email}</td>
167
														<td>
161
													<td>
168
															{
-
 
169
																item.type === 'r'
162
														{item.type === 'r'
170
																	? 'Recursos Humanos'
163
															? 'Recursos Humanos'
171
																	: 'Potencial superior'
164
															: 'Potencial superior'
172
															}
165
														}
173
														</td>
166
													</td>
174
														<td>{item.vacancy}</td>
167
													<td>{item.vacancy}</td>
175
														<td>
-
 
176
															{
-
 
177
																points[item.points]
168
													<td>{points[item.points]}</td>
178
															}
-
 
179
														</td>
-
 
180
														<td className='d-inline-flex align-items-center' style={{ gap: '10px' }}>
169
													<td className='d-inline-flex align-items-center' style={{ gap: '10px' }}>
181
															{
-
 
182
																permisions.allowEdit
170
														{permisions.allowEdit &&
183
																&&
-
 
184
																<i
171
															<i
185
																	className='fa fa-pencil'
172
																className='fa fa-pencil'
186
																	style={{ cursor: 'pointer' }}
173
																style={{ cursor: 'pointer' }}
187
																	onClick={() => {
174
																onClick={() => {
188
																		setActionLink(item.actions.link_edit)
175
																	setActionLink(item.actions.link_edit)
189
																		history.push(`${url}/edit`)
176
																	setAction('edit')
190
																	}}
-
 
191
																/>
177
																}} />
192
															}
178
														}
193
															{
-
 
194
																permisions.allowDelete
179
														{permisions.allowDelete &&
195
																&&
-
 
196
																<i
180
															<i
197
																	className='fa fa-trash'
181
																className='fa fa-trash'
198
																	onClick={() => {
182
																onClick={() => {
199
																		setShowDeleteModal(true)
183
																	setShowDeleteModal(true)
200
																		setDeleteLink(item.actions.link_delete)
184
																	setDeleteLink(item.actions.link_delete)
201
																	}}
185
																}}
202
																	style={{ cursor: 'pointer' }}
186
																style={{ cursor: 'pointer' }} />
203
																/>
-
 
204
															}
187
														}
205
															{
-
 
206
																item.type === 'r'
188
														{item.type === 'r' &&
207
																&&
-
 
208
																<a
189
															<a
209
																	href={`/recruitment-and-selection/interview/${item.uuid}/file`}
190
																href={`/recruitment-and-selection/interview/${item.uuid}/file`}
210
																	className='btn p-0'
191
																className='btn p-0'
211
																	title='Cargar evaluación'
192
																title='Cargar evaluación'>
212
																>
-
 
213
																	<i className='fa fa-external-link' style={{ cursor: 'pointer' }} />
193
																<i className='fa fa-external-link' style={{ cursor: 'pointer' }} />
214
																</a>
194
															</a>
215
															}
195
														}
216
															{
-
 
217
																permisions.allowFile
196
														{permisions.allowFile &&
218
																&&
-
 
219
																<a href={item.actions.link_report} target='_blank' className='btn p-0' rel="noreferrer">
197
															<a href={item.actions.link_report} target='_blank' className='btn p-0' rel="noreferrer">
220
																	<i className='fa fa-file-o' style={{ cursor: 'pointer' }} />
198
																<i className='fa fa-file-o' style={{ cursor: 'pointer' }} />
221
																</a>
199
															</a>
222
															}
200
														}
223
														</td>
201
													</td>
224
													</tr>
202
												</tr>
225
												))
203
											))
226
											}
204
											}
227
										</Table>
205
										</Table>
228
									</div>
206
									</div>
229
									<div className='row justify-content-between align-items-center'>
207
									<div className='row justify-content-between align-items-center'>
230
										<p className='mb-0'>
208
										<p className='mb-0'>