From 04c7a7536ff9b44cc056756921dc216ab3d0d1e7 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 14 Aug 2018 23:02:44 +0200 Subject: [PATCH] use custom endpoints for customer acceptance --- .../orders/customerAcceptanceActions.js | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/frontend/src/actions/orders/customerAcceptanceActions.js b/frontend/src/actions/orders/customerAcceptanceActions.js index 59f5cf7..9f1365f 100644 --- a/frontend/src/actions/orders/customerAcceptanceActions.js +++ b/frontend/src/actions/orders/customerAcceptanceActions.js @@ -23,15 +23,12 @@ const recieveCustomerAcceptance = (json) => ({ customerAcceptance: json }); -export const fetchCustomerAcceptance = (idOrder) => { +export const fetchCustomerAcceptance = (idEntry) => { return dispatch => { dispatch(requestCustomerAcceptance()); return htmlClient.fetch({ - url: `${API_SERVER}/orders/api/getCustomerAcceptance`, - method: 'post', - data: { - idOrder - } + url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`, + method: 'get' }) .then(response => { if (response.data) { @@ -48,18 +45,15 @@ const uploadAcceptanceAction = () => ({ type: UPLOAD_CUSTOMER_ACCEPTANCE }); -export const uploadAcceptance = (idOrder, file) => { +export const uploadAcceptance = (idEntry, file) => { return dispatch => { dispatch(uploadAcceptanceAction()); return htmlClient.uploadFile(file, { - url: `${API_SERVER}/orders/api/uploadAcceptanceDocument`, - data: { - idOrder - } + url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}/upload-file` }).then(response => { - if (typeof response.data !== 'undefined' && 'messages' in response.data) { - dispatch(updateMessages(response.data.messages, orderMessages)); - dispatch(fetchCustomerAcceptance(idOrder)); + if (typeof response.data !== 'undefined') { + //dispatch(updateMessages(response.data.messages, orderMessages)); + dispatch(fetchCustomerAcceptance(idEntry)); } }).catch(error => { htmlClient.onError(error, dispatch); @@ -77,14 +71,13 @@ const sendCustomerAcceptance = () => ({ type: SEND_CUSTOMER_ACCEPTANCE }); -export const acceptDeclineInstallation = (idOrder, actionType, declineReason) => { +export const acceptDeclineInstallation = (idEntry, actionType, declineReason) => { return dispatch => { dispatch(sendCustomerAcceptance()); return htmlClient.fetch({ - url: `${API_SERVER}/orders/api/acceptDeclineInstallation`, + url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`, method: 'post', data: { - idOrder, actionType, declineReason } @@ -92,7 +85,7 @@ export const acceptDeclineInstallation = (idOrder, actionType, declineReason) => .then(response => { if (response.data) { dispatch(updateMessages(response.data.messages, orderMessages)); - dispatch(fetchCustomerAcceptance(idOrder)); + dispatch(fetchCustomerAcceptance(idEntry)); } }) .catch(error => {