From 5f598d89199fad39bd0745e7db437972dda83878 Mon Sep 17 00:00:00 2001 From: Anastasia Poupeney Date: Thu, 31 May 2018 14:32:46 +0200 Subject: [PATCH 1/2] delete account in account settings --- src/components/modals/AccountSettingRenderBody.js | 14 ++++++++++++-- src/reducers/accounts.js | 6 ++++-- static/i18n/en/common.yml | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/modals/AccountSettingRenderBody.js b/src/components/modals/AccountSettingRenderBody.js index e43ca02d..990af9bb 100644 --- a/src/components/modals/AccountSettingRenderBody.js +++ b/src/components/modals/AccountSettingRenderBody.js @@ -11,7 +11,7 @@ import type { Account, Unit, Currency } from '@ledgerhq/live-common/lib/types' import type { T } from 'types/common' import { MODAL_SETTINGS_ACCOUNT } from 'config/constants' -import { updateAccount } from 'actions/accounts' +import { updateAccount, removeAccount } from 'actions/accounts' import { setDataModal } from 'reducers/modals' import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon' @@ -30,6 +30,7 @@ type State = { type Props = { setDataModal: Function, updateAccount: Function, + removeAccount: Function, t: T, onClose: () => void, data: any, @@ -38,6 +39,7 @@ type Props = { const mapDispatchToProps = { setDataModal, updateAccount, + removeAccount, } const defaultState = { @@ -104,6 +106,11 @@ class HelperComp extends PureComponent { this.setState({ accountUnit: value }) } + handleRemoveAccount = (account: Account) => { + const { removeAccount } = this.props + removeAccount(account) + } + render() { const { accountUnit, accountNameError } = this.state const { t, onClose, data } = this.props @@ -149,7 +156,10 @@ class HelperComp extends PureComponent { - + + diff --git a/src/reducers/accounts.js b/src/reducers/accounts.js index 40847073..afc3f706 100644 --- a/src/reducers/accounts.js +++ b/src/reducers/accounts.js @@ -50,8 +50,10 @@ const handlers: Object = { return orderAccountsOperations(updatedAccount) }), - REMOVE_ACCOUNT: (state: AccountsState, { payload: account }: { payload: Account }) => - state.filter(acc => acc.id !== account.id), + REMOVE_ACCOUNT: ( + state: AccountsState, + { payload: account }: { payload: Account }, + ): AccountsState => state.filter(acc => acc.id !== account.id), } // Selectors diff --git a/static/i18n/en/common.yml b/static/i18n/en/common.yml index d158d1fe..a84460d5 100644 --- a/static/i18n/en/common.yml +++ b/static/i18n/en/common.yml @@ -4,6 +4,7 @@ no: No apply: Apply confirm: Confirm cancel: Cancel +delete: Delete continue: Continue chooseWalletPlaceholder: Choose a wallet... currency: Currency From 64c92230e3a814ab325d0f246156ef99de789fd6 Mon Sep 17 00:00:00 2001 From: Anastasia Poupeney Date: Thu, 31 May 2018 14:53:02 +0200 Subject: [PATCH 2/2] small addition --- src/components/modals/AccountSettingRenderBody.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/modals/AccountSettingRenderBody.js b/src/components/modals/AccountSettingRenderBody.js index 990af9bb..f4d6c7df 100644 --- a/src/components/modals/AccountSettingRenderBody.js +++ b/src/components/modals/AccountSettingRenderBody.js @@ -109,6 +109,7 @@ class HelperComp extends PureComponent { handleRemoveAccount = (account: Account) => { const { removeAccount } = this.props removeAccount(account) + this.props.onClose() } render() { @@ -157,7 +158,7 @@ class HelperComp extends PureComponent { -