1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 22:24:27 +01:00
metamask-extension/ui/components/app/modals/hide-token-confirmation-modal/hide-token-confirmation-modal.js

90 lines
2.5 KiB
JavaScript
Raw Normal View History

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';
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 {
token: state.appState.modal.modalState.props.token,
};
2017-09-29 21:03:29 +02:00
}
2020-11-03 00:41:28 +01:00
function mapDispatchToProps(dispatch) {
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(() => {
dispatch(actions.hideModal());
});
},
};
2017-09-29 21:03:29 +02:00
}
class HideTokenConfirmationModal extends Component {
static contextTypes = {
t: PropTypes.func,
};
static propTypes = {
hideToken: PropTypes.func.isRequired,
hideModal: PropTypes.func.isRequired,
token: PropTypes.shape({
symbol: PropTypes.string,
address: PropTypes.string,
image: PropTypes.string,
}),
};
2017-09-29 21:03:29 +02:00
state = {};
2020-11-03 00:41:28 +01:00
render() {
const { token, hideToken, hideModal } = this.props;
const { symbol, address, image } = token;
2017-09-29 21:03:29 +02: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">
<Button
type="secondary"
className="hide-token-confirmation__button"
data-testid="hide-token-confirmation__cancel"
onClick={() => hideModal()}
>
{this.context.t('cancel')}
</Button>
<Button
type="primary"
className="hide-token-confirmation__button"
data-testid="hide-token-confirmation__hide"
onClick={() => hideToken(address)}
>
{this.context.t('hide')}
</Button>
</div>
</div>
</div>
);
}
2017-09-29 21:03:29 +02:00
}
2020-11-03 00:41:28 +01:00
export default connect(
mapStateToProps,
mapDispatchToProps,
)(HideTokenConfirmationModal);