Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12379 Rev 15102
Línea 4... Línea 4...
4
import { LengthFilter, SearchInput, Table, TablePagination } from '../../../recruitment_and_selection/components/TableComponents'
4
import { LengthFilter, SearchInput, Table, TablePagination } from '../../../recruitment_and_selection/components/TableComponents'
5
import { addNotification } from '../../../redux/notification/notification.actions'
5
import { addNotification } from '../../../redux/notification/notification.actions'
6
import DeleteModal from '../../../shared/DeleteModal'
6
import DeleteModal from '../../../shared/DeleteModal'
7
import axios from 'axios'
7
import axios from 'axios'
8
import { useDispatch } from 'react-redux'
8
import { useDispatch } from 'react-redux'
9
import { useHistory } from 'react-router-dom'
-
 
Línea 10... Línea 9...
10
 
9
 
11
const headers = [
10
const headers = [
12
	{ key: 'name', label: 'Nombre', isSorteable: true },
11
	{ key: 'name', label: 'Nombre', isSorteable: true },
13
	{ key: 'job_description', label: 'Descripción', isSorteable: true },
12
	{ key: 'job_description', label: 'Descripción', isSorteable: true },
14
	{ key: 'status', label: 'Estatus', isSorteable: false },
13
	{ key: 'status', label: 'Estatus', isSorteable: false },
15
	{ key: 'actions', label: 'Acciones', isSorteable: false }
14
	{ key: 'actions', label: 'Acciones', isSorteable: false }
Línea 16... Línea 15...
16
]
15
]
-
 
16
 
-
 
17
const TableView = ({
-
 
18
	add_link,
-
 
19
	table_link,
-
 
20
	permisions,
-
 
21
	actionLink,
Línea 17... Línea -...
17
 
-
 
18
const TableView = ({ add_link, table_link, permisions, actionLink, setActionLink }) => {
22
	setActionLink,
19
 
23
	setAction }) => {
20
	const history = useHistory()
24
 
21
	const dispatch = useDispatch()
25
	const dispatch = useDispatch()
22
	const [modalToShow, setModalToShow] = useState('')
26
	const [modalToShow, setModalToShow] = useState('')
Línea 62... Línea 66...
62
			}
66
			}
63
		})
67
		})
64
	}, [search, dataLength, pages.current])
68
	}, [search, dataLength, pages.current])
Línea 65... Línea 69...
65
 
69
 
66
	useEffect(() => {
70
	useEffect(() => {
67
		if (pages.current > 1) {
71
		pages.current > 1
68
			setStartItem((dataLength * (pages.current - 1)) + 1)
-
 
69
		} else {
72
			? setStartItem((dataLength * (pages.current - 1)) + 1)
70
			setStartItem(1)
-
 
71
		}
73
			: setStartItem(1)
Línea 72... Línea 74...
72
	}, [pages.current])
74
	}, [pages.current])
73
 
75
 
74
	useEffect(() => {
76
	useEffect(() => {
75
		if (items) {
77
		if (items) {
76
			if (startItem > 1) {
-
 
77
				setLastItem(startItem + (items.length - 1))
78
			startItem > 1
78
			} else {
-
 
79
				setLastItem(items.length)
79
				? setLastItem(startItem + (items.length - 1))
80
			}
80
				: setLastItem(items.length)
Línea 81... Línea 81...
81
		}
81
		}
82
	}, [items])
82
	}, [items])
Línea 88... Línea 88...
88
					<div className="row">
88
					<div className="row">
89
						<div className="col-12">
89
						<div className="col-12">
90
							<Card>
90
							<Card>
91
								<Card.Header>
91
								<Card.Header>
92
									<div className="row justify-content-end" style={{ gap: '10px' }}>
92
									<div className="row justify-content-end" style={{ gap: '10px' }}>
