handle order actions
This commit is contained in:
@@ -23,11 +23,11 @@ const recieveCustomerAcceptance = (json) => ({
|
||||
customerAcceptance: json
|
||||
});
|
||||
|
||||
export const fetchCustomerAcceptance = (idEntry) => {
|
||||
export const fetchCustomerAcceptance = (idOrder) => {
|
||||
return dispatch => {
|
||||
dispatch(requestCustomerAcceptance());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
@@ -45,15 +45,15 @@ const uploadAcceptanceAction = () => ({
|
||||
type: UPLOAD_CUSTOMER_ACCEPTANCE
|
||||
});
|
||||
|
||||
export const uploadAcceptance = (idEntry, file) => {
|
||||
export const uploadAcceptance = (idOrder, file) => {
|
||||
return dispatch => {
|
||||
dispatch(uploadAcceptanceAction());
|
||||
return htmlClient.uploadFile(file, {
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}/upload-file`
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance/upload`
|
||||
}).then(response => {
|
||||
if (typeof response.data !== 'undefined') {
|
||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||
dispatch(fetchCustomerAcceptance(idEntry));
|
||||
dispatch(fetchCustomerAcceptance(idOrder));
|
||||
}
|
||||
}).catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
@@ -71,21 +71,21 @@ const sendCustomerAcceptance = () => ({
|
||||
type: SEND_CUSTOMER_ACCEPTANCE
|
||||
});
|
||||
|
||||
export const acceptDeclineInstallation = (idEntry, actionType, declineReason) => {
|
||||
export const acceptDeclineInstallation = (idOrder, actionType, declineReason) => {
|
||||
return dispatch => {
|
||||
dispatch(sendCustomerAcceptance());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance`,
|
||||
method: 'post',
|
||||
data: {
|
||||
actionType,
|
||||
declineReason
|
||||
'action_type': actionType,
|
||||
'decline_reason': declineReason
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||
dispatch(fetchCustomerAcceptance(idEntry));
|
||||
dispatch(fetchCustomerAcceptance(idOrder));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -36,7 +36,7 @@ export const fetchCustomerQuestionnaires = (idOrder) => {
|
||||
return dispatch => {
|
||||
dispatch(requestCustomerQuestionnaires());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-questionnaires/${idOrder}`,
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-questionnaires`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
@@ -55,7 +55,7 @@ export const uploadCustomerQuestionnaire = (orderId, actionId, file) => {
|
||||
return dispatch => {
|
||||
dispatch(uploadCustomerQuestionnaireAction());
|
||||
return htmlClient.uploadFile(file, {
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-questionnaires/${orderId}/upload/${actionId}`,
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/${orderId}/customer-questionnaires/upload/${actionId}`,
|
||||
}).then(response => {
|
||||
if (typeof response.data !== 'undefined') {
|
||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||
|
||||
Reference in New Issue
Block a user