diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-13 02:24:40 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-13 02:24:40 +0200 |
commit | 2e7aac793ace0e938e45cb54ff601afa5d872214 (patch) | |
tree | 5c45c25a21ef9b1068604b8c459e1855ba91f239 /app/assets/javascripts/components/actions | |
parent | d6a64f45fd4530cfee4f7721f0c6e7ca28fe677f (diff) |
Adding sense of self to the UI, cleaning up routing, adding third (detail) column
Diffstat (limited to 'app/assets/javascripts/components/actions')
-rw-r--r-- | app/assets/javascripts/components/actions/accounts.jsx | 48 | ||||
-rw-r--r-- | app/assets/javascripts/components/actions/statuses.jsx | 6 |
2 files changed, 54 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/actions/accounts.jsx b/app/assets/javascripts/components/actions/accounts.jsx new file mode 100644 index 000000000..a334e3c20 --- /dev/null +++ b/app/assets/javascripts/components/actions/accounts.jsx @@ -0,0 +1,48 @@ +import api from '../api' + +export const ACCOUNT_SET_SELF = 'ACCOUNT_SET_SELF'; +export const ACCOUNT_FETCH = 'ACCOUNT_FETCH'; +export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST'; +export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS'; +export const ACCOUNT_FETCH_FAIL = 'ACCOUNT_FETCH_FAIL'; + +export function setAccountSelf(account) { + return { + type: ACCOUNT_SET_SELF, + account: account + }; +}; + +export function fetchAccount(id) { + return (dispatch, getState) => { + dispatch(fetchAccountRequest(id)); + + api(getState).get(`/api/accounts/${id}`).then(response => { + dispatch(fetchAccountSuccess(response.data)); + }).catch(error => { + dispatch(fetchAccountFail(id, error)); + }); + }; +}; + +export function fetchAccountRequest(id) { + return { + type: ACCOUNT_FETCH_REQUEST, + id: id + }; +}; + +export function fetchAccountSuccess(account) { + return { + type: ACCOUNT_FETCH_SUCCESS, + account: account + }; +}; + +export function fetchAccountFail(id, error) { + return { + type: ACCOUNT_FETCH_FAIL, + id: id, + error: error + }; +}; diff --git a/app/assets/javascripts/components/actions/statuses.jsx b/app/assets/javascripts/components/actions/statuses.jsx new file mode 100644 index 000000000..faf33ea1d --- /dev/null +++ b/app/assets/javascripts/components/actions/statuses.jsx @@ -0,0 +1,6 @@ +import api from '../api'; + +export const STATUS_FETCH = 'STATUS_FETCH'; +export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST'; +export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS'; +export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; |