From d4e2c23a42c96ece21ac40b60e7403b883211154 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Fri, 6 Sep 2019 18:09:12 -0400 Subject: [PATCH] Enabled answers for textboxs --- src/components/Questionnaire/BuildingInfo.js | 43 ++++++++++-------- .../Questionnaire/FinancialInitial.js | 28 +++++++----- src/components/Questionnaire/RemoteSurvey.js | 45 ++++++++++--------- src/containers/Questionnaire/index.js | 5 ++- 4 files changed, 68 insertions(+), 53 deletions(-) diff --git a/src/components/Questionnaire/BuildingInfo.js b/src/components/Questionnaire/BuildingInfo.js index b177eff3..79565e13 100644 --- a/src/components/Questionnaire/BuildingInfo.js +++ b/src/components/Questionnaire/BuildingInfo.js @@ -9,6 +9,7 @@ class BuildingInfo extends Component { super(props); this.state = { form: { + buildingId: props.buildingId, firstName: props.firstName, lastName: props.lastName, email: props.email, @@ -30,26 +31,29 @@ class BuildingInfo extends Component { } componentWillReceiveProps(nextProps) { - this.setState({ - form: { - firstName: nextProps.firstName, - lastName: nextProps.lastName, - email: nextProps.email, - phone: nextProps.phone, - address: nextProps.address, - buildingSqFt: nextProps.buildingSqFt, - numberOfFloors: nextProps.numberOfFloors, - unitInfo: { - studio: nextProps.numOfStudio, - oneBedroom: nextProps.numOfOneBedroom, - twoBedroom: nextProps.numOfTwoBedroom, - threeBedroom: nextProps.numOfThreeBedroom, - fourBedroom: nextProps.numOfFourBedroom, - other: nextProps.other, - numOfOther: nextProps.numOfOther, + if (this.props.buildingId !== nextProps.buildingId) { + this.setState({ + form: { + buildingId: nextProps.buildingId, + firstName: nextProps.firstName, + lastName: nextProps.lastName, + email: nextProps.email, + phone: nextProps.phone, + address: nextProps.address, + buildingSqFt: nextProps.buildingSqFt, + numberOfFloors: nextProps.numberOfFloors, + unitInfo: { + studio: nextProps.numOfStudio, + oneBedroom: nextProps.numOfOneBedroom, + twoBedroom: nextProps.numOfTwoBedroom, + threeBedroom: nextProps.numOfThreeBedroom, + fourBedroom: nextProps.numOfFourBedroom, + other: nextProps.other, + numOfOther: nextProps.numOfOther, + }, }, - }, - }); + }); + } } handleInputChange = (event) => { @@ -329,6 +333,7 @@ class BuildingInfo extends Component { BuildingInfo.propTypes = { tableHeader: PropTypes.objectOf, labelStyle: PropTypes.objectOf, + buildingId: PropTypes.number, address: PropTypes.arrayOf, firstName: PropTypes.string, lastName: PropTypes.string, diff --git a/src/components/Questionnaire/FinancialInitial.js b/src/components/Questionnaire/FinancialInitial.js index 5c586298..4970a33f 100644 --- a/src/components/Questionnaire/FinancialInitial.js +++ b/src/components/Questionnaire/FinancialInitial.js @@ -7,6 +7,7 @@ class FinanacialInitial extends Component { super(props); this.state = { form: { + buildingId: props.buildingId, legalOwnership: props.legalOwnership, bankruptcyPast: props.bankruptcyPast, currentOnEnergyBills: props.currentOnEnergyBills, @@ -19,17 +20,20 @@ class FinanacialInitial extends Component { } componentWillReceiveProps(nextProps) { - this.setState({ - form: { - legalOwnership: nextProps.legalOwnership, - bankruptcyPast: nextProps.bankruptcyPast, - currentOnEnergyBills: nextProps.currentOnEnergyBills, - currentMortgageBalance: nextProps.currentMortgageBalance, - profitable: nextProps.profitable, - budgetForDownPayment: nextProps.budgetForDownPayment, - numberOfDobViolations: nextProps.numberOfDobViolations, - }, - }); + if (this.props.buildingId !== nextProps.buildingId) { + this.setState({ + form: { + buildingId: nextProps.buildingId, + legalOwnership: nextProps.legalOwnership, + bankruptcyPast: nextProps.bankruptcyPast, + currentOnEnergyBills: nextProps.currentOnEnergyBills, + currentMortgageBalance: nextProps.currentMortgageBalance, + profitable: nextProps.profitable, + budgetForDownPayment: nextProps.budgetForDownPayment, + numberOfDobViolations: nextProps.numberOfDobViolations, + }, + }); + } } handleInputChange = (event) => { @@ -214,6 +218,7 @@ class FinanacialInitial extends Component { FinanacialInitial.propTypes = { tableHeader: PropTypes.objectOf, + buildingId: PropTypes.number, bankruptcyPast: PropTypes.string, currentOnEnergyBills: PropTypes.string, currentMortgageBalance: PropTypes.string, @@ -222,7 +227,6 @@ FinanacialInitial.propTypes = { legalOwnership: PropTypes.string, numberOfDobViolations: PropTypes.string, onChangeEvent: PropTypes.func, - // answers: PropTypes.objectOf, }; export default FinanacialInitial; diff --git a/src/components/Questionnaire/RemoteSurvey.js b/src/components/Questionnaire/RemoteSurvey.js index 92c97fdd..48e95729 100644 --- a/src/components/Questionnaire/RemoteSurvey.js +++ b/src/components/Questionnaire/RemoteSurvey.js @@ -7,6 +7,7 @@ class RemoteSurvey extends Component { super(props); this.state = { form: { + buildingId: props.buildingId, heatingSystem: props.heatingSystem, heatingFuelSource: props.heatingFuelSource, DHWSameBoiler: props.DHWSameBoiler, @@ -28,26 +29,29 @@ class RemoteSurvey extends Component { } componentWillReceiveProps(nextProps) { - this.setState({ - form: { - heatingSystem: nextProps.heatingSystem, - heatingFuelSource: nextProps.heatingFuelSource, - DHWSameBoiler: nextProps.DHWSameBoiler, - ageOfHeatGenerateSystem: nextProps.ageOfHeatGenerateSystem, - planToReplaceHS: nextProps.planToReplaceHS, - hallwaysHeated: nextProps.hallwaysHeated, - basementHeated: nextProps.basementHeated, - stairwellsHeated: nextProps.stairwellsHeated, - floorsHeated: nextProps.floorsHeated, - accessibleByStairwell: nextProps.accessibleByStairwell, - backFacadeAttached: nextProps.backFacadeAttached, - exteriorWallsAttached: nextProps.exteriorWallsAttached, - tenantComplaintsComfort: nextProps.tenantComplaintsComfort, - tenantComplaintsWindows: nextProps.tenantComplaintsWindows, - meteredForElectricity: nextProps.meteredForElectricity, - numberOfHeatingViolations: nextProps.numberOfHeatingViolations, - }, - }); + if (this.props.buildingId !== nextProps.buildingId) { + this.setState({ + form: { + buildingId: nextProps.buildingId, + heatingSystem: nextProps.heatingSystem, + heatingFuelSource: nextProps.heatingFuelSource, + DHWSameBoiler: nextProps.DHWSameBoiler, + ageOfHeatGenerateSystem: nextProps.ageOfHeatGenerateSystem, + planToReplaceHS: nextProps.planToReplaceHS, + hallwaysHeated: nextProps.hallwaysHeated, + basementHeated: nextProps.basementHeated, + stairwellsHeated: nextProps.stairwellsHeated, + floorsHeated: nextProps.floorsHeated, + accessibleByStairwell: nextProps.accessibleByStairwell, + backFacadeAttached: nextProps.backFacadeAttached, + exteriorWallsAttached: nextProps.exteriorWallsAttached, + tenantComplaintsComfort: nextProps.tenantComplaintsComfort, + tenantComplaintsWindows: nextProps.tenantComplaintsWindows, + meteredForElectricity: nextProps.meteredForElectricity, + numberOfHeatingViolations: nextProps.numberOfHeatingViolations, + }, + }); + } } handleInputChange = (event) => { @@ -416,6 +420,7 @@ class RemoteSurvey extends Component { RemoteSurvey.propTypes = { tableHeader: PropTypes.objectOf, labelStyle: PropTypes.objectOf, + buildingId: PropTypes.number, heatingSystem: PropTypes.string, heatingFuelSource: PropTypes.string, DHWSameBoiler: PropTypes.string, diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 156bb484..c13d449c 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -71,8 +71,6 @@ class Questionnaire extends Component { this.setState({ ...this.state, [formType]: formData, - }, () => { - console.log(this.state[formType]); // eslint-disable-line }); } @@ -222,6 +220,7 @@ class Questionnaire extends Component {