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

36 lines
951 B
JavaScript
Raw Normal View History

2018-06-14 16:49:28 +02:00
import {API_SERVER} from '../../config';
import HtmlClient from '../../helpers/HtmlClient';
import {
REQUEST_ORDERS,
RECEIVE_ORDERS
} from '../../constants/dashboardConstants';
const htmlClient = new HtmlClient();
export const requestOrders = () => ({
type: REQUEST_ORDERS,
isLoading: true
});
export const recieveOrders = (json) => ({
type: RECEIVE_ORDERS,
isLoading: false,
orders: json
});
export const fetchOrders = (viewAllOrders) => {
return dispatch => {
dispatch(requestOrders());
return htmlClient.fetch({
url: `${API_SERVER}/dashboards/api/getOrderCentralInfo`,
method: 'post',
data: {
viewAllOrders
}
})
.then(response => dispatch(recieveOrders(response.data)))
.catch(error => {
htmlClient.onError(error, dispatch);
});
}
}