feat(wallet): Close buttons on send/address pages to go back to wallet

This commit is contained in:
hack.ily 2019-10-29 23:07:30 -07:00 committed by Sean Yesmunt
parent 35605fc2b3
commit 18ac6fd82d
4 changed files with 32 additions and 12 deletions

View file

@ -1,6 +1,7 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doCheckAddressIsMine, doGetNewAddress, selectReceiveAddress, selectGettingNewAddress } from 'lbry-redux'; import { doCheckAddressIsMine, doGetNewAddress, selectReceiveAddress, selectGettingNewAddress } from 'lbry-redux';
import WalletAddress from './view'; import WalletAddress from './view';
import { withRouter } from 'react-router';
const select = state => ({ const select = state => ({
receiveAddress: selectReceiveAddress(state), receiveAddress: selectReceiveAddress(state),
@ -12,7 +13,9 @@ const perform = dispatch => ({
getNewAddress: () => dispatch(doGetNewAddress()), getNewAddress: () => dispatch(doGetNewAddress()),
}); });
export default connect( export default withRouter(
select, connect(
perform select,
)(WalletAddress); perform
)(WalletAddress)
);

View file

@ -1,5 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { REMOVE } from 'constants/icons';
import Button from 'component/button'; import Button from 'component/button';
import CopyableText from 'component/copyableText'; import CopyableText from 'component/copyableText';
import QRCode from 'component/common/qr-code'; import QRCode from 'component/common/qr-code';
@ -10,6 +11,7 @@ type Props = {
receiveAddress: string, receiveAddress: string,
getNewAddress: () => void, getNewAddress: () => void,
gettingNewAddress: boolean, gettingNewAddress: boolean,
history: { goBack: () => void },
}; };
type State = { type State = {
@ -43,12 +45,17 @@ class WalletAddress extends React.PureComponent<Props, State> {
} }
render() { render() {
const { receiveAddress, getNewAddress, gettingNewAddress } = this.props; const { receiveAddress, getNewAddress, gettingNewAddress, history } = this.props;
const { showQR } = this.state; const { showQR } = this.state;
return ( return (
<Card <Card
title={__('Receive Credits')} title={
<React.Fragment>
{__('Receive Credits')}
<Button button="close" icon={REMOVE} onClick={() => history.goBack()} />
</React.Fragment>
}
subtitle={__('Use this address to receive LBC.')} subtitle={__('Use this address to receive LBC.')}
actions={ actions={
<React.Fragment> <React.Fragment>

View file

@ -2,6 +2,7 @@ import { connect } from 'react-redux';
import { selectBalance } from 'lbry-redux'; import { selectBalance } from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
import WalletSend from './view'; import WalletSend from './view';
import { withRouter } from 'react-router';
const perform = dispatch => ({ const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
@ -11,7 +12,9 @@ const select = state => ({
balance: selectBalance(state), balance: selectBalance(state),
}); });
export default connect( export default withRouter(
select, connect(
perform select,
)(WalletSend); perform
)(WalletSend)
);

View file

@ -1,5 +1,6 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types'; import * as MODALS from 'constants/modal_types';
import { REMOVE } from 'constants/icons';
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import { Form, FormField } from 'component/common/form'; import { Form, FormField } from 'component/common/form';
@ -15,6 +16,7 @@ type DraftTransaction = {
type Props = { type Props = {
openModal: (id: string, { address: string, amount: number }) => void, openModal: (id: string, { address: string, amount: number }) => void,
balance: number, balance: number,
history: { goBack: () => void },
}; };
class WalletSend extends React.PureComponent<Props> { class WalletSend extends React.PureComponent<Props> {
@ -34,11 +36,16 @@ class WalletSend extends React.PureComponent<Props> {
} }
render() { render() {
const { balance } = this.props; const { balance, history } = this.props;
return ( return (
<Card <Card
title={__('Send Credits')} title={
<React.Fragment>
{__('Send Credits')}
<Button button="close" icon={REMOVE} onClick={() => history.goBack()} />
</React.Fragment>
}
subtitle={__('Send LBC to your friends or favorite creators.')} subtitle={__('Send LBC to your friends or favorite creators.')}
actions={ actions={
<Formik <Formik