handle order actions
This commit is contained in:
@@ -19,7 +19,7 @@ export const fetchNextActions = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestNextActions());
|
||||
return client.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/next-delivery-steps`
|
||||
url: `${API_SERVER}/wp-json/wiaas/delivery/next-actions`
|
||||
})
|
||||
.then(response => dispatch(recieveNextActions(response.data)))
|
||||
.catch(error => {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -31,10 +31,10 @@ class CustomerAcceptance extends Component {
|
||||
fileHandler.download(fileUrl, fileName);
|
||||
}
|
||||
|
||||
uploadFile(idEntry, acceptedFiles, rejectedFiles) {
|
||||
uploadFile(idOrder, acceptedFiles, rejectedFiles) {
|
||||
if(acceptedFiles && acceptedFiles.length){
|
||||
const file = acceptedFiles[0];
|
||||
this.props.dispatch(uploadAcceptance(idEntry, file));
|
||||
this.props.dispatch(uploadAcceptance(idOrder, file));
|
||||
}
|
||||
|
||||
if(rejectedFiles && rejectedFiles.length) {
|
||||
@@ -59,9 +59,9 @@ class CustomerAcceptance extends Component {
|
||||
}
|
||||
|
||||
acceptDeclineInstallation() {
|
||||
const {idProcess} = this.props.step;
|
||||
const {idOrder} = this.props.step;
|
||||
const {actionType, reason} = this.state;
|
||||
this.props.dispatch(acceptDeclineInstallation(idProcess, actionType, reason));
|
||||
this.props.dispatch(acceptDeclineInstallation(idOrder, actionType, reason));
|
||||
this.setState({reason: ''});
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ class CustomerAcceptance extends Component {
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
const {idProcess} = this.props.step;
|
||||
this.props.dispatch(fetchCustomerAcceptance(idProcess));
|
||||
const {idOrder} = this.props.step;
|
||||
this.props.dispatch(fetchCustomerAcceptance(idOrder));
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -137,7 +137,7 @@ class CustomerAcceptance extends Component {
|
||||
multiple={false}
|
||||
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods,.jpg,.png,.jpeg"
|
||||
activeClassName="upload-file-accept"
|
||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idProcess, acceptedFiles, rejectedFiles)}}>
|
||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
|
||||
<h5 className="drop-zone-text">{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}</h5>
|
||||
</Dropzone>
|
||||
</Col>
|
||||
@@ -148,7 +148,7 @@ class CustomerAcceptance extends Component {
|
||||
{
|
||||
customerAcceptance.documents.map((document, index) => <div key={'acceptance-documnet-' + index}>
|
||||
<span className="document-link">
|
||||
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} ({document.extension}) </a>
|
||||
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
|
||||
</span>
|
||||
<span className="document-status">
|
||||
{document.validation} <div className={'status-icon ' + document.validation}></div>
|
||||
|
||||
@@ -23,8 +23,8 @@ class ValidateQuestionnaire extends Component {
|
||||
return (
|
||||
<div id="validate-questionnaire" className="validate-questionnaire">
|
||||
{
|
||||
customerQuestionnaires && customerQuestionnaires.actions &&
|
||||
customerQuestionnaires.actions.map((customerQuestionnaryAction) =>
|
||||
customerQuestionnaires &&
|
||||
customerQuestionnaires.map((customerQuestionnaryAction) =>
|
||||
<ValidateQuestionnaireItem
|
||||
action={customerQuestionnaryAction}
|
||||
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
|
||||
|
||||
@@ -47,9 +47,8 @@ class ValidateQuestionnaireItem extends Component {
|
||||
<Col xl="7" lg="8">
|
||||
<div>
|
||||
|
||||
<span className="document-link"
|
||||
onClick={() => {this.downloadDocument(document)}}>
|
||||
<i className={'fa fa-file'}></i> {document.version}
|
||||
<span className="document-link">
|
||||
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
|
||||
</span>
|
||||
<br />
|
||||
<span className="document-status">
|
||||
@@ -60,8 +59,7 @@ class ValidateQuestionnaireItem extends Component {
|
||||
(action.comments && action.comments.length > 0) &&
|
||||
<div>
|
||||
{action.comments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
|
||||
<div>{comment.user} - {comment.addDate}</div>
|
||||
<div>{comment.comment}</div>
|
||||
<div>{comment}</div>
|
||||
</div>)}
|
||||
</div>
|
||||
}
|
||||
@@ -80,9 +78,8 @@ class ValidateQuestionnaireItem extends Component {
|
||||
: <div className="package-document">
|
||||
<Row>
|
||||
<Col>
|
||||
<span className="document-link"
|
||||
onClick={() => {this.downloadDocument(document)}}>
|
||||
<i className={'fa fa-file'}></i> {document.version}
|
||||
<span className="document-link">
|
||||
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
|
||||
</span>
|
||||
<br />
|
||||
<span className="document-status">
|
||||
|
||||
@@ -11,10 +11,15 @@ function formatAddress(addressObject) {
|
||||
}
|
||||
|
||||
export const fromWCOrder = (WCOrder) => {
|
||||
let processInfo = Object.assign({},WCOrder['delivery-process']);
|
||||
if (WCOrder['delivery-process']){
|
||||
let processInfo = undefined;
|
||||
|
||||
if (WCOrder['delivery-process']) {
|
||||
|
||||
processInfo = Object.assign({},WCOrder['delivery-process']);
|
||||
processInfo.steps = WCOrder['delivery-process'].steps.map(step=>fromWiaasProcessStep(step));
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
id: WCOrder.id,
|
||||
number: WCOrder.number,
|
||||
|
||||
Reference in New Issue
Block a user