Merge branch 'master' into package-details
This commit is contained in:
@@ -118,6 +118,7 @@ export const validateCredentials = (username, password) => {
|
||||
|
||||
// if(decodedAceessToken.data.wiaas_user_type === 'customer'){
|
||||
localStorage.setItem('accessToken', response.data.token);
|
||||
localStorage.setItem('username', username);
|
||||
const serverTime = decodedAceessToken.nbf || 1;
|
||||
// refreshToken = response.data.refreshToken;
|
||||
startRefreshTimer(dispatch, serverTime);
|
||||
|
||||
@@ -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) {
|
||||
if (typeof response.data !== 'undefined') {
|
||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||
dispatch(fetchCustomerAcceptance(idOrder));
|
||||
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 => {
|
||||
|
||||
@@ -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 => {
|
||||
@@ -63,22 +62,28 @@ const sendComment = () => ({
|
||||
type: SEND_ORDER_COMMENT
|
||||
})
|
||||
|
||||
export const addComment = (idOrder, comment) => {
|
||||
export const addComment = (idOrder, newComment) => {
|
||||
return dispatch => {
|
||||
dispatch(sendComment());
|
||||
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/orders/api/addOrderComment`,
|
||||
method: 'post',
|
||||
data: {
|
||||
idOrder,
|
||||
comment
|
||||
}
|
||||
})
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders/${idOrder}/notes`,
|
||||
method: 'post',
|
||||
data: {
|
||||
note : newComment || 'Test comment',
|
||||
customer_note: true,
|
||||
}
|
||||
})
|
||||
.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);
|
||||
|
||||
Reference in New Issue
Block a user