Proyectos de Subversion LeadersLinked - Backend

Rev

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

/* eslint-disable no-mixed-spaces-and-tabs */
import React from 'react'
import { useState } from 'react'

const SortButton = ({ onClick }) => {
        return (
                <button onClick={onClick} className="btn p-0">
                        <i className='fa fa-angle-down ml-2' />
                </button>
        )
}

const Table = ({ headers, children }) => {

        const [sortKey, setSortKey] = useState('name')

        return (
                <table className="table table-hover my-table w-100">
                        <thead>
                                <tr>
                                        {headers.map((row) =>
                                                <th key={row.key} className="text-vertical-middle">
                                                        {row.label}
                                                        {row.isSorteable &&
                                                                <SortButton
                                                                        columnKey={row.key}
                                                                        onClick={() => setSortKey(row.key)}
                                                                        sortKey={sortKey}
                                                                />
                                                        }
                                                </th>
                                        )}
                                </tr>
                        </thead>
                        <tbody>
                                {children()}
                        </tbody>
                </table >
        )
}

export default Table