Files
old-new-wiaas/frontend/src/containers/orders/components/process/ValidateQuestionnaire.jsx

46 lines
1.8 KiB
React
Raw Normal View History

2018-06-14 16:49:28 +02:00
import React, {Component} from 'react';
import {connect} from 'react-redux';
2018-10-30 17:20:56 +01:00
import {fetchCustomerQuestionnaires} from '../../../../actions/orders/customerQuestionnairesActions';
2018-06-14 16:49:28 +02:00
import ValidateQuestionnaireItem from './ValidateQuestionnaireItem.jsx';
import '../../style/ValidateQuestionnaire.css';
class ValidateQuestionnaire extends Component {
componentDidMount(){
const {idOrder, idProcessStep} = this.props.step;
2018-10-30 17:20:56 +01:00
this.props.dispatch(fetchCustomerQuestionnaires(idOrder));
//this.props.dispatch(fetchValidationComments(idOrder, idProcessStep, 'invalidQuestionnaireComment'));
2018-06-14 16:49:28 +02:00
}
findById(orderPackage, idOrderPackagePair){
const idPackage = idOrderPackagePair.split('-')[1];
return orderPackage.idPackage === parseInt(idPackage, 10);
}
render() {
2018-10-30 17:20:56 +01:00
const {customerQuestionnaires, orderPackages} = this.props;
2018-06-14 16:49:28 +02:00
return (
<div id="validate-questionnaire" className="validate-questionnaire">
{
2018-10-31 10:23:59 +01:00
customerQuestionnaires &&
customerQuestionnaires.map((customerQuestionnaryAction) =>
2018-06-14 16:49:28 +02:00
<ValidateQuestionnaireItem
2018-10-30 17:20:56 +01:00
action={customerQuestionnaryAction}
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
/>
2018-06-14 16:49:28 +02:00
)
}
</div>
);
}
}
const mapStateToProps = (state) => ({
2018-10-30 17:20:56 +01:00
customerQuestionnaires: state.processReducer.customerQuestionnaires,
2018-06-14 16:49:28 +02:00
orderPackages: state.processReducer.orderInfo.packages
});
export default connect(mapStateToProps)(ValidateQuestionnaire);