diff --git a/src/components/Questionnaire/BuildingInfo.js b/src/components/Questionnaire/BuildingInfo.js index b177eff3d228ae1c72f7df9e29abd39b3b84d679..79565e139e253463184a28e52d4baf1055b02153 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 5c5862982da0542fcaaabfb829addd642c656f99..4970a33fa1b504879c4e48e5ea188c3f1313279b 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 92c97fdd133032714e6df7a762edec212dfbabab..48e95729db4aadef3370422c42778888ebc79022 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 156bb484fb436b09133258fb1e4e7a9fe64455ea..c13d449c938dfdfaf27403b8428aa78bcb3fa18d 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 {