import { useEffect } from "react"; import classnames from "classnames"; function Button({ children, disabled, className, ...props }) { return ( ); } export default function Table({ items, count, headers, actions, offset, setOffset, pageSize = 10 }) { useEffect(() => { if (offset < 0) setOffset(0); else if (offset >= count && count > 0) setOffset(Math.floor(count / pageSize - 1) * pageSize); else if (offset % pageSize) setOffset(offset - (offset % pageSize)); }, [offset, pageSize, setOffset]); return (
{headers.map(({ key, name }) => ( ))} {actions.map(({ key, name }) => ( ))} {items && items.length ? ( items.map((row, index) => ( {headers.map(({ key, formatter, href, nowrap = true }) => ( ))} {actions.map(({ key, name, action }) => ( ))} )) ) : ( )}
{name} {name}
{(formatter ? ( formatter(row, key) ) : href ? ( {row[key]} ) : ( row[key] )) || <>—} {name}
no entries
{/* This example requires Tailwind CSS v2.0+ */}
); }