diff --git a/client/src/components/AccountsMultiSelect.js b/client/src/components/AccountsMultiSelect.js index b32833f56..d9e24c7e5 100644 --- a/client/src/components/AccountsMultiSelect.js +++ b/client/src/components/AccountsMultiSelect.js @@ -1,67 +1,76 @@ -import React, {useMemo, useCallback, useState} from 'react'; -import {omit} from 'lodash'; -import { - MenuItem, - Button -} from '@blueprintjs/core'; +import React, { useMemo, useCallback, useState } from 'react'; +import { omit } from 'lodash'; +import { MenuItem, Button } from '@blueprintjs/core'; import MultiSelect from 'components/MultiSelect'; import { FormattedMessage as T } from 'react-intl'; -export default function AccountsMultiSelect({ - accounts, - onAccountSelected, -}) { - const [selectedAccounts, setSelectedAccounts] = useState({}); +export default function AccountsMultiSelect({ accounts, onAccountSelected }) { + const [selectedAccounts, setSelectedAccounts] = useState({}); - const isAccountSelect = useCallback((accountId) => { - return 'undefined' !== typeof selectedAccounts[accountId]; - }, [selectedAccounts]); + const isAccountSelect = useCallback( + (accountId) => { + return 'undefined' !== typeof selectedAccounts[accountId]; + }, + [selectedAccounts], + ); // Account item of select accounts field. - const accountItem = useCallback((item, { handleClick, modifiers, query }) => { - return ( - - ); - }, [isAccountSelect]); + const accountItem = useCallback( + (item, { handleClick, modifiers, query }) => { + return ( + + ); + }, + [isAccountSelect], + ); - const countSelectedAccounts = useMemo(() => - Object.values(selectedAccounts).length, - [selectedAccounts]); + const countSelectedAccounts = useMemo( + () => Object.values(selectedAccounts).length, + [selectedAccounts], + ); - const onAccountSelect = useCallback((account) => { - const selected = { - ...(!isAccountSelect(account.id)) ? { - ...selectedAccounts, - [account.id]: true, - } : { - ...omit(selectedAccounts, [account.id]) - } - }; - setSelectedAccounts({ ...selected }); - onAccountSelected && onAccountSelected(selected); - }, [setSelectedAccounts, selectedAccounts, isAccountSelect, onAccountSelected]); + const onAccountSelect = useCallback( + (account) => { + const selected = { + ...(!isAccountSelect(account.id) + ? { + ...selectedAccounts, + [account.id]: true, + } + : { + ...omit(selectedAccounts, [account.id]), + }), + }; + setSelectedAccounts({ ...selected }); + onAccountSelected && onAccountSelected(selected); + }, + [setSelectedAccounts, selectedAccounts, isAccountSelect, onAccountSelected], + ); return ( } + noResults={} itemRenderer={accountItem} popoverProps={{ minimal: true }} filterable={true} onItemSelect={onAccountSelect} > ); -} \ No newline at end of file +} + +export default compose( + withProfitLoss(({ profitLossSheetFilter }) => ({ profitLossSheetFilter })), +)(ProfitLossHeader); diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js index 8fe8aff53..9aee1d7f6 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js @@ -19,6 +19,7 @@ export default (mapState) => { profitLossTableRows: getFinancialSheetTableRows(state.financialStatements.profitLoss.sheets, profitLossIndex), profitLossSheetLoading: state.financialStatements.profitLoss.loading, + profitLossSheetFilter: state.financialStatements.profitLoss.filter, }; return mapState ? mapState(mapped, state, props) : mapped; }; diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js index 962eb971d..ec08bf6c0 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js @@ -5,6 +5,7 @@ import { export const mapDispatchToProps = (dispatch) => ({ fetchProfitLossSheet: (query = {}) => dispatch(fetchProfitLossSheet({ query })), + toggleProfitLossSheetFilter: () => dispatch({ type: 'PROFIT_LOSS_FILTER_TOGGLE' }), }); export default connect(null, mapDispatchToProps); \ No newline at end of file diff --git a/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js b/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js index 6e88ac1ed..7e546fa0d 100644 --- a/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js +++ b/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js @@ -1,46 +1,77 @@ import React from 'react'; -import { - NavbarGroup, - Button, - Classes, - NavbarDivider, -} from '@blueprintjs/core'; +import { NavbarGroup, Button, Classes, NavbarDivider } from '@blueprintjs/core'; import Icon from 'components/Icon'; import { FormattedMessage as T } from 'react-intl'; -import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar' +import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import classNames from 'classnames'; // import FilterDropdown from 'components/FilterDropdown'; -export default function GeneralLedgerActionsBar() { - - // const filterDropdown = FilterDropdown({ - // fields: [], - // onFilterChange: (filterConditions) => { - - // }, - // }); +import { If } from 'components'; + +import withTrialBalance from './withTrialBalance'; +import withTrialBalanceActions from './withTrialBalanceActions'; +import { compose } from 'utils'; + + +function TrialBalanceActionsBar({ + + // #withTrialBalance + trialBalanceSheetFilter, + + // #withTrialBalanceActions + toggleTrialBalanceFilter, +}) { + + const handleFilterToggleClick = () => { + toggleTrialBalanceFilter(); + }; return (