Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11964 Rev 11965
Línea 12... Línea 12...
12
	{ key: 'job_description', label: 'Descripción', isSorteable: true },
12
	{ key: 'job_description', label: 'Descripción', isSorteable: true },
13
	{ key: 'status', label: 'Estatus', isSorteable: false },
13
	{ key: 'status', label: 'Estatus', isSorteable: false },
14
	{ key: 'actions', label: 'Acciones', isSorteable: false }
14
	{ key: 'actions', label: 'Acciones', isSorteable: false }
15
]
15
]
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea -...
17
const TableView = (props) => {
-
 
18
 
-
 
19
	console.log(props)
-
 
20
 
17
const TableView = ({ add_link, table_link, permisions }) => {
21
	const { add_link, table_link, permisions } = props
18
 
22
	const dispatch = useDispatch()
19
	const dispatch = useDispatch()
23
	const [modalToShow, setModalToShow] = useState('')
20
	const [modalToShow, setModalToShow] = useState('')
24
	const [actionLink, setActionLink] = useState(add_link)
21
	const [actionLink, setActionLink] = useState(add_link)
Línea 63... Línea 60...
63
		})
60
		})
64
	}, [search, dataLength, pages.current])
61
	}, [search, dataLength, pages.current])
Línea 65... Línea 62...
65
 
62
 
66
	return (
63
	return (
-
 
64
		<>
-
 
65
			<section className="content">
-
 
66
				<div className="container-fluid">
-
 
67
					<div className="row">
-
 
68
						<div className="col-12">
-
 
69
							<Card>
-
 
70
								<Card.Header>
-
 
71
									<div className="row justify-content-end" style={{ gap: '10px' }}>
-
 
72
										{
-
 
73
											permisions.allowAdd
-
 
74
											&&
-
 
75
											<label
-
 
76
												className='d-flex align-items-center'
-
 
77
												onClick={() => {
-
 
78
													setActionLink(add_link)
-
 
79
													setModalToShow('add')
-
 
80
												}}
-
 
81
												style={{ cursor: 'pointer' }}
-
 
82
											>
-
 
83
												<i className="fa fa-plus mr-2" />
-
 
84
												Agregar
-
 
85
											</label>
67
		<>
86
										}
-
 
87
										<label
-
 
88
											className='d-flex align-items-center'
-
 
89
											onClick={() => getData({
-
 
90
												url: table_link,
-
 
91
												params: {
-
 
92
													search: search,
-
 
93
													length: dataLength,
-
 
94
													page: pages.current
-
 
95
												}
-
 
96
											})}
-
 
97
											style={{ cursor: 'pointer' }}
-
 
98
										>
-
 
99
											<i className='fa fa-refresh mr-2' />
-
 
100
											Actualizar
-
 
101
										</label>
-
 
102
									</div>
-
 
103
									<div className="row justify-content-between align-items-center">
-
 
104
										<LengthFilter onChange={(e) => setDataLength(e.target.value)} />
-
 
105
										<SearchInput onChange={(e) => setSearch(e.target.value)} />
-
 
106
									</div>
-
 
107
								</Card.Header>
-
 
108
								<Card.Body>
-
 
109
									<div className="table-responsive">
-
 
110
										<Table data={items} headers={headers} setData={setItems}>
-
 
111
											{
-
 
112
												items.length
-
 
113
												&&
-
 
114
												items.map((item, index) => (
-
 
115
													<tr key={index}>
-
 
116
														<td className='text-vertical-middle'>{item.name}</td>
-
 
117
														<td className='text-vertical-middle'>{item.job_description}</td>
-
 
118
														<td className='text-vertical-middle'>
-
 
119
															{
-
 
120
																item.status === 'a'
-
 
121
																	? 'Activo'
-
 
122
																	: 'Inactivo'
-
 
123
															}
-
 
124
														</td>
-
 
125
														<td>
-
 
126
															<div className="d-flex align-items-center" style={{ gap: '5px' }}>
-
 
127
																{
-
 
128
																	permisions.allowEdit
-
 
129
																	&&
-
 
130
																	<i
-
 
131
																		className='fa fa-pencil'
-
 
132
																		onClick={() => {
-
 
133
																			setActionLink(item.actions.link_edit)
-
 
134
																			setModalToShow('edit')
-
 
135
																		}}
-
 
136
																		style={{ cursor: 'pointer' }}
-
 
137
																	/>
-
 
138
																}
-
 
139
																{
-
 
140
																	permisions.allowDelete
-
 
141
																	&&
-
 
142
																	<i
-
 
143
																		className='fa fa-trash'
-
 
144
																		onClick={() => {
-
 
145
																			setActionLink(item.actions.link_delete)
-
 
146
																			setModalToShow('delete')
-
 
147
																		}}
-
 
148
																		style={{ cursor: 'pointer' }}
-
 
149
																	/>
-
 
150
																}
-
 
151
																{
-
 
152
																	permisions.allowReport
-
 
153
																	&&
-
 
154
																	<a href={item.actions.link_report} target='_blank' rel="noreferrer" >
-
 
155
																		<i className='fa fa-fil' style={{ color: '#333' }} />
-
 
156
																	</a>
-
 
157
																}
-
 
158
															</div>
-
 
159
														</td>
-
 
160
													</tr>
-
 
161
												))
-
 
162
											}
-
 
163
										</Table>
-
 
164
									</div>
-
 
165
									<div className='row justify-content-between align-items-center'>
-
 
166
										<p className='mb-0'>
-
 
167
											{`Mostrando registros del ${(dataLength * pages.current) - (dataLength - 1) || 0} al ${(dataLength * pages.current) - (dataLength - total) || 0} de un total de ${total || 0} registros`}
-
 
168
										</p>
-
 
169
										<TablePagination
-
 
170
											onDecrement={() => setPages(prev => prev.current -= 1)}
-
 
171
											onIncrement={() => setPages(prev => prev.current += 1)}
-
 
172
											totalPages={pages.last}
-
 
173
											currentPage={pages.current}
-
 
174
										/>
-
 
175
									</div>
-
 
176
								</Card.Body>
-
 
177
							</Card>
-
 
178
						</div>
-
 
179
					</div >
-
 
180
				</div >
-
 
181
			</section >
-
 
182
			<DeleteModal
-
 
183
				url={actionLink}
-
 
184
				isOpen={modalToShow === 'delete'}
-
 
185
				closeModal={() => setModalToShow('')}
-
 
186
				title="Esta seguro de borrar este formulario?"
-
 
187
				onComplete={() => setItems(items.filter((item) => item.actions.link_delete !== actionLink))}
-
 
188
				message="Registro borrado"
68
            Hello
189
			/>
69
		</>
190
		</>
70
	)
191
	)
Línea 71... Línea 192...
71
}
192
}
72
 
193