create adapter for orders object and use it to accomodate for displaying
This commit is contained in:
@@ -4,7 +4,9 @@ import {
|
||||
REQUEST_ORDERS,
|
||||
RECEIVE_ORDERS
|
||||
} from '../../constants/dashboardConstants';
|
||||
import SaburlyAdapter from '../../helpers/SaburlyAdapter';
|
||||
const htmlClient = new HtmlClient();
|
||||
const saburlyAdapter = new SaburlyAdapter();
|
||||
|
||||
export const requestOrders = () => ({
|
||||
type: REQUEST_ORDERS,
|
||||
@@ -21,13 +23,13 @@ export const fetchOrders = (viewAllOrders) => {
|
||||
return dispatch => {
|
||||
dispatch(requestOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/dashboards/api/getOrderCentralInfo`,
|
||||
method: 'post',
|
||||
data: {
|
||||
viewAllOrders
|
||||
}
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
const transformedOrdersArray = saburlyAdapter.transformOrdersArray(response.data);
|
||||
dispatch(recieveOrders(transformedOrdersArray));
|
||||
})
|
||||
.then(response => dispatch(recieveOrders(response.data)))
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user