diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-15 12:38:28 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-15 12:38:28 +0200 |
commit | 70ab6624f5f397ddd05136db2fa37c902f0867eb (patch) | |
tree | 72407fd4b5368d3e8cdfd4c85ae928a654d8d261 /app/assets/javascripts/components/actions | |
parent | 91144d46ecc1a6e2d39abe8bea2d62c5cb57aca3 (diff) | |
parent | 4d336ceface783c255e62220cfa76812630ff1a1 (diff) |
Merge branch 'feature-suggestions' into development
Diffstat (limited to 'app/assets/javascripts/components/actions')
-rw-r--r-- | app/assets/javascripts/components/actions/suggestions.jsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/actions/suggestions.jsx b/app/assets/javascripts/components/actions/suggestions.jsx new file mode 100644 index 000000000..c70a4d121 --- /dev/null +++ b/app/assets/javascripts/components/actions/suggestions.jsx @@ -0,0 +1,37 @@ +import api from '../api'; + +export const SUGGESTIONS_FETCH_REQUEST = 'SUGGESTIONS_FETCH_REQUEST'; +export const SUGGESTIONS_FETCH_SUCCESS = 'SUGGESTIONS_FETCH_SUCCESS'; +export const SUGGESTIONS_FETCH_FAIL = 'SUGGESTIONS_FETCH_FAIL'; + +export function fetchSuggestions() { + return (dispatch, getState) => { + dispatch(fetchSuggestionsRequest()); + + api(getState).get('/api/v1/accounts/suggestions').then(response => { + dispatch(fetchSuggestionsSuccess(response.data)); + }).catch(error => { + dispatch(fetchSuggestionsFail(error)); + }); + }; +}; + +export function fetchSuggestionsRequest() { + return { + type: SUGGESTIONS_FETCH_REQUEST + }; +}; + +export function fetchSuggestionsSuccess(suggestions) { + return { + type: SUGGESTIONS_FETCH_SUCCESS, + suggestions: suggestions + }; +}; + +export function fetchSuggestionsFail(error) { + return { + type: SUGGESTIONS_FETCH_FAIL, + error: error + }; +}; |