From 0a21c5fa41740471408f51c06ef150fdd1776ce6 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Mon, 25 Oct 2021 17:31:07 +0200 Subject: [PATCH] feat: add view detail cash flow transaction. --- src/common/drawers.js | 1 + src/components/DrawersContainer.js | 2 + .../CashFlow/AccountDeleteTransactionAlert.js | 6 ++ .../AccountTransactionsDataTable.js | 47 ++++++++- .../AccountTransactionsDetailsBar.js | 3 +- .../AccountTransactions/components.js | 21 ++-- .../CashFlowAccounts/CashflowAccountsGrid.js | 11 ++- .../CashflowTransactionDrawerActionBar.js | 40 ++++++++ .../CashflowTransactionDrawerContent.js | 23 +++++ .../CashflowTransactionDrawerDetails.js | 25 +++++ .../CashflowTransactionDrawerFooter.js | 34 +++++++ .../CashflowTransactionDrawerHeader.js | 63 ++++++++++++ .../CashflowTransactionDrawerProvider.js | 50 ++++++++++ .../CashflowTransactionDrawerTable.js | 22 +++++ .../CashflowTransactionDetailDrawer/index.js | 35 +++++++ .../CashflowTransactionDetailDrawer/utils.js | 76 ++++++++++++++ src/hooks/query/cashflowAccounts.js | 16 +++ src/lang/en/index.json | 71 ++++++------- .../Drawers/CashflowTransactionDrawer.scss | 99 +++++++++++++++++++ 19 files changed, 600 insertions(+), 45 deletions(-) create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerActionBar.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerContent.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerDetails.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerFooter.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerHeader.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerProvider.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerTable.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/index.js create mode 100644 src/containers/Drawers/CashflowTransactionDetailDrawer/utils.js create mode 100644 src/style/components/Drawers/CashflowTransactionDrawer.scss diff --git a/src/common/drawers.js b/src/common/drawers.js index 4fb36ed80..449f51485 100644 --- a/src/common/drawers.js +++ b/src/common/drawers.js @@ -9,4 +9,5 @@ export const DRAWERS = { EXPENSE_DRAWER: 'expense-drawer', BILL_DRAWER: 'bill-drawer', INVENTORY_ADJUSTMENT_DRAWER: 'inventory-adjustment-drawer', + CASHFLOW_TRNASACTION_DRAWER: 'cashflow-transaction-drawer', }; diff --git a/src/components/DrawersContainer.js b/src/components/DrawersContainer.js index e35b17f1d..f240fd1bf 100644 --- a/src/components/DrawersContainer.js +++ b/src/components/DrawersContainer.js @@ -13,6 +13,7 @@ import ItemDetailDrawer from '../containers/Drawers/ItemDetailDrawer'; import CustomerDetailsDrawer from '../containers/Drawers/CustomerDetailsDrawer'; import VendorDetailsDrawer from '../containers/Drawers/VendorDetailsDrawer'; import InventoryAdjustmentDetailDrawer from '../containers/Drawers/InventoryAdjustmentDetailDrawer'; +import CashflowTransactionDetailDrawer from '../containers/Drawers/CashflowTransactionDetailDrawer'; import { DRAWERS } from 'common/drawers'; @@ -37,6 +38,7 @@ export default function DrawersContainer() { + ); } diff --git a/src/containers/Alerts/CashFlow/AccountDeleteTransactionAlert.js b/src/containers/Alerts/CashFlow/AccountDeleteTransactionAlert.js index da757392a..d24e9d591 100644 --- a/src/containers/Alerts/CashFlow/AccountDeleteTransactionAlert.js +++ b/src/containers/Alerts/CashFlow/AccountDeleteTransactionAlert.js @@ -7,6 +7,7 @@ import { useDeleteCashflowTransaction } from 'hooks/query'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { compose } from 'utils'; @@ -22,6 +23,9 @@ function AccountDeleteTransactionAlert({ // #withAlertActions closeAlert, + + // #withDrawerActions + closeDrawer, }) { const { mutateAsync: deleteTransactionMutate, isLoading } = useDeleteCashflowTransaction(); @@ -39,6 +43,7 @@ function AccountDeleteTransactionAlert({ message: intl.get('cash_flow_transaction.delete.alert_message'), intent: Intent.SUCCESS, }); + closeDrawer('cashflow-transaction-drawer'); }) .catch( ({ @@ -77,4 +82,5 @@ function AccountDeleteTransactionAlert({ export default compose( withAlertStoreConnect(), withAlertActions, + withDrawerActions, )(AccountDeleteTransactionAlert); diff --git a/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.js b/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.js index 7378a1a12..5d1e9b304 100644 --- a/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.js +++ b/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.js @@ -1,7 +1,7 @@ import React from 'react'; import styled from 'styled-components'; -import { DataTable, TableFastCell } from 'components'; +import { DataTable, TableFastCell, FormattedMessage as T } from 'components'; import { TABLES } from 'common/tables'; import TableVirtualizedListRows from 'components/Datatable/TableVirtualizedRows'; @@ -10,6 +10,7 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton'; import withSettings from '../../Settings/withSettings'; import withAlertsActions from 'containers/Alert/withAlertActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { useMemorizedColumnsWidths } from '../../../hooks'; import { useAccountTransactionsColumns, ActionsMenu } from './components'; @@ -25,6 +26,9 @@ function AccountTransactionsDataTable({ // #withAlertsActions openAlert, + + // #withDrawerActions + openDrawer, }) { // Retrieve table columns. const columns = useAccountTransactionsColumns(); @@ -42,6 +46,39 @@ function AccountTransactionsDataTable({ openAlert('account-transaction-delete', { referenceId: reference_id }); }; + const handleViewDetailCashflowTransaction = ({ + reference_id, + reference_type, + }) => { + switch (reference_type) { + case 'SaleReceipt': + return openDrawer('receipt-detail-drawer', { + receiptId: reference_id, + }); + case 'Journal': + return openDrawer('journal-drawer', { + manualJournalId: reference_id, + }); + case 'Expense': + return openDrawer('expense-drawer', { + expenseId: reference_id, + }); + case 'PaymentReceive': + return openDrawer('payment-receive-detail-drawer', { + paymentReceiveId: reference_id, + }); + case 'BillPayment': + return openDrawer('payment-made-detail-drawer', { + paymentMadeId: reference_id, + }); + + default: + return openDrawer('cashflow-transaction-drawer', { + referenceId: reference_id, + }); + } + }; + return ( } className="table-constrant" payload={{ + onViewDetails: handleViewDetailCashflowTransaction, onDelete: handleDeleteTransaction, }} /> @@ -79,6 +121,7 @@ export default compose( cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize, })), withAlertsActions, + withDrawerActions, )(AccountTransactionsDataTable); const DashboardConstrantTable = styled(DataTable)` diff --git a/src/containers/CashFlow/AccountTransactions/AccountTransactionsDetailsBar.js b/src/containers/CashFlow/AccountTransactions/AccountTransactionsDetailsBar.js index e72994af2..d01be1a15 100644 --- a/src/containers/CashFlow/AccountTransactions/AccountTransactionsDetailsBar.js +++ b/src/containers/CashFlow/AccountTransactions/AccountTransactionsDetailsBar.js @@ -1,4 +1,5 @@ import React from 'react'; +import intl from 'react-intl-universal'; import styled from 'styled-components'; import { Popover, @@ -61,7 +62,7 @@ function AccountBalanceItem() { return ( - Balance in Bigcapital{' '} + {intl.get('cash_flow_balance_in', { name: 'Bigcapital' })} {currentAccount.formatted_amount} diff --git a/src/containers/CashFlow/AccountTransactions/components.js b/src/containers/CashFlow/AccountTransactions/components.js index d4cded039..cb292468c 100644 --- a/src/containers/CashFlow/AccountTransactions/components.js +++ b/src/containers/CashFlow/AccountTransactions/components.js @@ -1,7 +1,7 @@ import React from 'react'; import intl from 'react-intl-universal'; -import { Intent, Menu, MenuItem } from '@blueprintjs/core'; +import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core'; import { MaterialProgressBar } from 'components'; import { FormatDateCell, If, Icon } from 'components'; @@ -9,18 +9,27 @@ import { useAccountTransactionsContext } from './AccountTransactionsProvider'; import { TRANSACRIONS_TYPE } from 'common/cashflowOptions'; import { safeCallback } from 'utils'; -export function ActionsMenu({ payload: { onDelete }, row: { original } }) { +export function ActionsMenu({ + payload: { onDelete, onViewDetails }, + row: { original }, +}) { return ( - - + + } + text={intl.get('view_details')} + onClick={safeCallback(onViewDetails, original)} + /> + + } /> - - + + ); } /** diff --git a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js index ea04d8e64..32898d54a 100644 --- a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js +++ b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js @@ -13,6 +13,7 @@ import { BankAccount, If, Icon, + T, } from '../../../components'; import AccountsAlerts from './../../Accounts/AccountsAlerts'; @@ -169,7 +170,11 @@ function CashflowAccountsEmptyState() { return ( - There is no cashflow accounts with current filter criteria. + ); @@ -248,14 +253,14 @@ function CashflowAccountContextMenu({ /> } icon={} > } icon={} > diff --git a/src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerActionBar.js b/src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerActionBar.js new file mode 100644 index 000000000..2099f063e --- /dev/null +++ b/src/containers/Drawers/CashflowTransactionDetailDrawer/CashflowTransactionDrawerActionBar.js @@ -0,0 +1,40 @@ +import React from 'react'; +import Icon from 'components/Icon'; +import { Button, Classes, NavbarGroup, Intent } from '@blueprintjs/core'; +import { FormattedMessage as T } from 'components'; + +import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; +import { useCashflowTransactionDrawerContext } from './CashflowTransactionDrawerProvider'; +import withAlertsActions from 'containers/Alert/withAlertActions'; + +import { compose } from 'utils'; + +/** + * Cashflow transaction drawer action bar. + */ +function CashflowTransactionDrawerActionBar({ + // #withAlertsDialog + openAlert, +}) { + const { referenceId } = useCashflowTransactionDrawerContext(); + + // Handle cashflow transaction delete action. + const handleDeleteCashflowTransaction = () => { + openAlert('account-transaction-delete', { referenceId }); + }; + + return ( + + +