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} />