Skip to content

Commit

Permalink
setting: primary wallet cannot be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
rithvikvibhu committed Feb 6, 2022
1 parent f852bfb commit d0cb06b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
66 changes: 42 additions & 24 deletions app/pages/Settings/InterstitialWarningModal.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import MiniModal from '../../components/Modal/MiniModal';
import './interstitial-warning-modal.scss';
import PropTypes from 'prop-types';
import Checkbox from '../../components/Checkbox';
import {I18nContext} from "../../utils/i18n";

@withRouter
@connect(
(state) => ({
wid: state.wallet.wid,
})
)
export default class InterstitialWarningModal extends Component {
static propTypes = {
nextRoute: PropTypes.string.isRequired,
nextAction: PropTypes.func,
wid: PropTypes.string.isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -48,7 +55,7 @@ export default class InterstitialWarningModal extends Component {
};

onClickCancel = () => {
this.props.history.push('/settings');
this.props.history.push('/settings/wallet');
};

onClickSubmit = async () => {
Expand All @@ -58,20 +65,46 @@ export default class InterstitialWarningModal extends Component {

render() {
const {t} = this.context;
const isPrimary = this.props.wid === 'primary';

return (
<MiniModal
closeRoute="/settings/wallet"
title={t('removeWalletTitle')}
>
<div className="interstitial-warning-modal__instructions">
{t('removeWalletInstruction')}
{isPrimary ? t('removeWalletNoPrimary') : t('removeWalletInstruction')}
</div>
<div className="interstitial-warning-modal__checkbox">
{isPrimary ? null : this.renderCheckboxes(this.state.acceptances)}
<div className="interstitial-warning-modal__buttons">
<button
className="interstitial-warning-modal__cancel-button"
onClick={this.onClickCancel}
>
{t('removeWalletCancel')}
</button>
<button
className="interstitial-warning-modal__submit-button"
disabled={isPrimary || this.checkDisabled()}
onClick={this.onClickSubmit}
>
{t('removeWalletCTA')}
</button>
</div>
</MiniModal>
);
}

renderCheckboxes(acceptances) {
const {t} = this.context;

return (
<>
<div className="interstitial-warning-modal__checkbox">
<Checkbox
className="interstitial-warning-modal__checkbox-box"
onChange={this.toggleCheck(0)}
checked={this.state.acceptances[0]}
checked={acceptances[0]}
/>
<div className="interstitial-warning-modal__checkbox-label">
{t('removeWalletAck1')}
Expand All @@ -81,7 +114,7 @@ export default class InterstitialWarningModal extends Component {
<Checkbox
className="interstitial-warning-modal__checkbox-box"
onChange={this.toggleCheck(1)}
checked={this.state.acceptances[1]}
checked={acceptances[1]}
/>
<div className="interstitial-warning-modal__checkbox-label">
{t('removeWalletAck2')}
Expand All @@ -91,7 +124,7 @@ export default class InterstitialWarningModal extends Component {
<Checkbox
className="interstitial-warning-modal__checkbox-box"
onChange={this.toggleCheck(2)}
checked={this.state.acceptances[2]}
checked={acceptances[2]}
/>
<div className="interstitial-warning-modal__checkbox-label">
{t('removeWalletAck3')}
Expand All @@ -101,28 +134,13 @@ export default class InterstitialWarningModal extends Component {
<Checkbox
className="interstitial-warning-modal__checkbox-box"
onChange={this.toggleCheck(3)}
checked={this.state.acceptances[3]}
checked={acceptances[3]}
/>
<div className="interstitial-warning-modal__checkbox-label">
{t('removeWalletAck4')}
</div>
</div>
<div className="interstitial-warning-modal__buttons">
<button
className="interstitial-warning-modal__cancel-button"
onClick={this.onClickCancel}
>
{t('removeWalletCancel')}
</button>
<button
className="interstitial-warning-modal__submit-button"
disabled={this.checkDisabled()}
onClick={this.onClickSubmit}
>
{t('removeWalletCTA')}
</button>
</div>
</MiniModal>
);
</>
)
}
}
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
"removeWalletCTA": "Yes, remove wallet",
"removeWalletCancel": "Cancel, keep wallet",
"removeWalletInstruction": "You are about to remove your current wallet from Bob. Be sure you have your current recovery seed phrase saved somewhere safe before proceeding.",
"removeWalletNoPrimary": "Primary wallet cannot be removed.",
"removeWalletTitle": "Are you sure you want to do this?",
"renew": "Renew",
"renewBy": "Renew By",
Expand Down

0 comments on commit d0cb06b

Please sign in to comment.