diff --git a/app/reducers/activity.js b/app/reducers/activity.js new file mode 100644 index 00000000..e1af749c --- /dev/null +++ b/app/reducers/activity.js @@ -0,0 +1,50 @@ +// ------------------------------------ +// Initial State +// ------------------------------------ +const initialState = { + filter: 'ALL_ACTIVITY', + modal: { + modalType: null, + modalProps: {} + } +} + +// ------------------------------------ +// Constants +// ------------------------------------ +export const SHOW_ACTIVITY_MODAL = 'SHOW_ACTIVITY_MODAL' +export const HIDE_ACTIVITY_MODAL = 'HIDE_ACTIVITY_MODAL' + +// ------------------------------------ +// Actions +// ------------------------------------ +export function showActivityModal(modalType, modalProps) { + return { + type: SHOW_ACTIVITY_MODAL, + modalType, + modalProps + } +} + +export function hideActivityModal() { + return { + type: HIDE_ACTIVITY_MODAL + } +} + +// ------------------------------------ +// Action Handlers +// ------------------------------------ +const ACTION_HANDLERS = { + [SHOW_ACTIVITY_MODAL]: (state, { modalType, modalProps }) => ({ ...state, modal: { modalType, modalProps } }), + [HIDE_ACTIVITY_MODAL]: (state) => ({ ...state, modal: { modalType: null, modalProps: {} } }) +} + +// ------------------------------------ +// Reducer +// ------------------------------------ +export default function activityReducer(state = initialState, action) { + const handler = ACTION_HANDLERS[action.type] + + return handler ? handler(state, action) : state +} diff --git a/app/reducers/index.js b/app/reducers/index.js index 75b0597e..4c906733 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -12,6 +12,7 @@ import invoice from './invoice' import modal from './modal' import address from './address' import transaction from './transaction' +import activity from './activity' const rootReducer = combineReducers({ router, @@ -25,7 +26,8 @@ const rootReducer = combineReducers({ invoice, modal, address, - transaction + transaction, + activity }) export default rootReducer diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 3ff58af9..11602edc 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -9,6 +9,8 @@ import Invoice from './components/Invoice' import Payment from './components/Payment' import Transaction from './components/Transaction' +import Modal from './components/Modal' + import styles from './Activity.scss' class Activity extends Component { @@ -30,18 +32,17 @@ class Activity extends Component { } renderActivity(activity) { - const { ticker, currentTicker } = this.props + const { ticker, currentTicker, showActivityModal } = this.props if (activity.hasOwnProperty('block_hash')) { // activity is an on-chain tx - return + return } else if (activity.hasOwnProperty('payment_request')) { // activity is an LN invoice - console.log('activity: ', activity) - return + return } else { // activity is an LN payment - return + return } } @@ -58,11 +59,17 @@ class Activity extends Component { paymentModalOpen, invoiceModalOpen, currentTicker, - sortedActivity + sortedActivity, + activity: { modal }, + hideActivityModal } = this.props + if (invoiceLoading || paymentLoading) { return
Loading...
} + return (
+ +