diff --git a/src/components/modals/SettingsAccount.js b/src/components/modals/SettingsAccount.js index dee06452..1874e301 100644 --- a/src/components/modals/SettingsAccount.js +++ b/src/components/modals/SettingsAccount.js @@ -7,9 +7,11 @@ import { push } from 'react-router-redux' import { MODAL_SETTINGS_ACCOUNT } from 'constants' +import type { MapStateToProps } from 'react-redux' import type { Account } from 'types/common' -import { updateAccount, removeAccount } from 'actions/accounts' +import { updateOrderAccounts, updateAccount, removeAccount } from 'actions/accounts' +import { getOrderAccounts } from 'reducers/settings' import { setDataModal, closeModal } from 'reducers/modals' import Box from 'components/base/Box' @@ -27,18 +29,25 @@ type State = { type Props = { closeModal: Function, - updateAccount: Function, + orderAccounts: string, + push: Function, removeAccount: Function, setDataModal: Function, - push: Function, + updateAccount: Function, + updateOrderAccounts: Function, } +const mapStateToProps: MapStateToProps<*, *, *> = state => ({ + orderAccounts: getOrderAccounts(state), +}) + const mapDispatchToProps = { closeModal, - updateAccount, + push, removeAccount, setDataModal, - push, + updateAccount, + updateOrderAccounts, } const defaultState = { @@ -101,6 +110,7 @@ class SettingsAccount extends PureComponent { updateAccount(account) setDataModal(MODAL_SETTINGS_ACCOUNT, { account }) + this.updateOrderAccounts() this.setState({ editName: false, @@ -117,8 +127,8 @@ class SettingsAccount extends PureComponent { updateAccount({ ...account, archived: true }) } + this.updateOrderAccounts() closeModal(MODAL_SETTINGS_ACCOUNT) - push('/') } @@ -127,6 +137,12 @@ class SettingsAccount extends PureComponent { ...defaultState, }) + updateOrderAccounts() { + const { updateOrderAccounts, orderAccounts } = this.props + + updateOrderAccounts(orderAccounts) + } + render() { const { editName, nameHovered } = this.state @@ -195,4 +211,4 @@ class SettingsAccount extends PureComponent { } } -export default connect(null, mapDispatchToProps)(SettingsAccount) +export default connect(mapStateToProps, mapDispatchToProps)(SettingsAccount) diff --git a/src/reducers/settings.js b/src/reducers/settings.js index 06f3a0f8..196fc07c 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -29,5 +29,6 @@ const handlers: Object = { export const hasPassword = (state: Object) => get(state.settings, 'password.state', false) export const getLanguage = (state: Object) => get(state.settings, 'language', 'en') +export const getOrderAccounts = (state: Object) => get(state.settings, 'orderAccounts', 'balance') export default handleActions(handlers, state)