about summary refs log tree commit diff
path: root/app/assets/javascripts/components/actions
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/components/actions')
-rw-r--r--app/assets/javascripts/components/actions/suggestions.jsx26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/assets/javascripts/components/actions/suggestions.jsx b/app/assets/javascripts/components/actions/suggestions.jsx
index 562a901c5..c70a4d121 100644
--- a/app/assets/javascripts/components/actions/suggestions.jsx
+++ b/app/assets/javascripts/components/actions/suggestions.jsx
@@ -6,10 +6,32 @@ 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 => {
-      console.log(response.data);
+      dispatch(fetchSuggestionsSuccess(response.data));
     }).catch(error => {
-      console.error(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
+  };
+};