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