From 5b62410afa50f3c87575082352b7f07f4aca9957 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Tue, 27 Apr 2021 15:58:37 +0200 Subject: [PATCH] feat: account drawer. --- .../containers/Accounts/AccountsDataTable.js | 25 ++++-- client/src/containers/Accounts/components.js | 1 + .../AccountDrawer/AccountDrawerActionBar.js | 85 +++++++++++++++++++ .../AccountDrawer/AccountDrawerContent.js | 17 ++++ .../AccountDrawer/AccountDrawerDetails.js | 23 +++++ .../AccountDrawer/AccountDrawerHeader.js | 61 +++++++++++++ .../AccountDrawer/AccountDrawerProvider.js | 40 +++++++++ .../AccountDrawer/AccountDrawerTable.js | 60 +++++++++++++ .../containers/Drawers/AccountDrawer/index.js | 35 ++++++++ client/src/hooks/query/accounts.js | 16 ++++ client/src/hooks/query/types.js | 3 +- .../components/Drawer/AccountDrawer.scss | 79 +++++++++++++++++ server/src/api/controllers/Accounts.ts | 2 +- .../src/services/Accounts/AccountsService.ts | 2 +- 14 files changed, 437 insertions(+), 12 deletions(-) create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerContent.js create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerDetails.js create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerHeader.js create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerProvider.js create mode 100644 client/src/containers/Drawers/AccountDrawer/AccountDrawerTable.js create mode 100644 client/src/containers/Drawers/AccountDrawer/index.js create mode 100644 client/src/style/components/Drawer/AccountDrawer.scss diff --git a/client/src/containers/Accounts/AccountsDataTable.js b/client/src/containers/Accounts/AccountsDataTable.js index c89eba307..4e5e7b983 100644 --- a/client/src/containers/Accounts/AccountsDataTable.js +++ b/client/src/containers/Accounts/AccountsDataTable.js @@ -13,6 +13,7 @@ import { useAccountsChartContext } from './AccountsChartProvider'; import withAlertsActions from 'containers/Alert/withAlertActions'; import withDialogActions from 'containers/Dialog/withDialogActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; /** * Accounts data-table. @@ -23,6 +24,9 @@ function AccountsDataTable({ // #withDial openDialog, + + // #withDrawerActions + openDrawer, }) { const { isAccountsLoading, @@ -59,6 +63,11 @@ function AccountsDataTable({ openDialog('account-form', { action: 'edit', id: account.id }); }; + // Handle view detail account. + const handleViewDetailAccount = ({ id, name, code }) => { + openDrawer('account-drawer', { accountId: id, title: `${name} ${code}` }); + }; + // Handle new child button click. const handleNewChildAccount = (account) => { openDialog('account-form', { @@ -76,40 +85,38 @@ function AccountsDataTable({ selectionColumn={true} expandable={true} sticky={true} - loading={isAccountsLoading} headerLoading={isAccountsLoading} progressBarLoading={isAccountsFetching} - rowClassNames={rowClassNames} - autoResetExpanded={false} autoResetSortBy={false} autoResetSelectedRows={false} - expandColumnSpace={1} expandToggleColumn={2} selectionColumnWidth={50} - TableCellRenderer={TableFastCell} TableRowsRenderer={TableVirtualizedListRows} TableLoadingRenderer={TableSkeletonRows} TableHeaderSkeletonRenderer={TableSkeletonHeader} ContextMenu={ActionsMenu} - // #TableVirtualizedListRows props. vListrowHeight={42} vListOverscanRowCount={0} - payload={{ onEdit: handleEditAccount, onDelete: handleDeleteAccount, onActivate: handleActivateAccount, onInactivate: handleInactivateAccount, - onNewChild: handleNewChildAccount + onNewChild: handleNewChildAccount, + onViewDetails: handleViewDetailAccount, }} /> ); } -export default compose(withAlertsActions, withDialogActions)(AccountsDataTable); +export default compose( + withAlertsActions, + withDrawerActions, + withDialogActions, +)(AccountsDataTable); diff --git a/client/src/containers/Accounts/components.js b/client/src/containers/Accounts/components.js index 28d5e541a..741293354 100644 --- a/client/src/containers/Accounts/components.js +++ b/client/src/containers/Accounts/components.js @@ -27,6 +27,7 @@ export function ActionsMenu({ onNewChild, onActivate, onInactivate, + // onDrawer, }, }) { return ( diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js new file mode 100644 index 000000000..7df7f3ade --- /dev/null +++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js @@ -0,0 +1,85 @@ +import React from 'react'; +import Icon from 'components/Icon'; +import { Button, Classes, NavbarGroup, Intent } from '@blueprintjs/core'; +import { FormattedMessage as T } from 'react-intl'; + +import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; +import withDialogActions from 'containers/Dialog/withDialogActions'; +import withAlertsActions from 'containers/Alert/withAlertActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; + +import { safeCallback } from 'utils'; + +import { compose } from 'utils'; + +/** + * Account drawer action bar. + */ +function AccountDrawerActionBar({ + // #withDialog + openDialog, + + // #withAlertsDialog + openAlert, + + // #withDrawerActions + closeDrawer, + + // #ownProps + account, +}) { + + + // Handle new child button click. + const onNewChildAccount = () => { + openDialog('account-form', { + action: 'new_child', + parentAccountId: account.id, + accountType: account.account_type, + }); + }; + + // Handle edit account action. + const onEditAccount = () => { + openDialog('account-form', { action: 'edit', id: account.id }); + }; + + // Handle delete action account. + const onDeleteAccount = () => { + if (account) { + openAlert('account-delete', { accountId: account.id }); + closeDrawer('account-drawer'); + } + }; + + return ( + + +