Handle additional orders info for wiaas
This commit is contained in:
@@ -7,13 +7,14 @@ import {
|
||||
RECEIVE_HISTORY_ORDERS,
|
||||
SET_VIEW_ALL_ORDERS
|
||||
} from '../../constants/ordersConstants';
|
||||
import {fromWCOrder} from '../../helpers/OrderHelper';
|
||||
const htmlClient = new HtmlClient();
|
||||
|
||||
const requestActiveOrders = () => ({
|
||||
type: REQUEST_ACTIVE_ORDERS,
|
||||
isLoading: true
|
||||
});
|
||||
const recieveActiveOrders = (json) => ({
|
||||
const receiveActiveOrders = (json) => ({
|
||||
type: RECEIVE_ACTIVE_ORDERS,
|
||||
isLoading: false,
|
||||
activeOrders: json
|
||||
@@ -23,10 +24,10 @@ export const getActiveOrders = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestActiveOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?status=processing`
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?wiaas_is_active=1`
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(recieveActiveOrders(response.data));
|
||||
dispatch(receiveActiveOrders(response.data.map(wcOrder => fromWCOrder(wcOrder))));
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
@@ -48,10 +49,10 @@ export const getHistoryOrders = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestHistoryOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?status=completed`
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?wiaas_is_active=0`
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(recieveHistoryOrders(response.data));
|
||||
dispatch(recieveHistoryOrders(response.data.map(wcOrder => fromWCOrder(wcOrder))));
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
|
||||
Reference in New Issue
Block a user