Browse Source

temp confirmation added when deleting account for dev purposes

master
Anastasia Poupeney 7 years ago
parent
commit
d5836106bd
  1. 31
      src/components/modals/AccountSettingRenderBody.js
  2. 4
      static/i18n/en/settings.yml

31
src/components/modals/AccountSettingRenderBody.js

@ -20,12 +20,19 @@ import Box from 'components/base/Box'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Select from 'components/base/LegacySelect' import Select from 'components/base/LegacySelect'
import { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal' import {
ModalBody,
ModalTitle,
ModalFooter,
ModalContent,
ConfirmModal,
} from 'components/base/Modal'
type State = { type State = {
accountName: string | null, accountName: string | null,
accountUnit: Unit | null, accountUnit: Unit | null,
accountNameError: boolean, accountNameError: boolean,
isRemoveAccountModalOpen: boolean,
} }
type Props = { type Props = {
@ -47,6 +54,7 @@ const defaultState = {
accountName: null, accountName: null,
accountUnit: null, accountUnit: null,
accountNameError: false, accountNameError: false,
isRemoveAccountModalOpen: false,
} }
class HelperComp extends PureComponent<Props, State> { class HelperComp extends PureComponent<Props, State> {
@ -106,15 +114,18 @@ class HelperComp extends PureComponent<Props, State> {
handleChangeUnit = (value: Unit) => { handleChangeUnit = (value: Unit) => {
this.setState({ accountUnit: value }) this.setState({ accountUnit: value })
} }
handleOpenRemoveAccountModal = () => this.setState({ isRemoveAccountModalOpen: true })
handleCloseRemoveAccountModal = () => this.setState({ isRemoveAccountModalOpen: false })
handleRemoveAccount = (account: Account) => { handleRemoveAccount = (account: Account) => {
const { removeAccount } = this.props const { removeAccount, onClose } = this.props
removeAccount(account) removeAccount(account)
this.props.onClose() this.setState({ isRemoveAccountModalOpen: false })
onClose()
} }
render() { render() {
const { accountUnit, accountNameError } = this.state const { accountUnit, accountNameError, isRemoveAccountModalOpen } = this.state
const { t, onClose, data } = this.props const { t, onClose, data } = this.props
const account = this.getAccount(data) const account = this.getAccount(data)
@ -183,7 +194,7 @@ class HelperComp extends PureComponent<Props, State> {
</Spoiler> </Spoiler>
</ModalContent> </ModalContent>
<ModalFooter horizontal> <ModalFooter horizontal>
<Button small danger type="button" onClick={() => this.handleRemoveAccount(account)}> <Button small danger type="button" onClick={this.handleOpenRemoveAccountModal}>
{t('common:delete')} {t('common:delete')}
</Button> </Button>
<Button small ml="auto" type="submit" primary> <Button small ml="auto" type="submit" primary>
@ -191,6 +202,16 @@ class HelperComp extends PureComponent<Props, State> {
</Button> </Button>
</ModalFooter> </ModalFooter>
</form> </form>
<ConfirmModal
isDanger
isOpened={isRemoveAccountModalOpen}
onClose={this.handleCloseRemoveAccountModal}
onReject={this.handleCloseRemoveAccountModal}
onConfirm={() => this.handleRemoveAccount(account)}
title={t('settings:removeAccountModal.title')}
subTitle={t('settings:removeAccountModal.subTitle')}
desc={t('settings:removeAccountModal.desc')}
/>
</ModalBody> </ModalBody>
) )
} }

4
static/i18n/en/settings.yml

@ -57,6 +57,10 @@ softResetModal:
title: Clean application cache title: Clean application cache
subTitle: Are you sure houston? subTitle: Are you sure houston?
desc: Lorem ipsum dolor sit amet desc: Lorem ipsum dolor sit amet
removeAccountModal:
title: Delete this account
subTitle: Are you sure houston?
desc: Lorem ipsum dolor sit amet
exportLogs: exportLogs:
title: Export Logs title: Export Logs
desc: Export Logs desc: Export Logs

Loading…
Cancel
Save