about summary refs log tree commit diff
path: root/app/assets/javascripts/components/actions/suggestions.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/components/actions/suggestions.jsx')
-rw-r--r--app/assets/javascripts/components/actions/suggestions.jsx37
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
+  };
+};