import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants'; import { API_SERVER } from '../../config'; import HtmlClient from '../../helpers/HtmlClient'; const client = new HtmlClient(); export const requestNextActions = () => ({ type: REQUEST_NEXT_ACTIONS, isLoading: true }); export const recieveNextActions = (json) => ({ type: RECIEVE_NEXT_ACTIONS, isLoading: false, nextActions: json }); export const fetchNextActions = () => { return dispatch => { dispatch(requestNextActions()); return client.fetch({ url: `${API_SERVER}/wp-json/wiaas/delivery/next-actions` }) .then(response => dispatch(recieveNextActions(response.data))) .catch(error => { client.onError(error, dispatch); }); } }