WikiEducationFoundation/WikiEduDashboard

View on GitHub
app/assets/javascripts/actions/did_you_know_actions.js

Summary

Maintainability
A
1 hr
Test Coverage
B
80%
import { RECEIVE_DYK, SORT_DYK, API_FAIL } from '../constants';
import API from '../utils/api.js';

export const fetchDYKArticles = (opts = {}) => (dispatch) => {
  return (
    API.fetchDykArticles(opts)
      .then(resp =>
        dispatch({
          type: RECEIVE_DYK,
          payload: {
            data: resp,
          }
        }))
        .catch(response => (dispatch({ type: API_FAIL, data: response })))
  );
};

export const sortDYKArticles = key => ({ type: SORT_DYK, key: key });