Jack Mallers
7 years ago
4 changed files with 35 additions and 3 deletions
@ -0,0 +1,22 @@ |
|||
import { createSelector } from 'reselect' |
|||
|
|||
const activitySelectors = {} |
|||
const paymentsSelector = state => state.payment.payments |
|||
const invoicesSelector = state => state.invoice.invoices |
|||
const transactionsSelector = state => state.transaction.transactions |
|||
|
|||
activitySelectors.sortedActivity = createSelector( |
|||
paymentsSelector, |
|||
invoicesSelector, |
|||
transactionsSelector, |
|||
(payments, invoices, transactions) => { |
|||
return [...payments, ...invoices, ...transactions].sort((a, b) => { |
|||
let aTimestamp = a.hasOwnProperty('time_stamp') ? a.time_stamp : a.creation_date |
|||
let bTimestamp = b.hasOwnProperty('time_stamp') ? b.time_stamp : b.creation_date |
|||
|
|||
return bTimestamp - aTimestamp |
|||
}) |
|||
} |
|||
) |
|||
|
|||
export default activitySelectors |
@ -0,0 +1,5 @@ |
|||
import activitySelectors from './activity' |
|||
|
|||
export default { |
|||
activitySelectors |
|||
} |
Loading…
Reference in new issue