use custom endpoints for customer acceptance
This commit is contained in:
@@ -23,15 +23,12 @@ const recieveCustomerAcceptance = (json) => ({
|
|||||||
customerAcceptance: json
|
customerAcceptance: json
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchCustomerAcceptance = (idOrder) => {
|
export const fetchCustomerAcceptance = (idEntry) => {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(requestCustomerAcceptance());
|
dispatch(requestCustomerAcceptance());
|
||||||
return htmlClient.fetch({
|
return htmlClient.fetch({
|
||||||
url: `${API_SERVER}/orders/api/getCustomerAcceptance`,
|
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
|
||||||
method: 'post',
|
method: 'get'
|
||||||
data: {
|
|
||||||
idOrder
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
@@ -48,18 +45,15 @@ const uploadAcceptanceAction = () => ({
|
|||||||
type: UPLOAD_CUSTOMER_ACCEPTANCE
|
type: UPLOAD_CUSTOMER_ACCEPTANCE
|
||||||
});
|
});
|
||||||
|
|
||||||
export const uploadAcceptance = (idOrder, file) => {
|
export const uploadAcceptance = (idEntry, file) => {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(uploadAcceptanceAction());
|
dispatch(uploadAcceptanceAction());
|
||||||
return htmlClient.uploadFile(file, {
|
return htmlClient.uploadFile(file, {
|
||||||
url: `${API_SERVER}/orders/api/uploadAcceptanceDocument`,
|
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}/upload-file`
|
||||||
data: {
|
|
||||||
idOrder
|
|
||||||
}
|
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (typeof response.data !== 'undefined' && 'messages' in response.data) {
|
if (typeof response.data !== 'undefined') {
|
||||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
//dispatch(updateMessages(response.data.messages, orderMessages));
|
||||||
dispatch(fetchCustomerAcceptance(idOrder));
|
dispatch(fetchCustomerAcceptance(idEntry));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
htmlClient.onError(error, dispatch);
|
htmlClient.onError(error, dispatch);
|
||||||
@@ -77,14 +71,13 @@ const sendCustomerAcceptance = () => ({
|
|||||||
type: SEND_CUSTOMER_ACCEPTANCE
|
type: SEND_CUSTOMER_ACCEPTANCE
|
||||||
});
|
});
|
||||||
|
|
||||||
export const acceptDeclineInstallation = (idOrder, actionType, declineReason) => {
|
export const acceptDeclineInstallation = (idEntry, actionType, declineReason) => {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(sendCustomerAcceptance());
|
dispatch(sendCustomerAcceptance());
|
||||||
return htmlClient.fetch({
|
return htmlClient.fetch({
|
||||||
url: `${API_SERVER}/orders/api/acceptDeclineInstallation`,
|
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
idOrder,
|
|
||||||
actionType,
|
actionType,
|
||||||
declineReason
|
declineReason
|
||||||
}
|
}
|
||||||
@@ -92,7 +85,7 @@ export const acceptDeclineInstallation = (idOrder, actionType, declineReason) =>
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||||
dispatch(fetchCustomerAcceptance(idOrder));
|
dispatch(fetchCustomerAcceptance(idEntry));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user