delivery step actions
This commit is contained in:
68
frontend/src/actions/orders/customerQuestionnairesActions.js
Normal file
68
frontend/src/actions/orders/customerQuestionnairesActions.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
API_SERVER
|
||||
} from '../../config';
|
||||
|
||||
import {
|
||||
UPLOAD_CUSTOMER_QUESTIONNAIRE,
|
||||
REQUEST_CUSTOMER_QUESTIONNAIRES,
|
||||
RECEIVE_CUSTOMER_QUESTIONNAIRES,
|
||||
orderMessages, REQUEST_CUSTOMER_ACCEPTANCE, RECEIVE_CUSTOMER_ACCEPTANCE, UPLOAD_CUSTOMER_ACCEPTANCE
|
||||
} from '../../constants/ordersConstants';
|
||||
|
||||
import {
|
||||
updateMessages
|
||||
} from '../notification/notificationActions';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
import {fetchCustomerAcceptance} from "./customerAcceptanceActions";
|
||||
|
||||
const htmlClient = new HtmlClient();
|
||||
|
||||
|
||||
const requestCustomerQuestionnaires = () => ({
|
||||
type: REQUEST_CUSTOMER_QUESTIONNAIRES
|
||||
});
|
||||
|
||||
const receiveCustomerQuestionnaires = (json) => ({
|
||||
type: RECEIVE_CUSTOMER_QUESTIONNAIRES,
|
||||
customerQuestionnaires: json
|
||||
});
|
||||
|
||||
const uploadCustomerQuestionnaireAction = () => ({
|
||||
type: UPLOAD_CUSTOMER_QUESTIONNAIRE
|
||||
});
|
||||
|
||||
|
||||
export const fetchCustomerQuestionnaires = (idOrder) => {
|
||||
return dispatch => {
|
||||
dispatch(requestCustomerQuestionnaires());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wiaas/customer-questionnaires/${idOrder}`,
|
||||
method: 'get'
|
||||
})
|
||||
.then(response => {
|
||||
if (typeof response.data !== 'undefined') {
|
||||
dispatch(receiveCustomerQuestionnaires(response.data));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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}`,
|
||||
}).then(response => {
|
||||
if (typeof response.data !== 'undefined') {
|
||||
dispatch(updateMessages(response.data.messages, orderMessages));
|
||||
dispatch(fetchCustomerQuestionnaires(orderId));
|
||||
}
|
||||
}).catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,10 @@ export const SET_VIEW_ALL_ORDERS = MODULE + 'SET_VIEW_ALL_ORDERS';
|
||||
export const REQUEST_ALL_SHIPPING_DATES_CONFIRMED = MODULE + 'REQUEST_ALL_SHIPPING_DATES_CONFIRMED';
|
||||
export const RECEIVE_ALL_SHIPPING_DATES_CONFIRMED = MODULE + 'RECEIVE_ALL_SHIPPING_DATES_CONFIRMED';
|
||||
|
||||
export const UPLOAD_CUSTOMER_QUESTIONNAIRE = MODULE + 'UPLOAD_CUSTOMER_QUESTIONNAIRE';
|
||||
export const REQUEST_CUSTOMER_QUESTIONNAIRES = MODULE + 'REQUEST_CUSTOMER_QUESTIONNAIRES';
|
||||
export const RECEIVE_CUSTOMER_QUESTIONNAIRES = MODULE + 'RECEIVE_CUSTOMER_QUESTIONNAIRES';
|
||||
|
||||
export const orderMessages = {
|
||||
SYSTEM_ALLOWED_LANGUAGES_EMPTY: 'There are no languages added in the system.',
|
||||
ALLOWED_LANGUAGE: 'Allowed languages are:',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {Component} from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
import {fetchCustomerDocuments, fetchValidationComments} from '../../../../actions/orders/processActions';
|
||||
import {fetchCustomerQuestionnaires} from '../../../../actions/orders/customerQuestionnairesActions';
|
||||
import ValidateQuestionnaireItem from './ValidateQuestionnaireItem.jsx';
|
||||
import '../../style/ValidateQuestionnaire.css';
|
||||
|
||||
@@ -8,7 +8,7 @@ class ValidateQuestionnaire extends Component {
|
||||
|
||||
componentDidMount(){
|
||||
const {idOrder, idProcessStep} = this.props.step;
|
||||
//this.props.dispatch(fetchCustomerDocuments(idOrder, 'orderQuestionaire'));
|
||||
this.props.dispatch(fetchCustomerQuestionnaires(idOrder));
|
||||
//this.props.dispatch(fetchValidationComments(idOrder, idProcessStep, 'invalidQuestionnaireComment'));
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ class ValidateQuestionnaire extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const {customerDocuments, validationComments, orderPackages} = this.props;
|
||||
const {customerQuestionnaires, orderPackages} = this.props;
|
||||
|
||||
return (
|
||||
<div id="validate-questionnaire" className="validate-questionnaire">
|
||||
{
|
||||
customerDocuments &&
|
||||
Object.keys(customerDocuments).map((idOrderPackagePair) =>
|
||||
customerQuestionnaires && customerQuestionnaires.actions &&
|
||||
customerQuestionnaires.actions.map((customerQuestionnaryAction) =>
|
||||
<ValidateQuestionnaireItem
|
||||
customerDocuments={customerDocuments[idOrderPackagePair]}
|
||||
validationComments={validationComments && validationComments[idOrderPackagePair] ? validationComments[idOrderPackagePair] : []}
|
||||
orderPackage={orderPackages.find((orderPackage)=>{ return this.findById(orderPackage, idOrderPackagePair)})}
|
||||
key={'validate-questionnaire-' + idOrderPackagePair}/>
|
||||
action={customerQuestionnaryAction}
|
||||
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
|
||||
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
@@ -38,8 +38,7 @@ class ValidateQuestionnaire extends Component {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
customerDocuments: state.processReducer.customerDocuments,
|
||||
validationComments: state.processReducer.validationComments,
|
||||
customerQuestionnaires: state.processReducer.customerQuestionnaires,
|
||||
orderPackages: state.processReducer.orderInfo.packages
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, {Component} from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
import Dropzone from 'react-dropzone';
|
||||
import {Row, Col} from 'reactstrap';
|
||||
import {reUploadOrderDocument, badFile} from '../../../../actions/orders/processActions';
|
||||
import {uploadCustomerQuestionnaire, badFile} from '../../../../actions/orders/customerQuestionnairesActions';
|
||||
import {API_SERVER} from '../../../../config';
|
||||
import FileDownloader from '../../../../helpers/FileDownloader';
|
||||
import {orderTexts} from '../../../../constants/ordersConstants';
|
||||
@@ -16,19 +16,21 @@ class ValidateQuestionnaireItem extends Component {
|
||||
fileHandler.download(fileUrl, fileName);
|
||||
}
|
||||
|
||||
uploadFile(idPackage, idOrder, idDocument,acceptedFiles, rejectedFiles) {
|
||||
uploadFile(action,acceptedFiles, rejectedFiles) {
|
||||
if(acceptedFiles && acceptedFiles.length){
|
||||
const file = acceptedFiles[0];
|
||||
this.props.dispatch(reUploadOrderDocument(idPackage, idOrder, idDocument, file));
|
||||
this.props.dispatch(uploadCustomerQuestionnaire(action.order_id, action.action_id, file));
|
||||
}
|
||||
|
||||
if(rejectedFiles && rejectedFiles.length) {
|
||||
this.props.dispatch(badFile());
|
||||
}
|
||||
// if(rejectedFiles && rejectedFiles.length) {
|
||||
// this.props.dispatch(badFile());
|
||||
// }
|
||||
}
|
||||
|
||||
render() {
|
||||
const {customerDocuments, validationComments, orderPackage} = this.props;
|
||||
const {action, orderPackage} = this.props;
|
||||
|
||||
const customerDocuments = [ action.document ];
|
||||
|
||||
return (
|
||||
<div id="validate-questionnaire" className="validate-questionnaire">
|
||||
@@ -37,25 +39,27 @@ class ValidateQuestionnaireItem extends Component {
|
||||
<div>
|
||||
{orderPackage.packageName}
|
||||
{
|
||||
customerDocuments.map(document => <div key={'package-document-' + document.idDocument}>
|
||||
customerDocuments.map(document => <div key={'package-document-' + document.key}>
|
||||
{
|
||||
document.validation === 'invalid'
|
||||
action.status === 'invalid'
|
||||
? <div className="package-document">
|
||||
<Row>
|
||||
<Col xl="7" lg="8">
|
||||
<div>
|
||||
|
||||
<span className="document-link"
|
||||
onClick={() => {this.downloadDocument(document)}}>
|
||||
<i className={'fa fa-file'}></i> {document.documentName} ({document.extension}) {' '}
|
||||
<i className={'fa fa-file'}></i> {document.version}
|
||||
</span>
|
||||
<br />
|
||||
<span className="document-status">
|
||||
{document.validation.replace(/-/g,' ')} <div className={'status-icon ' + document.validation}></div>
|
||||
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
|
||||
</span>
|
||||
</div>
|
||||
{
|
||||
(validationComments && validationComments.length > 0) &&
|
||||
(action.comments && action.comments.length > 0) &&
|
||||
<div>
|
||||
{validationComments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
|
||||
{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>)}
|
||||
@@ -67,7 +71,7 @@ class ValidateQuestionnaireItem extends Component {
|
||||
multiple={false}
|
||||
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods"
|
||||
activeClassName="upload-file-accept"
|
||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(document.idPackage, document.idOrder, document.idDocument, acceptedFiles, rejectedFiles)}}>
|
||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
|
||||
<h5 className="drop-zone-text">{orderTexts.labels.SELECT_OR_DROP}</h5>
|
||||
</Dropzone>
|
||||
</Col>
|
||||
@@ -78,10 +82,11 @@ class ValidateQuestionnaireItem extends Component {
|
||||
<Col>
|
||||
<span className="document-link"
|
||||
onClick={() => {this.downloadDocument(document)}}>
|
||||
<i className={'fa fa-file'}></i> {document.documentName} ({document.extension}) {' '}
|
||||
<i className={'fa fa-file'}></i> {document.version}
|
||||
</span>
|
||||
<br />
|
||||
<span className="document-status">
|
||||
{document.validation.replace(/-/g,' ')} <div className={'status-icon ' + document.validation}></div>
|
||||
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
|
||||
</span>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
@@ -46,7 +46,7 @@ class HtmlClient {
|
||||
let formData = new FormData();
|
||||
formData.append('file', file, file.name);
|
||||
|
||||
if(configParams) {
|
||||
if(configParams && configParams.data) {
|
||||
|
||||
Object.keys(configParams.data).forEach((paramKey) => {
|
||||
formData.append(paramKey, configParams.data[paramKey]);
|
||||
|
||||
@@ -3,17 +3,14 @@ import moment from "moment";
|
||||
export const fromWiaasProcessStep = (step) => {
|
||||
return {
|
||||
actionCode: step.action_code,
|
||||
actualDate: step.actual_date,
|
||||
comments: step.comments,
|
||||
fullDesc: step.full_desc,
|
||||
idOrder: step.order_id,
|
||||
idProcess: step.step_form_entry_id, //not sure about this
|
||||
idProcess: step.process_id, //not sure about this
|
||||
idProcessStep: step.step_id, //not sure about this
|
||||
isNewCommentVisible: 1, //TODO : get this from backend
|
||||
isVisibleForCustomer: 1, //TODO : get this from backend
|
||||
now: moment().format("Do MMM YY"),
|
||||
shortDesc: step.short_desc,
|
||||
status: step.status,
|
||||
stepType: step.step_type,
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
RECEIVE_CUSTOMER_DOCUMENTS,
|
||||
RECEIVE_VALIDATION_COMMENTS,
|
||||
RECEIVE_CUSTOMER_ACCEPTANCE,
|
||||
RECEIVE_CUSTOMER_QUESTIONNAIRES,
|
||||
RECEIVE_IS_COMPONENT_DISABLED,
|
||||
RECEIVE_IS_NEXT_STEP_WANTED,
|
||||
SET_EARLIEST_INSTALLATION_DATE,
|
||||
@@ -53,6 +54,14 @@ moduleReducers[RECEIVE_CUSTOMER_ACCEPTANCE] = (state, action) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
moduleReducers[RECEIVE_CUSTOMER_QUESTIONNAIRES] = (state, action) => {
|
||||
|
||||
return Object.assign({}, state, {
|
||||
customerQuestionnaires: action.customerQuestionnaires
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_IS_COMPONENT_DISABLED] = (state, action) => {
|
||||
const newState = {isComponentDisabled : {}};
|
||||
newState.isComponentDisabled.installationScheduling = state.isComponentDisabled && state.isComponentDisabled.installationScheduling
|
||||
|
||||
Reference in New Issue
Block a user