change endpoints for order details, comments and documents

This commit is contained in:
GotPPay
2018-08-14 23:31:12 +02:00
parent 04c7a7536f
commit 8b5374ee24

View File

@@ -24,7 +24,9 @@ import {
SET_SCHEDULING_DISABLED_FLAG
} from '../../constants/ordersConstants';
import HtmlClient from '../../helpers/HtmlClient';
import {updateMessages} from '../notification/notificationActions';
import { updateMessages } from '../notification/notificationActions';
import { fromWCOrder } from '../../helpers/OrderHelper';
import moment from 'moment';
const htmlClient = new HtmlClient();
@@ -42,15 +44,12 @@ export const fetchOrderInfo = (idOrder) => {
return dispatch => {
dispatch(requestOrderInfo());
return htmlClient.fetch({
url: `${API_SERVER}/orders/api/getOrderInfo`,
method: 'post',
data: {
idOrder
}
})
url: `${API_SERVER}/wp-json/wc/v2/orders/${idOrder}`,
method: 'get'
})
.then(response => {
if (response.data) {
dispatch(recieveOrderInfo(response.data));
dispatch(recieveOrderInfo(fromWCOrder(response.data)));
}
})
.catch(error => {
@@ -66,19 +65,34 @@ const sendComment = () => ({
export const addComment = (idOrder, comment) => {
return dispatch => {
dispatch(sendComment());
//TODO: get real user name and store in comment object
return htmlClient.fetch({
url: `${API_SERVER}/orders/api/addOrderComment`,
method: 'post',
data: {
idOrder,
comment
}
})
url: `${API_SERVER}/wp-json/wc/v2/orders/${idOrder}`,
method: 'post',
data: {
meta_data: [
{
key: `comment-${moment().unix()}`,
value: {
comment: comment,
addDate: moment().format("Do MMM, YY"),
username: 'username',
isOwner: 1
}
}
]
}
})
.then(response => {
if (response.data) {
dispatch(fetchOrderInfo(idOrder));
}
/*
if (response.data && response.data.messages) {
dispatch(updateMessages(response.data.messages, orderMessages));
dispatch(fetchOrderInfo(idOrder));
}
*/
})
.catch(error => {
htmlClient.onError(error, dispatch);