Browse Source

feature(request global error): hook up back end global errors for request form

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
e80dd91880
  1. 20
      app/components/GlobalError/GlobalError.js
  2. 5
      app/lnd/methods/index.js
  3. 12
      app/reducers/invoice.js
  4. 3
      app/reducers/ipc.js

20
app/components/GlobalError/GlobalError.js

@ -3,19 +3,17 @@ import PropTypes from 'prop-types'
import { MdClose } from 'react-icons/lib/md'
import styles from './GlobalError.scss'
const GlobalError = ({ error, clearError }) => {
console.log('error: ', error)
return (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
</div>
<h2>{error}</h2>
const GlobalError = ({ error, clearError }) => (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
</div>
<h2>{error}</h2>
</div>
)
}
</div>
)
GlobalError.propTypes = {

5
app/lnd/methods/index.js

@ -105,7 +105,10 @@ export default function (lnd, event, msg, data) {
})
)
)
.catch(error => console.log('addInvoice error: ', error))
.catch(error => {
console.log('addInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() })
})
break
case 'sendPayment':
// Payment looks like { payment_preimage: Buffer, payment_route: Object }

12
app/reducers/invoice.js

@ -5,6 +5,7 @@ import { fetchBalance } from './balance'
import { setFormType } from './form'
import { setPayInvoice } from './payform'
import { resetRequestForm } from './requestform'
import { setError } from './error'
import { showNotification } from '../notifications'
import { btc, usd } from '../utils'
@ -71,12 +72,6 @@ export function sendInvoice() {
}
}
export function invoiceFailed() {
return {
type: INVOICE_FAILED
}
}
// Send IPC event for a specific invoice
export const fetchInvoice = payreq => (dispatch) => {
dispatch(getInvoice())
@ -117,6 +112,11 @@ export const createdInvoice = (event, invoice) => (dispatch) => {
dispatch(resetRequestForm())
}
export const invoiceFailed = (event, { error }) => dispatch => {
dispatch({ type: INVOICE_FAILED })
dispatch(setError(error))
}
// Listen for invoice updates pushed from backend from subscribeToInvoices
export const invoiceUpdate = (event, { invoice }) => (dispatch) => {
dispatch({ type: UPDATE_INVOICE, invoice })

3
app/reducers/ipc.js

@ -22,7 +22,7 @@ import {
} from './channels'
import { lightningPaymentUri } from './payform'
import { receivePayments, paymentSuccessful, paymentFailed } from './payment'
import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice'
import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate, invoiceFailed } from './invoice'
import { receiveBalance } from './balance'
import {
receiveTransactions,
@ -48,6 +48,7 @@ const ipc = createIpc({
receiveInvoices,
receiveInvoice: receiveFormInvoice,
createdInvoice,
invoiceFailed,
invoiceUpdate,
receiveBalance,

Loading…
Cancel
Save