93
										{
-
 
94
											permisions.allowAdd
93
										{permisions.allowAdd &&
95
											&&
-
 
96
											<label
94
											<label
97
												className='d-flex align-items-center'
95
												className='d-flex align-items-center'
98
												onClick={() => {
96
												onClick={() => {
99
													setActionLink(add_link)
97
													setActionLink(add_link)
100
													history.push('/performance-evaluation/forms/add')
98
													setAction('add')
101
												}}
99
												}}
102
												style={{ cursor: 'pointer' }}
100
												style={{ cursor: 'pointer' }}
103
											>
101
											>
104
												<i className="fa fa-plus mr-2" />
102
												<i className="fa fa-plus mr-2" />
105
												Agregar
103
												Agregar
Línea 127... Línea 125...
127
									</div>
125
									</div>
128
								</Card.Header>
126
								</Card.Header>
129
								<Card.Body>
127
								<Card.Body>
130
									<div className="table-responsive">
128
									<div className="table-responsive">
131
										<Table data={items} headers={headers} setData={setItems}>
129
										<Table data={items} headers={headers} setData={setItems}>
132
											{
-
 
133
												items.length
130
											{!!items.length &&
134
												&&
-
 
135
												items.map((item, index) => (
131
												items.map((item, index) => (
136
													<tr key={index}>
132
													<tr key={index}>
137
														<td className='text-vertical-middle'>{item.name}</td>
133
														<td className='text-vertical-middle'>{item.name}</td>
138
														<td className='text-vertical-middle'>{item.job_description}</td>
134
														<td className='text-vertical-middle'>{item.job_description}</td>
139
														<td className='text-vertical-middle'>
135
														<td className='text-vertical-middle'>
140
															{
-
 
141
																item.status === 'a'
136
															{item.status === 'a'
142
																	? 'Activo'
137
																? 'Activo'
143
																	: 'Inactivo'
138
																: 'Inactivo'
144
															}
139
															}
145
														</td>
140
														</td>
146
														<td>
141
														<td>
147
															<div className="d-flex align-items-center" style={{ gap: '5px' }}>
142
															<div className="d-flex align-items-center" style={{ gap: '5px' }}>
148
																{
-
 
149
																	permisions.allowEdit
143
																{permisions.allowEdit &&
150
																	&&
-
 
151
																	<i
144
																	<i
152
																		className='fa fa-pencil'
145
																		className='fa fa-pencil'
153
																		onClick={() => {
146
																		onClick={() => {
154
																			setActionLink(item.actions.link_edit)
147
																			setActionLink(item.actions.link_edit)
155
																			history.push('/performance-evaluation/forms/edit')
148
																			setAction('edit')
156
																		}}
149
																		}}
157
																		style={{ cursor: 'pointer' }}
150
																		style={{ cursor: 'pointer' }}
158
																	/>
151
																	/>
159
																}
152
																}
160
																{
-
 
161
																	permisions.allowDelete
153
																{permisions.allowDelete &&
162
																	&&
-
 
163
																	<i
154
																	<i
164
																		className='fa fa-trash'
155
																		className='fa fa-trash'
165
																		onClick={() => {
156
																		onClick={() => {
166
																			setActionLink(item.actions.link_delete)
157
																			setActionLink(item.actions.link_delete)
167
																			setModalToShow('delete')
158
																			setModalToShow('delete')
168
																		}}
159
																		}}
169
																		style={{ cursor: 'pointer' }}
160
																		style={{ cursor: 'pointer' }}
170
																	/>
161
																	/>
171
																}
162
																}
172
																{
-
 
173
																	permisions.allowReport
163
																{permisions.allowReport &&
174
																	&&
-
 
175
																	<a href={item.actions.link_report} target='_blank' rel="noreferrer" >
164
																	<a href={item.actions.link_report} target='_blank' rel="noreferrer" >
176
																		<i className='fa fa-file' style={{ color: '#333' }} />
165
																		<i className='fa fa-file' style={{ color: '#333' }} />
177
																	</a>
166
																	</a>
178
																}
167
																}
179
															</div>
168
															</div>