From 95745dcc4fde21e3756edc50c98f8a2ddd8ea611 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Fri, 15 Sep 2017 15:34:19 -0500 Subject: [PATCH] fix(sendcoins): clear form after successful send and add helpful comments --- app/reducers/form.js | 1 - app/reducers/payment.js | 8 ++++++-- .../ModalRoot/SuccessfulSendCoins/SuccessfulSendCoins.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/reducers/form.js b/app/reducers/form.js index 8a7d9f6b..ba076291 100644 --- a/app/reducers/form.js +++ b/app/reducers/form.js @@ -101,7 +101,6 @@ formSelectors.isOnchain = createSelector( bitcoin.address.toOutputScript(paymentRequest, bitcoin.networks.testnet) return true } catch (e) { - console.log('e: ', e) return false } } diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 09b680ab..9c486d8a 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import { ipcRenderer } from 'electron' import { btc, usd } from '../utils' -import { setForm } from './form' +import { setForm, resetForm } from './form' import { showModal } from './modal' // ------------------------------------ @@ -79,9 +79,13 @@ export const paymentSuccessful = () => fetchPayments() export const sendSuccessful = (event, { amount, addr, txid }) => (dispatch) => { // Close the form modal once the payment was succesful dispatch(setForm({ modalOpen: false })) + // Show successful payment state dispatch(showModal('SUCCESSFUL_SEND_COINS', { txid, amount, addr })) // TODO: Add successful on-chain payment to payments list once payments list supports on-chain and LN // dispatch({ type: PAYMENT_SUCCESSFULL, payment: { amount, addr, txid, pending: true } }) + dispatch({ type: PAYMENT_SUCCESSFULL }) + // Reset the payment form + dispatch(resetForm()) } @@ -94,7 +98,7 @@ const ACTION_HANDLERS = { [SEND_PAYMENT]: state => ({ ...state, sendingPayment: true }), [RECEIVE_PAYMENTS]: (state, { payments }) => ({ ...state, paymentLoading: false, payments }), [PAYMENT_SUCCESSFULL]: (state, { payment }) => ( - { ...state, sendingPayment: false, payments: [payment, ...state.payments] } + { ...state, sendingPayment: false } ) } diff --git a/app/routes/app/components/components/ModalRoot/SuccessfulSendCoins/SuccessfulSendCoins.js b/app/routes/app/components/components/ModalRoot/SuccessfulSendCoins/SuccessfulSendCoins.js index 18119af3..bdccac84 100644 --- a/app/routes/app/components/components/ModalRoot/SuccessfulSendCoins/SuccessfulSendCoins.js +++ b/app/routes/app/components/components/ModalRoot/SuccessfulSendCoins/SuccessfulSendCoins.js @@ -26,7 +26,7 @@ const SuccessfulSendCoins = ({ amount, addr, txid, hideModal, currentTicker, cur } SuccessfulSendCoins.propTypes = { - amount: PropTypes.oneOf([ + amount: PropTypes.oneOfType([ PropTypes.number, PropTypes.string ]).isRequired,