import { Grid } from 'gridjs-react'; import { h } from 'gridjs'; import './BudgetPeriodTransTable.scss'; import '../../node_modules/gridjs/dist/theme/mermaid.css' const BudgetPeriodTransTable = ({title, transList, isBill, actionHandler}) => { const columns = [ 'Description', 'Amount', { name: 'Actions', formatter: (cell, row) => { return h('button', { className: 'py-2 mb-4 px-4 border rounded-md text-white bg-blue-600', onClick: () => actionHandler(row) }, row.cells[2].data.paid ? 'Unpay' : 'Pay'); } } ], toCurrency = (amount) => { return '$' + (isBill === true ? '-' : '') + amount; }, tableData = transList.map(t => { return [t.description, toCurrency(t.amount), t]}); return (
{ title }
); }; export default BudgetPeriodTransTable;