Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15310 | Rev 15314 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15310 stevensc 1
/* eslint-disable no-mixed-spaces-and-tabs */
2
import React from 'react'
3
import { useState } from 'react'
4
 
15312 stevensc 5
const SortButton = ({ onClick }) => {
15310 stevensc 6
	return (
7
		<button onClick={onClick} className="btn p-0">
15312 stevensc 8
			<i className='fa fa-angle-down ml-2' />
15310 stevensc 9
		</button>
10
	)
11
}
12
 
15312 stevensc 13
const Table = ({ headers, children }) => {
15310 stevensc 14
 
15
	const [sortKey, setSortKey] = useState('name')
16
 
17
	return (
18
		<table className="table table-hover my-table w-100">
19
			<thead>
20
				<tr>
21
					{headers.map((row) =>
22
						<th key={row.key} className="text-vertical-middle">
23
							{row.label}
24
							{row.isSorteable &&
15312 stevensc 25
								<SortButton
26
									columnKey={row.key}
27
									onClick={() => setSortKey(row.key)}
28
									sortKey={sortKey}
29
								/>
15310 stevensc 30
							}
31
						</th>
32
					)}
33
				</tr>
34
			</thead>
35
			<tbody>
36
				{children()}
37
			</tbody>
38
		</table >
39
	)
40
}
41
 
42
export default Table