diff --git a/client/src/components/Accounts/AccountsDataTable.js b/client/src/components/Accounts/AccountsDataTable.js index 9b7ff3a07..6afe6fdba 100644 --- a/client/src/components/Accounts/AccountsDataTable.js +++ b/client/src/components/Accounts/AccountsDataTable.js @@ -6,6 +6,8 @@ import { MenuItem, MenuDivider, Position, + Classes, + Tooltip, } from '@blueprintjs/core'; import { useParams } from 'react-router-dom'; import Icon from 'components/Icon'; @@ -16,6 +18,7 @@ import DashboardConnect from 'connectors/Dashboard.connector'; import ViewConnect from 'connectors/View.connector'; import LoadingIndicator from 'components/LoadingIndicator'; import DataTable from 'components/DataTable'; +import Money from 'components/Money'; function AccountsDataTable({ accounts, @@ -45,9 +48,10 @@ function AccountsDataTable({ // Clear page subtitle when unmount the page. useEffect(() => () => { changePageSubtitle(''); }, []); - const handleEditAccount = account => () => { + const handleEditAccount = useCallback((account) => () => { openDialog('account-form', { action: 'edit', id: account.id }); - }; + }, [openDialog]); + const actionMenuList = account => ( @@ -64,20 +68,71 @@ function AccountsDataTable({ ); const columns = useMemo(() => [ + { + // Build our expander column + id: 'expander', // Make sure it has an ID + className: 'expander', + Header: ({ + getToggleAllRowsExpandedProps, + isAllRowsExpanded + }) => ( + + {isAllRowsExpanded ? + () : + () + } + + ), + Cell: ({ row }) => + // Use the row.canExpand and row.getToggleRowExpandedProps prop getter + // to build the toggle for expanding a row + row.canExpand ? ( + + {row.isExpanded ? + () : + () + } + + ) : null, + width: 20, + disableResizing: true, + }, { id: 'name', Header: 'Account Name', - accessor: 'name', + accessor: row => { + return (row.description) ? + ( + { row.name } + ) : row.name; + }, + className: 'account_name', }, { id: 'code', Header: 'Code', - accessor: 'code' + accessor: 'code', + className: 'code', }, { id: 'type', Header: 'Type', - accessor: 'type.name' + accessor: 'type.name', + className: 'type', }, { id: 'normal', @@ -96,14 +151,14 @@ function AccountsDataTable({ Header: 'Balance', Cell: ({ cell }) => { const account = cell.row.original; - const {balance} = account; + const {balance = null} = account; - return ('undefined' !== typeof balance) ? - ({ balance.amount }) : - (--); + return (balance) ? + ( + + ) : + (--); }, - - // canResize: false, }, { id: 'actions', @@ -111,18 +166,23 @@ function AccountsDataTable({ Cell: ({ cell }) => ( + position={Position.RIGHT_TOP}>