From 5e72178adb8c40f130ba4224ad1204ed3dd1439b Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 14 Sep 2017 15:03:28 -0500 Subject: [PATCH] feature(sendcoins): use formSelectors to determine whether a user is using LN or onchain --- app/reducers/form.js | 21 ++++ app/routes/app/components/App.js | 6 ++ .../app/components/components/Form/Form.js | 11 ++- .../components/Form/components/Pay/Pay.js | 96 +++++++++---------- .../components/Form/components/Pay/Pay.scss | 3 +- app/routes/app/containers/AppContainer.js | 7 +- 6 files changed, 88 insertions(+), 56 deletions(-) diff --git a/app/reducers/form.js b/app/reducers/form.js index 34b1c0d2..879ddcc9 100644 --- a/app/reducers/form.js +++ b/app/reducers/form.js @@ -1,3 +1,5 @@ +import { createSelector } from 'reselect' + // Initial State const initialState = { modalOpen: false, @@ -94,6 +96,25 @@ const ACTION_HANDLERS = { [RESET_FORM]: () => (initialState) } +// ------------------------------------ +// Selector +// ------------------------------------ +const formSelectors = {} +const paymentRequestSelector = state => state.form.payment_request +const paymentTypeSelector = state => state.form.paymentType + +formSelectors.isOnchain = createSelector( + paymentRequestSelector, + paymentRequest => paymentRequest.length === 42 +) + +formSelectors.isLn = createSelector( + paymentRequestSelector, + paymentRequest => paymentRequest.length === 124 +) + +export { formSelectors } + // ------------------------------------ // Reducer // ------------------------------------ diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 5bd0741c..bc6c4823 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -33,6 +33,8 @@ class App extends Component { payInvoice, fetchInvoice, currentTicker, + isOnchain, + isLn, children } = this.props @@ -58,6 +60,8 @@ class App extends Component { fetchInvoice={fetchInvoice} formInvoice={formInvoice} currentTicker={currentTicker} + isOnchain={isOnchain} + isLn={isLn} />