2021-02-04 19:15:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import * as actions from '../../../../store/actions';
|
|
|
|
import Identicon from '../../../ui/identicon';
|
|
|
|
import Button from '../../../ui/button';
|
2022-02-16 17:59:39 +01:00
|
|
|
import { DEFAULT_ROUTE } from '../../../../helpers/constants/routes';
|
2017-09-29 21:03:29 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2017-09-29 21:03:29 +02:00
|
|
|
return {
|
2018-06-05 01:13:32 +02:00
|
|
|
token: state.appState.modal.modalState.props.token,
|
2022-02-16 17:59:39 +01:00
|
|
|
history: state.appState.modal.modalState.props.history,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-09-29 21:03:29 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapDispatchToProps(dispatch) {
|
2017-10-03 19:25:52 +02:00
|
|
|
return {
|
|
|
|
hideModal: () => dispatch(actions.hideModal()),
|
2020-02-15 21:34:12 +01:00
|
|
|
hideToken: (address) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(actions.removeToken(address)).then(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(actions.hideModal());
|
|
|
|
});
|
2017-10-03 19:25:52 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-09-29 21:03:29 +02:00
|
|
|
}
|
|
|
|
|
2020-01-10 16:21:47 +01:00
|
|
|
class HideTokenConfirmationModal extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-03-29 17:00:44 +02:00
|
|
|
|
2020-01-10 16:21:47 +01:00
|
|
|
static propTypes = {
|
|
|
|
hideToken: PropTypes.func.isRequired,
|
|
|
|
hideModal: PropTypes.func.isRequired,
|
|
|
|
token: PropTypes.shape({
|
|
|
|
symbol: PropTypes.string,
|
|
|
|
address: PropTypes.string,
|
2021-09-10 19:37:19 +02:00
|
|
|
image: PropTypes.string,
|
2020-01-10 16:21:47 +01:00
|
|
|
}),
|
2022-02-16 17:59:39 +01:00
|
|
|
history: PropTypes.object,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-09-29 21:03:29 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
state = {};
|
2018-03-29 17:00:44 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2022-02-16 17:59:39 +01:00
|
|
|
const { token, hideToken, hideModal, history } = this.props;
|
2021-09-10 19:37:19 +02:00
|
|
|
const { symbol, address, image } = token;
|
2017-09-29 21:03:29 +02:00
|
|
|
|
2020-01-10 16:21:47 +01:00
|
|
|
return (
|
|
|
|
<div className="hide-token-confirmation">
|
|
|
|
<div className="hide-token-confirmation__container">
|
|
|
|
<div className="hide-token-confirmation__title">
|
|
|
|
{this.context.t('hideTokenPrompt')}
|
|
|
|
</div>
|
|
|
|
<Identicon
|
|
|
|
className="hide-token-confirmation__identicon"
|
|
|
|
diameter={45}
|
|
|
|
address={address}
|
|
|
|
image={image}
|
|
|
|
/>
|
|
|
|
<div className="hide-token-confirmation__symbol">{symbol}</div>
|
|
|
|
<div className="hide-token-confirmation__copy">
|
|
|
|
{this.context.t('readdToken')}
|
|
|
|
</div>
|
|
|
|
<div className="hide-token-confirmation__buttons">
|
2020-08-19 18:41:56 +02:00
|
|
|
<Button
|
2021-10-05 21:20:42 +02:00
|
|
|
type="secondary"
|
2020-08-19 18:41:56 +02:00
|
|
|
className="hide-token-confirmation__button"
|
2020-06-02 23:47:55 +02:00
|
|
|
data-testid="hide-token-confirmation__cancel"
|
2020-01-10 16:21:47 +01:00
|
|
|
onClick={() => hideModal()}
|
|
|
|
>
|
|
|
|
{this.context.t('cancel')}
|
2020-08-19 18:41:56 +02:00
|
|
|
</Button>
|
|
|
|
<Button
|
2021-10-05 21:20:42 +02:00
|
|
|
type="primary"
|
2020-08-19 18:41:56 +02:00
|
|
|
className="hide-token-confirmation__button"
|
2020-06-02 23:47:55 +02:00
|
|
|
data-testid="hide-token-confirmation__hide"
|
2022-02-16 17:59:39 +01:00
|
|
|
onClick={() => {
|
|
|
|
hideToken(address);
|
|
|
|
history.push(DEFAULT_ROUTE);
|
|
|
|
}}
|
2020-01-10 16:21:47 +01:00
|
|
|
>
|
|
|
|
{this.context.t('hide')}
|
2020-08-19 18:41:56 +02:00
|
|
|
</Button>
|
2020-01-10 16:21:47 +01:00
|
|
|
</div>
|
2019-11-24 23:01:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-10 16:21:47 +01:00
|
|
|
}
|
2017-09-29 21:03:29 +02:00
|
|
|
}
|
2020-01-10 16:21:47 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps,
|
2021-02-04 19:15:23 +01:00
|
|
|
)(HideTokenConfirmationModal);
|