2018-06-01 14:25:59 +00:00
|
|
|
import { createTypes, actionCreator } from 'redux-action-creator'
|
|
|
|
|
|
|
|
export const types = createTypes([
|
|
|
|
'RECEIVE_ACCOUNTS'
|
|
|
|
], 'ACCOUNTS')
|
|
|
|
export const actions = {
|
2018-06-01 16:45:11 +00:00
|
|
|
receiveAccounts: actionCreator(types.RECEIVE_ACCOUNTS, 'defaultAccount','accounts')
|
2018-06-01 14:25:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 16:45:11 +00:00
|
|
|
export default function(state = { loading: true, accounts: [] }, action) {
|
2018-06-01 14:25:59 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case types.RECEIVE_ACCOUNTS:
|
2018-06-01 16:45:11 +00:00
|
|
|
const { defaultAccount, accounts } = action.payload
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
loading: false,
|
|
|
|
defaultAccount,
|
|
|
|
accounts
|
|
|
|
}
|
2018-06-01 14:25:59 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-01 16:45:11 +00:00
|
|
|
export const getAccounts = state => state.accounts.accounts;
|
|
|
|
export const accountsIsLoading = state => state.accounts.loading;
|