diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-30 15:06:43 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-30 15:06:43 +0100 |
commit | e8ff4c8e56650bf061c63a7da3d84b742e618b6a (patch) | |
tree | cb9aa48393bc6108655db7490434ae29d3145ee5 /app/assets/javascripts/components/actions/accounts.jsx | |
parent | 7060bdf04bde59aab9addce95f00d6e1075a62ba (diff) |
Refactoring redux state into different reducers
Diffstat (limited to 'app/assets/javascripts/components/actions/accounts.jsx')
-rw-r--r-- | app/assets/javascripts/components/actions/accounts.jsx | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/app/assets/javascripts/components/actions/accounts.jsx b/app/assets/javascripts/components/actions/accounts.jsx index 224562199..fdfd204a1 100644 --- a/app/assets/javascripts/components/actions/accounts.jsx +++ b/app/assets/javascripts/components/actions/accounts.jsx @@ -1,5 +1,4 @@ import api from '../api' -import axios from 'axios'; import Immutable from 'immutable'; export const ACCOUNT_SET_SELF = 'ACCOUNT_SET_SELF'; @@ -53,12 +52,11 @@ export function setAccountSelf(account) { export function fetchAccount(id) { return (dispatch, getState) => { - const boundApi = api(getState); - dispatch(fetchAccountRequest(id)); - axios.all([boundApi.get(`/api/v1/accounts/${id}`), boundApi.get(`/api/v1/accounts/relationships?id=${id}`)]).then(values => { - dispatch(fetchAccountSuccess(values[0].data, values[1].data[0])); + api(getState).get(`/api/v1/accounts/${id}`).then(response => { + dispatch(fetchAccountSuccess(response.data)); + dispatch(fetchRelationships([id])); }).catch(error => { dispatch(fetchAccountFail(id, error)); }); @@ -107,11 +105,10 @@ export function fetchAccountRequest(id) { }; }; -export function fetchAccountSuccess(account, relationship) { +export function fetchAccountSuccess(account) { return { type: ACCOUNT_FETCH_SUCCESS, - account: account, - relationship: relationship + account: account }; }; |