2022-02-04 20:54:55 -05:00
|
|
|
import { Grid } from 'gridjs-react';
|
2023-02-25 13:54:37 -05:00
|
|
|
import { h } from 'gridjs';
|
2022-02-04 20:54:55 -05:00
|
|
|
import './BudgetPeriodTransTable.scss';
|
|
|
|
|
import '../../node_modules/gridjs/dist/theme/mermaid.css'
|
|
|
|
|
|
2023-02-25 13:54:37 -05:00
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2022-02-04 20:54:55 -05:00
|
|
|
toCurrency = (amount) => { return '$' + (isBill === true ? '-' : '') + amount; },
|
2023-02-25 13:54:37 -05:00
|
|
|
tableData = transList.map(t => { return [t.description, toCurrency(t.amount), t]});
|
2022-02-04 20:54:55 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className='budget-period-trans-table'>
|
|
|
|
|
<div className="table-header">
|
|
|
|
|
<span className="table-title">{ title }</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className='table-container'>
|
|
|
|
|
<Grid data={tableData} columns={columns} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default BudgetPeriodTransTable;
|