You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
949 B

  1. import api from '../api';
  2. export const SUGGESTIONS_FETCH_REQUEST = 'SUGGESTIONS_FETCH_REQUEST';
  3. export const SUGGESTIONS_FETCH_SUCCESS = 'SUGGESTIONS_FETCH_SUCCESS';
  4. export const SUGGESTIONS_FETCH_FAIL = 'SUGGESTIONS_FETCH_FAIL';
  5. export function fetchSuggestions() {
  6. return (dispatch, getState) => {
  7. dispatch(fetchSuggestionsRequest());
  8. api(getState).get('/api/v1/accounts/suggestions').then(response => {
  9. dispatch(fetchSuggestionsSuccess(response.data));
  10. }).catch(error => {
  11. console.error(error);
  12. dispatch(fetchSuggestionsFail(error));
  13. });
  14. };
  15. };
  16. export function fetchSuggestionsRequest() {
  17. return {
  18. type: SUGGESTIONS_FETCH_REQUEST
  19. };
  20. };
  21. export function fetchSuggestionsSuccess(suggestions) {
  22. return {
  23. type: SUGGESTIONS_FETCH_SUCCESS,
  24. suggestions: suggestions
  25. };
  26. };
  27. export function fetchSuggestionsFail(error) {
  28. return {
  29. type: SUGGESTIONS_FETCH_FAIL,
  30. error: error
  31. };
  32. };