Browse Source

Merge pull request #421 from NastiaS/polish

delete account in account settings
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
eb486a4468
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/components/modals/AccountSettingRenderBody.js
  2. 6
      src/reducers/accounts.js
  3. 1
      static/i18n/en/common.yml

15
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 type { T } from 'types/common'
import { MODAL_SETTINGS_ACCOUNT } from 'config/constants' import { MODAL_SETTINGS_ACCOUNT } from 'config/constants'
import { updateAccount } from 'actions/accounts' import { updateAccount, removeAccount } from 'actions/accounts'
import { setDataModal } from 'reducers/modals' import { setDataModal } from 'reducers/modals'
import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon' import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon'
@ -30,6 +30,7 @@ type State = {
type Props = { type Props = {
setDataModal: Function, setDataModal: Function,
updateAccount: Function, updateAccount: Function,
removeAccount: Function,
t: T, t: T,
onClose: () => void, onClose: () => void,
data: any, data: any,
@ -38,6 +39,7 @@ type Props = {
const mapDispatchToProps = { const mapDispatchToProps = {
setDataModal, setDataModal,
updateAccount, updateAccount,
removeAccount,
} }
const defaultState = { const defaultState = {
@ -104,6 +106,12 @@ class HelperComp extends PureComponent<Props, State> {
this.setState({ accountUnit: value }) this.setState({ accountUnit: value })
} }
handleRemoveAccount = (account: Account) => {
const { removeAccount } = this.props
removeAccount(account)
this.props.onClose()
}
render() { render() {
const { accountUnit, accountNameError } = this.state const { accountUnit, accountNameError } = this.state
const { t, onClose, data } = this.props const { t, onClose, data } = this.props
@ -149,7 +157,10 @@ class HelperComp extends PureComponent<Props, State> {
</Box> </Box>
</Container> </Container>
</ModalContent> </ModalContent>
<ModalFooter> <ModalFooter horizontal>
<Button small danger type="button" onClick={() => this.handleRemoveAccount(account)}>
{t('common:delete')}
</Button>
<Button small ml="auto" type="submit" primary> <Button small ml="auto" type="submit" primary>
{t('common:apply')} {t('common:apply')}
</Button> </Button>

6
src/reducers/accounts.js

@ -50,8 +50,10 @@ const handlers: Object = {
return orderAccountsOperations(updatedAccount) return orderAccountsOperations(updatedAccount)
}), }),
REMOVE_ACCOUNT: (state: AccountsState, { payload: account }: { payload: Account }) => REMOVE_ACCOUNT: (
state.filter(acc => acc.id !== account.id), state: AccountsState,
{ payload: account }: { payload: Account },
): AccountsState => state.filter(acc => acc.id !== account.id),
} }
// Selectors // Selectors

1
static/i18n/en/common.yml

@ -4,6 +4,7 @@ no: No
apply: Apply apply: Apply
confirm: Confirm confirm: Confirm
cancel: Cancel cancel: Cancel
delete: Delete
continue: Continue continue: Continue
chooseWalletPlaceholder: Choose a wallet... chooseWalletPlaceholder: Choose a wallet...
currency: Currency currency: Currency

Loading…
Cancel
Save