Browse Source

create components for each type of activity / fix modal not closing on successful payment

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
0a04874e52
  1. 11
      app/reducers/payment.js
  2. 41
      app/routes/activity/components/Activity.js
  3. 15
      app/routes/activity/components/components/Invoice/Invoice.js
  4. 0
      app/routes/activity/components/components/Invoice/Invoice.scss
  5. 3
      app/routes/activity/components/components/Invoice/index.js
  6. 15
      app/routes/activity/components/components/Payment/Payment.js
  7. 0
      app/routes/activity/components/components/Payment/Payment.scss
  8. 3
      app/routes/activity/components/components/Payment/index.js
  9. 15
      app/routes/activity/components/components/Transaction/Transaction.js
  10. 0
      app/routes/activity/components/components/Transaction/Transaction.scss
  11. 3
      app/routes/activity/components/components/Transaction/index.js
  12. 1
      app/routes/activity/containers/ActivityContainer.js
  13. 5
      app/routes/app/components/components/Form/components/Pay/Pay.js

11
app/reducers/payment.js

@ -68,7 +68,16 @@ export const payInvoice = paymentRequest => (dispatch) => {
// Receive IPC event for successful payment // Receive IPC event for successful payment
// TODO: Add payment to state, not a total re-fetch // TODO: Add payment to state, not a total re-fetch
export const paymentSuccessful = () => fetchPayments() export const paymentSuccessful = () => dispatch => {
// Close the form modal once the payment was succesful
dispatch(setForm({ modalOpen: false }))
// Refetch payments (TODO: dont do a full refetch, rather append new tx to list)
fetchPayments()
// Reset the payment form
dispatch(resetForm())
}
// ------------------------------------ // ------------------------------------

41
app/routes/activity/components/Activity.js

@ -1,8 +1,14 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { MdSearch } from 'react-icons/lib/md' import { MdSearch } from 'react-icons/lib/md'
import { FaChain, FaBolt } from 'react-icons/lib/fa'
import Payments from './components/Payments' import Payments from './components/Payments'
import Invoices from './components/Invoices' import Invoices from './components/Invoices'
import Invoice from './components/Invoice'
import Payment from './components/Payment'
import Transaction from './components/Transaction'
import styles from './Activity.scss' import styles from './Activity.scss'
class Activity extends Component { class Activity extends Component {
@ -36,7 +42,6 @@ class Activity extends Component {
currentTicker, currentTicker,
sortedActivity sortedActivity
} = this.props } = this.props
console.log('sortedActivity: ', sortedActivity)
if (invoiceLoading || paymentLoading) { return <div>Loading...</div> } if (invoiceLoading || paymentLoading) { return <div>Loading...</div> }
return ( return (
<div> <div>
@ -69,28 +74,22 @@ class Activity extends Component {
Requests Requests
</span> </span>
</header> </header>
<div className={styles.activityContainer}> <ul className={styles.activityContainer}>
{ {
tab === 1 ? sortedActivity.map((activity, index) => {
<Payments if (activity.hasOwnProperty('block_hash')) {
payment={payment} // activity is an on-chain tx
payments={payments} return <Transaction transaction={activity} key={index} />
ticker={ticker} } else if (activity.hasOwnProperty('payment_request')) {
setPayment={setPayment} // activity is an LN invoice
paymentModalOpen={paymentModalOpen} return <Invoice invoice={activity} key={index} />
currentTicker={currentTicker} } else {
/> // activity is an LN payment
: return <Payment payment={activity} key={index} />
<Invoices
invoice={invoice}
invoices={invoices}
ticker={ticker}
setInvoice={setInvoice}
invoiceModalOpen={invoiceModalOpen}
currentTicker={currentTicker}
/>
} }
</div> })
}
</ul>
</div> </div>
</div> </div>
) )

15
app/routes/activity/components/components/Invoice/Invoice.js

@ -0,0 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './Invoice.scss'
const Invoice = () => (
<div>
Invoice
</div>
)
Invoice.propTypes = {
}
export default Invoice

0
app/routes/activity/components/components/Invoice/Invoice.scss

3
app/routes/activity/components/components/Invoice/index.js

@ -0,0 +1,3 @@
import Invoice from './Invoice'
export default Invoice

15
app/routes/activity/components/components/Payment/Payment.js

@ -0,0 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './Payment.scss'
const Payment = () => (
<div>
Payment
</div>
)
Payment.propTypes = {
}
export default Payment

0
app/routes/activity/components/components/Payment/Payment.scss

3
app/routes/activity/components/components/Payment/index.js

@ -0,0 +1,3 @@
import Payment from './Payment'
export default Payment

15
app/routes/activity/components/components/Transaction/Transaction.js

@ -0,0 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './Transaction.scss'
const Transaction = () => (
<div>
transaction
</div>
)
Transaction.propTypes = {
}
export default Transaction

0
app/routes/activity/components/components/Transaction/Transaction.scss

3
app/routes/activity/components/components/Transaction/index.js

@ -0,0 +1,3 @@
import Transaction from './Transaction'
export default Transaction

1
app/routes/activity/containers/ActivityContainer.js

@ -24,7 +24,6 @@ const mapDispatchToProps = {
searchInvoices searchInvoices
} }
console.log('activitySelectors: ', activitySelectors)
const mapStateToProps = state => ({ const mapStateToProps = state => ({
activity: state.activity, activity: state.activity,

5
app/routes/app/components/components/Form/components/Pay/Pay.js

@ -128,7 +128,10 @@ class Pay extends Component {
Pay.propTypes = { Pay.propTypes = {
sendingTransaction: PropTypes.bool.isRequired, sendingTransaction: PropTypes.bool.isRequired,
invoiceAmount: PropTypes.string.isRequired, invoiceAmount: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]).isRequired,
onchainAmount: PropTypes.string.isRequired, onchainAmount: PropTypes.string.isRequired,
setOnchainAmount: PropTypes.func.isRequired, setOnchainAmount: PropTypes.func.isRequired,
payment_request: PropTypes.string.isRequired, payment_request: PropTypes.string.isRequired,

Loading…
Cancel
Save