Browse Source

fix(invoice): fix bug after fetching invoice to prevent forever loading

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
c076d7bca3
  1. 4
      app/components/Form/Form.js
  2. 16
      app/components/Form/PayForm.js
  3. 9
      app/reducers/invoice.js
  4. 2
      app/reducers/payform.js
  5. 6
      app/routes/app/containers/AppContainer.js

4
app/components/Form/Form.js

@ -34,7 +34,9 @@ const Form = ({ formType, formProps, closeForm }) => {
Form.propTypes = {
formType: PropTypes.string,
formProps: PropTypes.object.isRequired,
closeForm: PropTypes.func.isRequired
}
export default Form

16
app/components/Form/PayForm.js

@ -106,7 +106,23 @@ class PayForm extends Component {
PayForm.propTypes = {
payform: PropTypes.object.isRequired,
currency: PropTypes.string.isRequired,
crypto: PropTypes.string.isRequired,
isOnchain: PropTypes.bool.isRequired,
isLn: PropTypes.bool.isRequired,
currentAmount: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]).isRequired,
inputCaption: PropTypes.string.isRequired,
showPayLoadingScreen: PropTypes.bool.isRequired,
setPayAmount: PropTypes.func.isRequired,
setPayInput: PropTypes.func.isRequired,
onPaySubmit: PropTypes.func.isRequired
}
export default PayForm

9
app/reducers/invoice.js

@ -83,7 +83,10 @@ export const fetchInvoice = payreq => (dispatch) => {
}
// Receive IPC event for form invoice
export const receiveFormInvoice = (event, invoice) => dispatch => dispatch(setPayInvoice(invoice))
export const receiveFormInvoice = (event, invoice) => dispatch => {
dispatch(setPayInvoice(invoice))
dispatch({ type: RECEIVE_FORM_INVOICE })
}
// Send IPC event for invoices
export const fetchInvoices = () => (dispatch) => {
@ -133,9 +136,7 @@ const ACTION_HANDLERS = {
[GET_INVOICE]: state => ({ ...state, invoiceLoading: true }),
[RECEIVE_INVOICE]: (state, { invoice }) => ({ ...state, invoiceLoading: false, invoice }),
[RECEIVE_FORM_INVOICE]: (state, { formInvoice }) => (
{ ...state, invoiceLoading: false, formInvoice }
),
[RECEIVE_FORM_INVOICE]: state => ({ ...state, invoiceLoading: false }),
[GET_INVOICES]: state => ({ ...state, invoiceLoading: true }),
[RECEIVE_INVOICES]: (state, { invoices }) => ({ ...state, invoiceLoading: false, invoices }),

2
app/reducers/payform.js

@ -121,7 +121,7 @@ payFormSelectors.inputCaption = createSelector(
payAmountSelector,
currencySelector,
(isOnchain, isLn, amount, currency) => {
if (!isOnchain && !isLn) { return }
if (!isOnchain && !isLn) { return '' }
if (isOnchain) {
return `You're about to send ${amount} ${currency.toUpperCase()} on-chain which should take around 10 minutes`

6
app/routes/app/containers/AppContainer.js

@ -128,15 +128,15 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
...dispatchProps,
...ownProps,
// Props to pass to the pay form
formProps: formProps(stateProps.form.formType),
// action to open the pay form
openPayForm: () => dispatchProps.setFormType('PAY_FORM'),
// action to open the request form
openRequestForm: () => dispatchProps.setFormType('REQUEST_FORM'),
// action to close form
closeForm: () => dispatchProps.setFormType(null),
closeForm: () => dispatchProps.setFormType(null)
// Props to pass to the pay form
formProps: formProps(stateProps.form.formType)
}
}

Loading…
Cancel
Save