Files
old-new-wiaas/frontend/src/actions/dashboard/nextActionsActions.js

30 lines
861 B
JavaScript
Raw Normal View History

2018-06-14 16:49:28 +02:00
import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants';
2018-08-02 14:32:15 +02:00
import { API_SERVER } from '../../config';
import HtmlClient from '../../helpers/HtmlClient';
const client = new HtmlClient();
2018-06-14 16:49:28 +02:00
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({
2018-10-31 10:23:59 +01:00
url: `${API_SERVER}/wp-json/wiaas/delivery/next-actions`
2018-06-14 16:49:28 +02:00
})
.then(response => dispatch(recieveNextActions(response.data)))
.catch(error => {
client.onError(error, dispatch);
2018-08-02 14:32:15 +02:00
});
2018-06-14 16:49:28 +02:00
}
}