From 82b421d5c7ee4d93ce121c3f450b61c3dba77db1 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 15 Aug 2019 18:43:02 -0400 Subject: [PATCH 01/20] Update reducer and sagas --- src/containers/Questionnaire/reducer.js | 2 ++ src/containers/Questionnaire/sagas.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/Questionnaire/reducer.js b/src/containers/Questionnaire/reducer.js index b932745a..a2c4c03e 100644 --- a/src/containers/Questionnaire/reducer.js +++ b/src/containers/Questionnaire/reducer.js @@ -45,6 +45,8 @@ export default function (state = questionnaireInitialState, action) { }; case LOAD_QUESTIONNAIRE_SUCCEEDED: + console.log(questionnaireInitialState); // eslint-disable-line + console.log(action); // eslint-disable-line return { ...state, buildingInfo: { diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index da8db336..c818299f 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -24,14 +24,14 @@ import SagaRequests from '../../utils/sagaRequests'; function* loadQuestionnaire(action) { - const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/questionnaire/`; + const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/questionnaire/`; yield SagaRequests.get(action, url, loadQuestionnaireSucceeded, loadQuestionnaireLFailed); } function* submitQuestionnaire(action) { const formData = new FormData(); Object.keys(action.payload).map(key => formData.append(key, action.payload[key])); - const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/questionnaire/`; + const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/questionnaire/`; const res = yield call( request, -- GitLab From 7cab8e2a3287a697ae821b5d38ac1cdfd87e4bcd Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Fri, 16 Aug 2019 18:36:55 -0400 Subject: [PATCH 02/20] Load data to frontend page properly --- src/components/Ashp/BuildingInfo.js | 9 +- src/components/Ashp/FinancialInitial.js | 68 ++-- src/components/Ashp/RemoteSurvey.js | 195 ++++++----- src/containers/Questionnaire/actions.js | 4 +- src/containers/Questionnaire/index.js | 414 ++++++++++++------------ src/containers/Questionnaire/reducer.js | 14 +- 6 files changed, 353 insertions(+), 351 deletions(-) diff --git a/src/components/Ashp/BuildingInfo.js b/src/components/Ashp/BuildingInfo.js index 7651e7f6..023e4a0e 100644 --- a/src/components/Ashp/BuildingInfo.js +++ b/src/components/Ashp/BuildingInfo.js @@ -33,6 +33,7 @@ class BuildingInfo extends Component { [name]: val, }, }, () => { + console.log(this.state.form); // eslint-disable-line this.props.onChangeEvent('buildingInfo', this.state.form); console.log('changed!'); // eslint-disable-line }); @@ -42,15 +43,17 @@ class BuildingInfo extends Component { this.setState({ form: { ...this.state.form, - [name]: val, + [name]: parseInt(val, 10), }, }, () => { + console.log(this.state.form); // eslint-disable-line this.props.onChangeEvent('buildingInfo', this.state.form); console.log('changed!'); // eslint-disable-line }); } render() { + console.log(this.props); // eslint-disable-line const address = this.props.address.map(addressItem => { return (
@@ -204,7 +207,7 @@ class BuildingInfo extends Component {
this.handleInputChange(e)} />
@@ -213,7 +216,7 @@ class BuildingInfo extends Component { type="select" name={'numOfOther'} inputName={'numOfOther'} - value={this.state.numOfOther} + value={this.state.form.numOfOther} onChange={e => this.handleInputChange(e)} > diff --git a/src/components/Ashp/FinancialInitial.js b/src/components/Ashp/FinancialInitial.js index 4fc5b3a5..4801d2da 100644 --- a/src/components/Ashp/FinancialInitial.js +++ b/src/components/Ashp/FinancialInitial.js @@ -48,91 +48,91 @@ class FinanacialInitial extends Component {
- Any bankruptcy in the past three years? + {this.props.bankruptyPast.question} this.handleInputChange(e)} > - - - - + + + + - Current on energy bills? + {this.props.currentOnEnergyBills.question} this.handleInputChange(e)} > - - - - - - - + + + + + + +
- What is the current outstanding balance of the mortgage? + {this.props.currentMortgageBalance.question} this.handleInputChange(e)} > - - - - - - + + + + + + - Is your building currently profitable? + {this.props.profitable.question} this.handleInputChange(e)} > - - - - + + + +
- What is your current budget for a down payment? + {this.props.budgetForDownPayment.question} this.handleInputChange(e)} > - - - + + + diff --git a/src/components/Ashp/RemoteSurvey.js b/src/components/Ashp/RemoteSurvey.js index dadcdc3b..59e37dd1 100644 --- a/src/components/Ashp/RemoteSurvey.js +++ b/src/components/Ashp/RemoteSurvey.js @@ -56,94 +56,94 @@ class RemoteSurvey extends Component { diff --git a/src/containers/Questionnaire/actions.js b/src/containers/Questionnaire/actions.js index 85d322bc..4b9332a4 100644 --- a/src/containers/Questionnaire/actions.js +++ b/src/containers/Questionnaire/actions.js @@ -17,11 +17,11 @@ import { makeActionCreator } from '../../utils/reduxHelpers'; export const loadQuestionnaire = makeActionCreator(LOAD_QUESTIONNAIRE_REQUESTED, 'buildingId'); -export const loadQuestionnaireSucceeded = makeActionCreator(LOAD_QUESTIONNAIRE_SUCCEEDED, 'questionnaire'); +export const loadQuestionnaireSucceeded = makeActionCreator(LOAD_QUESTIONNAIRE_SUCCEEDED, 'instance'); export const loadQuestionnaireLFailed = makeActionCreator(LOAD_QUESTIONNAIRE_FAILED, 'error'); export const submitQuestionnaire = makeActionCreator(SUBMIT_QUESTIONNAIRE_REQUESTED, 'buildingId'); -export const submitQuestionnaireSucceeded = makeActionCreator(SUBMIT_QUESTIONNAIRE_SUCCEEDED, 'questionnaire'); +export const submitQuestionnaireSucceeded = makeActionCreator(SUBMIT_QUESTIONNAIRE_SUCCEEDED, 'instance'); export const submitQuestionnaireFailed = makeActionCreator(SUBMIT_QUESTIONNAIRE_FAILED, 'error'); export const calculateCost = makeActionCreator(CALCULATE_COST_REQUESTED, 'buildingId', 'id'); diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index e2e23f17..4c4e235a 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { Button } from 'reactstrap'; -// import Loading from '../../components/Loading'; +import Loading from '../../components/Loading'; import buildingDetailPropTypes from '../Building/propTypes'; import { loadQuestionnaire, @@ -48,46 +48,9 @@ class Questionnaire extends Component { budgetForDownPayment: 'Down payment budget', }; this.state = { - buildingInfo: { - firstName: 'Bryan', - lastName: 'Ontiveros', - email: 'bryan@blocpower.io', - phone: '911-911-9911', - address: this.props.building.street_address.map(addressItem => { - return `${addressItem}, ${this.props.building.borough}`; - }), - numOfStudio: 1, - numOfOneBedroom: 3, - numOfTwoBedroom: 2, - numOfThreeBedroom: 1, - numOfFourBedroom: 0, - other: ' ', - numOfOther: 0, - }, - remoteSurvey: { - heatingSystem: 'steam', - heatingFuelSource: 'heating oil', - DHWSameBoiler: 'yes', - AgeOfHeatGenerateSystem: '0-3 years', - planToReplaceHS: 'asap', - hallwaysHeated: 'yes', - basementHeated: 'yes', - stairwellsHeated: 'yes', - floorsHeated: 'yes', - accessibleByStairwell: 'yes', - backFacadeAttached: 'yes', - exteriorWallsAttached: 'no', - tenantComplaintsComfort: 'no', - tenantComplaintsWindows: 'no', - meteredForElectricity: 'no', - }, - financialInitials: { - bankruptyPast: 'yes', - currentOnEnergyBills: 'current', - currentMortgageBalance: '0%', - profitable: 'always', - budgetForDownPayment: 'no cash', - }, + buildingInfo: {}, + remoteSurvey: {}, + financialInitials: {}, showReviewAnswers: false, submitted: false, calculated: false, @@ -109,11 +72,19 @@ class Questionnaire extends Component { } submitQuestionnaire = () => { + console.log(this.state); // eslint-disable-line + if (Object.keys(this.state.buildingInfo).length === 0) { + this.setState({ + buildingInfo: this.props.questionnaire.buildingInfo.data, + }); + } + if (this.validateInputs()) { this.setState({ submitted: true, showReviewAnswers: true, }, () => { + this.props.submitQuestionnaire(this.props.building.building_id, this.state); console.log('Saving answers!'); // eslint-disable-line }); } @@ -184,188 +155,217 @@ class Questionnaire extends Component { } render() { - const tableHeader = { - paddingBottom: '20px', - borderTop: '1px solid #CCCCCC', - background: '#EEEEEE', - fontWeight: 'bold', - paddingTop: '20px', - }; + let mainContent = ; + const { + questionnaire, + building, + } = this.props; + const { + buildingInfo, + submittedAnswers, + } = questionnaire; - const labelStyle = { - marginBottom: '0.7em', - fontWeight: 'bold', - fontSize: '12px', - color: '#999999', - }; + if (buildingInfo.data !== undefined && buildingInfo.data !== null && + submittedAnswers.data !== undefined && submittedAnswers.data !== null && + building !== undefined) { - const successMsgStyle = { - padding: '15px 50px 15px 50px', - border: '2px solid #CCCCCC', - marginBottom: '20px', - background: '#B8DFC2', - }; + const address = building.street_address.map(addressItem => { + return `${addressItem}, ${building.borough}`; + }); - const editStyle = { - marginLeft: '15px', - cursor: 'pointer', - textDecoration: 'underline', - }; + let other = 'other'; + let numOfOther = 0; + Object.keys(buildingInfo.data.apartmentInfo).forEach(unitType => { + if (!['studio, one bedroom', 'two bedroom', 'three bedroom', 'four bedroom'].includes(unitType)) { + other = unitType; + numOfOther = buildingInfo.data.apartmentInfo[unitType]; + } + }); + + const tableHeader = { + paddingBottom: '20px', + borderTop: '1px solid #CCCCCC', + background: '#EEEEEE', + fontWeight: 'bold', + paddingTop: '20px', + }; + + const labelStyle = { + marginBottom: '0.7em', + fontWeight: 'bold', + fontSize: '12px', + color: '#999999', + }; + + const successMsgStyle = { + padding: '15px 50px 15px 50px', + border: '2px solid #CCCCCC', + marginBottom: '20px', + background: '#B8DFC2', + }; - let forms = ''; - if (this.state.showReviewAnswers === false) { - forms = ( -
-
-
- + const editStyle = { + marginLeft: '15px', + cursor: 'pointer', + textDecoration: 'underline', + }; + console.log(submittedAnswers.data.remoteSurvey); // eslint-disable-line + console.log(submittedAnswers.data.remoteSurvey['1']); // eslint-disable-line + + let forms = ''; + if (this.state.showReviewAnswers === false) { + forms = ( +
+
+
+ +
-
-
-
- +
+
+ +
-
-
-
- +
+
+ +
-
- ); - } - - let message = ''; - let editLink = ''; - let submitButton = ''; - if (this.state.showReviewAnswers === false) { - submitButton = ( - - ); - } + ); + } - let calculateButton = ''; - if (this.state.submitted === true) { - calculateButton = ( - - {' '} + let message = ''; + let editLink = ''; + let submitButton = ''; + if (this.state.showReviewAnswers === false) { + submitButton = ( - - ); - message = ( -
- Successfully submitted. -
- ); - } + ); + } - let downloadButton = ''; - if (this.state.calculated === true) { - downloadButton = ( - - {' '} - - - ); - message = ( -
- Calculation completed. -
- ); - } + let calculateButton = ''; + if (this.state.submitted === true) { + calculateButton = ( + + {' '} + + + ); + message = ( +
+ Successfully submitted. +
+ ); + } - let reviewAnswers = null; - if (this.state.showReviewAnswers === true) { - reviewAnswers = ( - - ); - editLink = ( - - Edit answers - - ); - } + let downloadButton = ''; + if (this.state.calculated === true) { + downloadButton = ( + + {' '} + + + ); + message = ( +
+ Calculation completed. +
+ ); + } + + let reviewAnswers = null; + if (this.state.showReviewAnswers === true) { + reviewAnswers = ( + + ); + editLink = ( + + Edit answers + + ); + } - const mainContent = ( -
- {forms} -
-
- {message} - {submitButton} - {calculateButton} - {downloadButton} - {editLink} + mainContent = ( +
+ {forms} +
+
+ {message} + {submitButton} + {calculateButton} + {downloadButton} + {editLink} +
+ {reviewAnswers}
- {reviewAnswers} -
- ); + ); + } return (
@@ -386,6 +386,8 @@ class Questionnaire extends Component { Questionnaire.propTypes = { building: buildingDetailPropTypes, loadQuestionnaire: PropTypes.func, + submitQuestionnaire: PropTypes.func, + questionnaire: PropTypes.objectOf, }; const mapDispatchToProps = dispatch => ( @@ -398,7 +400,7 @@ const mapDispatchToProps = dispatch => ( ); const mapStateToProps = state => ({ - buildingInfo: state.buildingInfo, + questionnaire: state.questionnaire, user: state.user, eng: state.eng, }); diff --git a/src/containers/Questionnaire/reducer.js b/src/containers/Questionnaire/reducer.js index a2c4c03e..028ebeec 100644 --- a/src/containers/Questionnaire/reducer.js +++ b/src/containers/Questionnaire/reducer.js @@ -20,12 +20,7 @@ const questionnaireInitialState = { error: false, data: null, }, - remoteSurvey: { - loading: false, - error: false, - data: null, - }, - financialInitials: { + submittedAnswers: { loading: false, error: false, data: null, @@ -50,7 +45,12 @@ export default function (state = questionnaireInitialState, action) { return { ...state, buildingInfo: { - data: action.instance, + data: action.instance.buildingInfo, + loading: false, + error: false, + }, + submittedAnswers: { + data: action.instance.submittedAnswers, loading: false, error: false, }, -- GitLab From 59817f4e2be52b995d9c60aa3e74a72526671866 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Fri, 16 Aug 2019 19:19:33 -0400 Subject: [PATCH 03/20] Add console log and remove the callback function --- src/containers/Questionnaire/actions.js | 2 +- src/containers/Questionnaire/index.js | 19 ++++++++++++------- src/containers/Questionnaire/sagas.js | 11 +++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/containers/Questionnaire/actions.js b/src/containers/Questionnaire/actions.js index 4b9332a4..97387abc 100644 --- a/src/containers/Questionnaire/actions.js +++ b/src/containers/Questionnaire/actions.js @@ -20,7 +20,7 @@ export const loadQuestionnaire = makeActionCreator(LOAD_QUESTIONNAIRE_REQUESTED, export const loadQuestionnaireSucceeded = makeActionCreator(LOAD_QUESTIONNAIRE_SUCCEEDED, 'instance'); export const loadQuestionnaireLFailed = makeActionCreator(LOAD_QUESTIONNAIRE_FAILED, 'error'); -export const submitQuestionnaire = makeActionCreator(SUBMIT_QUESTIONNAIRE_REQUESTED, 'buildingId'); +export const submitQuestionnaire = makeActionCreator(SUBMIT_QUESTIONNAIRE_REQUESTED, 'buildingId', 'payload'); export const submitQuestionnaireSucceeded = makeActionCreator(SUBMIT_QUESTIONNAIRE_SUCCEEDED, 'instance'); export const submitQuestionnaireFailed = makeActionCreator(SUBMIT_QUESTIONNAIRE_FAILED, 'error'); diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 4c4e235a..d4219ab6 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -80,13 +80,18 @@ class Questionnaire extends Component { } if (this.validateInputs()) { - this.setState({ - submitted: true, - showReviewAnswers: true, - }, () => { - this.props.submitQuestionnaire(this.props.building.building_id, this.state); - console.log('Saving answers!'); // eslint-disable-line - }); + console.log(this.state); // eslint-disable-line + this.props.submitQuestionnaire(this.props.building.building_id, this.state); + console.log('Saving answers!'); // eslint-disable-line + // console.log(this.state); // eslint-disable-line + // this.setState({ + // submitted: true, + // showReviewAnswers: true, + // }, () => { + // console.log(this.state); // eslint-disable-line + // this.props.submitQuestionnaire(this.props.building.building_id, this.state); + // console.log('Saving answers!'); // eslint-disable-line + // }); } return false; } diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index c818299f..cd21c105 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -28,23 +28,22 @@ function* loadQuestionnaire(action) { yield SagaRequests.get(action, url, loadQuestionnaireSucceeded, loadQuestionnaireLFailed); } + function* submitQuestionnaire(action) { - const formData = new FormData(); - Object.keys(action.payload).map(key => formData.append(key, action.payload[key])); + console.log(action); // eslint-disable-line const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/questionnaire/`; - const res = yield call( request, SagaRequests.generateURL(url, action), { - method: 'POST', + method: 'PUT', headers: getHeaders(), - body: formData, + body: JSON.stringify(action.payload), } ); if (!res.err) { - yield put(submitQuestionnaireSucceeded(res)); + yield put(submitQuestionnaireSucceeded(action.payload)); } else { yield put(submitQuestionnaireFailed(res.err)); } -- GitLab From f6fa6c0034d99b58aa70a3659f9a833cac946b9e Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 19 Aug 2019 17:31:52 -0400 Subject: [PATCH 04/20] Updated reducer.js --- src/components/Ashp/BuildingInfo.js | 3 --- src/containers/Questionnaire/reducer.js | 31 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/components/Ashp/BuildingInfo.js b/src/components/Ashp/BuildingInfo.js index 023e4a0e..72cee3a7 100644 --- a/src/components/Ashp/BuildingInfo.js +++ b/src/components/Ashp/BuildingInfo.js @@ -33,7 +33,6 @@ class BuildingInfo extends Component { [name]: val, }, }, () => { - console.log(this.state.form); // eslint-disable-line this.props.onChangeEvent('buildingInfo', this.state.form); console.log('changed!'); // eslint-disable-line }); @@ -46,14 +45,12 @@ class BuildingInfo extends Component { [name]: parseInt(val, 10), }, }, () => { - console.log(this.state.form); // eslint-disable-line this.props.onChangeEvent('buildingInfo', this.state.form); console.log('changed!'); // eslint-disable-line }); } render() { - console.log(this.props); // eslint-disable-line const address = this.props.address.map(addressItem => { return (
diff --git a/src/containers/Questionnaire/reducer.js b/src/containers/Questionnaire/reducer.js index 028ebeec..cbc199cd 100644 --- a/src/containers/Questionnaire/reducer.js +++ b/src/containers/Questionnaire/reducer.js @@ -37,6 +37,11 @@ export default function (state = questionnaireInitialState, action) { loading: true, error: false, }, + submittedAnswers: { + ...state.submittedAnswers, + loading: true, + error: false, + }, }; case LOAD_QUESTIONNAIRE_SUCCEEDED: @@ -63,13 +68,22 @@ export default function (state = questionnaireInitialState, action) { loading: false, error: action.error, }, + submittedAnswers: { + loading: false, + error: action.error, + }, }; case SUBMIT_QUESTIONNAIRE_REQUESTED: return { ...state, - remoteSurvey: { - ...state.remoteSurvey, + buildingInfo: { + ...state.buildingInfo, + loading: true, + error: false, + }, + submittedAnswers: { + ...state.submittedAnswers, loading: true, error: false, }, @@ -78,17 +92,26 @@ export default function (state = questionnaireInitialState, action) { case SUBMIT_QUESTIONNAIRE_SUCCEEDED: return { ...state, - remoteSurvey: { + buildingInfo: { data: action.instance, loading: false, error: false, }, + submittedAnswers: { + data: action.submittedAnswers, + loading: false, + error: false, + }, }; case SUBMIT_QUESTIONNAIRE_FAILED: return { ...state, - remoteSurvey: { + buildingInfo: { + loading: false, + error: action.error, + }, + submittedAnswers: { loading: false, error: action.error, }, -- GitLab From 092ec558a037b90aa4485c9ae569c2853179d36b Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Tue, 20 Aug 2019 14:51:07 -0400 Subject: [PATCH 05/20] Updated pna endpoint for calculation --- src/containers/Questionnaire/sagas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index cd21c105..7a871aaa 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -50,7 +50,7 @@ function* submitQuestionnaire(action) { } function* calculateCost(action) { - const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/calculate-cost/`; + const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/calculate/`; yield SagaRequests.get(action, url, calculateCostSucceeded, calculateCostFailed); } -- GitLab From 38e58e98cb670e23e6d9170c2a57e1c9e3977802 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 20 Aug 2019 18:43:24 -0400 Subject: [PATCH 06/20] Fix dropdown issues --- src/components/Ashp/FinancialInitial.js | 11 +-- src/components/Ashp/RemoteSurvey.js | 17 +++-- src/containers/Questionnaire/index.js | 92 +++++++++++++++---------- 3 files changed, 71 insertions(+), 49 deletions(-) diff --git a/src/components/Ashp/FinancialInitial.js b/src/components/Ashp/FinancialInitial.js index 4801d2da..7236e369 100644 --- a/src/components/Ashp/FinancialInitial.js +++ b/src/components/Ashp/FinancialInitial.js @@ -8,7 +8,7 @@ class FinanacialInitial extends Component { super(props); this.state = { form: { - bankruptyPast: props.bankruptyPast, + bankruptcyPast: props.bankruptcyPast, currentOnEnergyBills: props.currentOnEnergyBills, currentMortgageBalance: props.currentMortgageBalance, profitable: props.profitable, @@ -48,13 +48,13 @@ class FinanacialInitial extends Component {
- Heating System + {this.props.heatingSystem.question} this.handleInputChange(e)} > - - - - - - + + + + + + - Heating Fuel Source + {this.props.heatingFuelSource.question} this.handleInputChange(e)} > - - - - - - + + + + + +
- Is Domestic Hot Water (DHW) and heat prepared by the same boiler? + {this.props.DHWSameBoiler.question} this.handleInputChange(e)} > - - - - + + + + - Age of heat generating system? + {this.props.AgeOfHeatGenerateSystem.question} this.handleInputChange(e)} > - - - - - - + + + + + +
- When do you plan to replace the heating system? + {this.props.planToReplaceHS.question} this.handleInputChange(e)} > - - - - - + + + + + @@ -166,13 +166,13 @@ class RemoteSurvey extends Component { this.handleInputChange(e)} > - - - - + + + + @@ -186,13 +186,13 @@ class RemoteSurvey extends Component { this.handleInputChange(e)} > - - - - + + + + @@ -214,13 +214,13 @@ class RemoteSurvey extends Component { this.handleInputChange(e)} > - - - - + + + + @@ -234,13 +234,13 @@ class RemoteSurvey extends Component { this.handleInputChange(e)} > - - - - + + + + @@ -251,109 +251,106 @@ class RemoteSurvey extends Component {
- Is the roof flat and easily accessible by a stairwell? + {this.props.accessibleByStairwell.question} this.handleInputChange(e)} > - - - - + + + + - Is the back facade of your building attached to - an adjacent building or structure? + {this.props.backFacadeAttached.question} this.handleInputChange(e)} > - - - - + + + +
- Are the exterior walls of your building attached to - an adjacent building or structure? + {this.props.exteriorWallsAttached.question} this.handleInputChange(e)} > - - - - - + + + + + - Any tenant complaints about comfort issues? (Temperature) + {this.props.tenantComplaintsComfort.question} this.handleInputChange(e)} > - - - - - + + + + +
- Any tenant complaints about drafty windows? + {this.props.tenantComplaintsWindows.question} this.handleInputChange(e)} > - - - - - + + + + + - Is the building directly metered for electricity - (tenants pay ConEd bills)? + {this.props.meteredForElectricity.question} this.handleInputChange(e)} > - - - - + + + +
@@ -146,10 +156,10 @@ class BuildingInfo extends Component {
Number of One Bedroom Apartment
- @@ -162,10 +172,10 @@ class BuildingInfo extends Component {
Number of Two Bedroom Apartment
- @@ -173,10 +183,10 @@ class BuildingInfo extends Component {
Number of Three Bedroom Apartment
- @@ -189,10 +199,10 @@ class BuildingInfo extends Component {
Number of Four Bedroom Apartment
- @@ -204,7 +214,7 @@ class BuildingInfo extends Component {
this.handleInputChange(e)} />
@@ -213,7 +223,7 @@ class BuildingInfo extends Component { type="select" name={'numOfOther'} inputName={'numOfOther'} - value={this.state.form.numOfOther} + value={this.state.form.unitInfo.numOfOther} onChange={e => this.handleInputChange(e)} > diff --git a/src/components/Ashp/ApartmentTypeDropdown.js b/src/components/Ashp/BuildingUnitDropdown.js similarity index 79% rename from src/components/Ashp/ApartmentTypeDropdown.js rename to src/components/Ashp/BuildingUnitDropdown.js index 564bc513..ca2c6df2 100644 --- a/src/components/Ashp/ApartmentTypeDropdown.js +++ b/src/components/Ashp/BuildingUnitDropdown.js @@ -5,11 +5,11 @@ import { } from 'reactstrap'; -class ApartmentTypeDropdown extends Component { +class BuildingUnitDropdown extends Component { constructor(props) { super(props); this.state = { - numOfApartment: props.numOfApartment, + numOfUnit: props.numOfUnit, }; } @@ -17,9 +17,9 @@ class ApartmentTypeDropdown extends Component { const val = event.target.value; // const name = event.target.name; this.setState({ - numOfApartment: val, + numOfUnit: val, }, () => { - this.props.onChange(this.props.inputName, this.state.numOfApartment); + this.props.onChange(this.props.inputName, this.state.numOfUnit); console.log('changed!'); // eslint-disable-line }); } @@ -31,7 +31,7 @@ class ApartmentTypeDropdown extends Component { this.handleInputChange(e)} > @@ -47,10 +47,10 @@ class ApartmentTypeDropdown extends Component { } } -ApartmentTypeDropdown.propTypes = { +BuildingUnitDropdown.propTypes = { inputName: PropTypes.string, - numOfApartment: PropTypes.number, + numOfUnit: PropTypes.number, onChange: PropTypes.func, }; -export default ApartmentTypeDropdown; +export default BuildingUnitDropdown; diff --git a/src/components/Ashp/FinancialInitial.js b/src/components/Ashp/FinancialInitial.js index 7236e369..ac588bb4 100644 --- a/src/components/Ashp/FinancialInitial.js +++ b/src/components/Ashp/FinancialInitial.js @@ -23,7 +23,11 @@ class FinanacialInitial extends Component { this.setState({ form: { ...this.state.form, - [name]: val, + [name]: { + question_id: this.state.form[name].question_id, + question: this.state.form[name].question, + answer_id: val, + }, }, }, () => { this.props.onChangeEvent('financialInitials', this.state.form); @@ -60,7 +64,7 @@ class FinanacialInitial extends Component { - +
diff --git a/src/components/Ashp/RemoteSurvey.js b/src/components/Ashp/RemoteSurvey.js index eacb05cd..dd2badfa 100644 --- a/src/components/Ashp/RemoteSurvey.js +++ b/src/components/Ashp/RemoteSurvey.js @@ -74,7 +74,7 @@ class RemoteSurvey extends Component { - + @@ -110,7 +110,7 @@ class RemoteSurvey extends Component { - + @@ -176,7 +176,7 @@ class RemoteSurvey extends Component { - + @@ -196,7 +196,7 @@ class RemoteSurvey extends Component { - + @@ -224,7 +224,7 @@ class RemoteSurvey extends Component { - + @@ -244,7 +244,7 @@ class RemoteSurvey extends Component { - + @@ -267,7 +267,7 @@ class RemoteSurvey extends Component { - + @@ -302,7 +302,7 @@ class RemoteSurvey extends Component { - + @@ -338,7 +338,7 @@ class RemoteSurvey extends Component { - + diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index e4c3fc66..eb82eeff 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -143,22 +143,27 @@ class Questionnaire extends Component { if (fieldData[0] === 'email' && !(validEmail.test(fieldData[1]))) { invalidFields.push(this.nameMapping[fieldData[0]]); } - if (fieldData[1] === '-1') { + if (typeof fieldData[1] === 'object' && + fieldData[1].answer_id !== undefined && + fieldData[1].answer_id === -1 && + fieldData[1].question_id !== 16) { emptyFields.push(this.nameMapping[fieldData[0]]); } }); } }); - if (emptyFields.length > 0 || invalidFields.length > 0) { - if (emptyFields.length > 0) { - errorMessage.push(`Please fill in ${emptyFields.join(', ')} field(s)`); - } - if (invalidFields.length > 0) { - errorMessage.push(`\nInvalid input in ${invalidFields.join(', ')} field(s)`); - } + + if (emptyFields.length > 0) { + errorMessage.push(`Please fill in ${emptyFields.join(', ')} field(s)`); alert(errorMessage); return false; } + if (invalidFields.length > 0) { + errorMessage.push(`\nInvalid input in ${invalidFields.join(', ')} field(s)`); + alert(errorMessage); + return false; + } + return true; } @@ -181,15 +186,6 @@ class Questionnaire extends Component { return `${addressItem}, ${building.borough}`; }); - let other = 'other'; - let numOfOther = 0; - Object.keys(buildingInfo.data.apartmentInfo).forEach(unitType => { - if (!['studio, one bedroom', 'two bedroom', 'three bedroom', 'four bedroom'].includes(unitType)) { - other = unitType; - numOfOther = buildingInfo.data.apartmentInfo[unitType]; - } - }); - const tableHeader = { paddingBottom: '20px', borderTop: '1px solid #CCCCCC', @@ -217,7 +213,6 @@ class Questionnaire extends Component { cursor: 'pointer', textDecoration: 'underline', }; - console.log(submittedAnswers.data.remoteSurvey); // eslint-disable-line let forms = ''; if (this.state.showReviewAnswers === false) { @@ -233,13 +228,13 @@ class Questionnaire extends Component { lastName={buildingInfo.data.lastName} email={buildingInfo.data.email} phone={buildingInfo.data.phone} - numOfStudio={buildingInfo.data.apartmentInfo.studio} - numOfOneBedroom={buildingInfo.data.apartmentInfo['one bedroom']} - numOfTwoBedroom={buildingInfo.data.apartmentInfo['two bedroom']} - numOfThreeBedroom={buildingInfo.data.apartmentInfo['three bedroom']} - numOfFourBedroom={buildingInfo.data.apartmentInfo['four bedroom']} - other={other} - numOfOther={numOfOther} + numOfStudio={buildingInfo.data.unitInfo.studio} + numOfOneBedroom={buildingInfo.data.unitInfo.oneBedroom} + numOfTwoBedroom={buildingInfo.data.unitInfo.twoBedroom} + numOfThreeBedroom={buildingInfo.data.unitInfo.threeBedroom} + numOfFourBedroom={buildingInfo.data.unitInfo.fourBedroom} + other={buildingInfo.data.unitInfo.other} + numOfOther={buildingInfo.data.unitInfo.numOfOther} onChangeEvent={this.onChangeEvent} /> -- GitLab From 72822087c5035f21fb2a78baaa1868da8192da69 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 21 Aug 2019 17:48:58 -0400 Subject: [PATCH 08/20] Fix submit button issue --- src/components/Ashp/BuildingInfo.js | 2 +- .../Ashp/ReviewAnswers/BuildingInfo.js | 13 +-- .../Ashp/ReviewAnswers/FinancialInitial.js | 32 ++++++- .../Ashp/ReviewAnswers/RemoteSurvey.js | 91 ++++++++++++++++--- src/components/Ashp/ReviewAnswers/index.js | 3 + src/containers/Questionnaire/index.js | 38 ++++---- src/containers/Questionnaire/reducer.js | 13 ++- src/containers/Questionnaire/sagas.js | 4 +- 8 files changed, 150 insertions(+), 46 deletions(-) diff --git a/src/components/Ashp/BuildingInfo.js b/src/components/Ashp/BuildingInfo.js index d0e08459..d262ed54 100644 --- a/src/components/Ashp/BuildingInfo.js +++ b/src/components/Ashp/BuildingInfo.js @@ -186,7 +186,7 @@ class BuildingInfo extends Component { diff --git a/src/components/Ashp/ReviewAnswers/BuildingInfo.js b/src/components/Ashp/ReviewAnswers/BuildingInfo.js index 3c8efa1d..9eec5cb0 100644 --- a/src/components/Ashp/ReviewAnswers/BuildingInfo.js +++ b/src/components/Ashp/ReviewAnswers/BuildingInfo.js @@ -16,6 +16,7 @@ const BuildingInfo = (props) => { ); }); + return (
- {this.props.bankruptyPast.question} + {this.props.bankruptcyPast.question} this.handleInputChange(e)} > @@ -154,12 +154,13 @@ class FinanacialInitial extends Component { FinanacialInitial.propTypes = { tableHeader: PropTypes.objectOf, - bankruptyPast: PropTypes.string, + bankruptcyPast: PropTypes.string, currentOnEnergyBills: PropTypes.string, currentMortgageBalance: PropTypes.string, profitable: PropTypes.string, budgetForDownPayment: PropTypes.string, onChangeEvent: PropTypes.func, + // answers: PropTypes.objectOf, }; export default FinanacialInitial; diff --git a/src/components/Ashp/RemoteSurvey.js b/src/components/Ashp/RemoteSurvey.js index 59e37dd1..eacb05cd 100644 --- a/src/components/Ashp/RemoteSurvey.js +++ b/src/components/Ashp/RemoteSurvey.js @@ -11,7 +11,7 @@ class RemoteSurvey extends Component { heatingSystem: props.heatingSystem, heatingFuelSource: props.heatingFuelSource, DHWSameBoiler: props.DHWSameBoiler, - AgeOfHeatGenerateSystem: props.AgeOfHeatGenerateSystem, + ageOfHeatGenerateSystem: props.ageOfHeatGenerateSystem, planToReplaceHS: props.planToReplaceHS, hallwaysHeated: props.hallwaysHeated, basementHeated: props.basementHeated, @@ -33,7 +33,11 @@ class RemoteSurvey extends Component { this.setState({ form: { ...this.state.form, - [name]: val, + [name]: { + question_id: this.state.form[name].question_id, + question: this.state.form[name].question, + answer_id: val, + }, }, }, () => { this.props.onChangeEvent('remoteSurvey', this.state.form); @@ -110,13 +114,13 @@ class RemoteSurvey extends Component { - {this.props.AgeOfHeatGenerateSystem.question} + {this.props.ageOfHeatGenerateSystem.question} this.handleInputChange(e)} > @@ -381,8 +385,9 @@ RemoteSurvey.propTypes = { tenantComplaintsWindows: PropTypes.string, tenantComplaintsComfort: PropTypes.string, meteredForElectricity: PropTypes.string, - AgeOfHeatGenerateSystem: PropTypes.string, + ageOfHeatGenerateSystem: PropTypes.string, onChangeEvent: PropTypes.func, + // answers: PropTypes.objectOf, }; export default RemoteSurvey; diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index d4219ab6..e4c3fc66 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -41,7 +41,7 @@ class Questionnaire extends Component { tenantComplaintsComfort: 'Tenant temperature complaints', tenantComplaintsWindows: 'Tenant window draft complaints', meteredForElectricity: 'ConEd Electricity Meter', - bankruptyPast: 'Past bankruptcy', + bankruptcyPast: 'Past bankruptcy', currentOnEnergyBills: 'Energy bills status', currentMortgageBalance: 'Outstanding mortgage balance', profitable: 'Building profit', @@ -72,24 +72,27 @@ class Questionnaire extends Component { } submitQuestionnaire = () => { - console.log(this.state); // eslint-disable-line - if (Object.keys(this.state.buildingInfo).length === 0) { - this.setState({ - buildingInfo: this.props.questionnaire.buildingInfo.data, - }); - } + const data = { + buildingInfo: Object.keys(this.state.buildingInfo).length > 0 ? + this.state.buildingInfo : + this.props.questionnaire.buildingInfo.data, + remoteSurvey: Object.keys(this.state.remoteSurvey).length > 0 ? + this.state.remoteSurvey : + this.props.questionnaire.submittedAnswers.data.remoteSurvey, + financialInitials: Object.keys(this.state.financialInitials).length > 0 ? + this.state.financialInitials : + this.props.questionnaire.submittedAnswers.data.financialInitials, + }; - if (this.validateInputs()) { - console.log(this.state); // eslint-disable-line - this.props.submitQuestionnaire(this.props.building.building_id, this.state); + if (this.validateInputs(data)) { + this.props.submitQuestionnaire(this.props.building.building_id, data); console.log('Saving answers!'); // eslint-disable-line - // console.log(this.state); // eslint-disable-line // this.setState({ // submitted: true, // showReviewAnswers: true, // }, () => { // console.log(this.state); // eslint-disable-line - // this.props.submitQuestionnaire(this.props.building.building_id, this.state); + // this.props.submitQuestionnaire(this.props.building.building_id, data); // console.log('Saving answers!'); // eslint-disable-line // }); } @@ -121,14 +124,14 @@ class Questionnaire extends Component { }); } - validateInputs() { + validateInputs(data) { const emptyFields = []; const invalidFields = []; const errorMessage = []; const validEmail = /^$|^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[A-Za-z]+$/; const validPhone = /^$|^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/; - Object.entries(this.state).forEach(formData => { + Object.entries(data).forEach(formData => { if (['buildingInfo', 'remoteSurvey', 'financialInitials'].includes(formData[0])) { Object.entries(formData[1]).forEach(fieldData => { if (fieldData[0] !== 'other' && fieldData[1].toString().replace(/^\s+|\s+$/g, '') === '') { @@ -215,7 +218,6 @@ class Questionnaire extends Component { textDecoration: 'underline', }; console.log(submittedAnswers.data.remoteSurvey); // eslint-disable-line - console.log(submittedAnswers.data.remoteSurvey['1']); // eslint-disable-line let forms = ''; if (this.state.showReviewAnswers === false) { @@ -247,21 +249,29 @@ class Questionnaire extends Component { @@ -271,11 +281,17 @@ class Questionnaire extends Component { @@ -343,9 +359,9 @@ class Questionnaire extends Component { reviewAnswers = ( ); editLink = ( -- GitLab From cbb8e2e04458b4b8afa53e6ac2ea1755e7f87e67 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 21 Aug 2019 15:03:16 -0400 Subject: [PATCH 07/20] Fix submit issue with frontend issu3s --- src/components/Ashp/BuildingInfo.js | 62 +++++++++++-------- ...ypeDropdown.js => BuildingUnitDropdown.js} | 16 ++--- src/components/Ashp/FinancialInitial.js | 10 ++- src/components/Ashp/RemoteSurvey.js | 30 ++++----- src/containers/Questionnaire/index.js | 45 ++++++-------- 5 files changed, 86 insertions(+), 77 deletions(-) rename src/components/Ashp/{ApartmentTypeDropdown.js => BuildingUnitDropdown.js} (79%) diff --git a/src/components/Ashp/BuildingInfo.js b/src/components/Ashp/BuildingInfo.js index 72cee3a7..d0e08459 100644 --- a/src/components/Ashp/BuildingInfo.js +++ b/src/components/Ashp/BuildingInfo.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Table, Input } from 'reactstrap'; -import ApartmentTypeDropdown from './ApartmentTypeDropdown'; +import BuildingUnitDropdown from './BuildingUnitDropdown'; class BuildingInfo extends Component { constructor(props) { @@ -12,14 +12,16 @@ class BuildingInfo extends Component { lastName: props.lastName, email: props.email, phone: props.phone, - numOfStudio: props.numOfStudio, - numOfOneBedroom: props.numOfOneBedroom, - numOfTwoBedroom: props.numOfTwoBedroom, - numOfThreeBedroom: props.numOfThreeBedroom, - numOfFourBedroom: props.numOfFourBedroom, - other: props.other, - numOfOther: props.numOfOther, address: props.address, + unitInfo: { + studio: props.numOfStudio, + oneBedroom: props.numOfOneBedroom, + twoBedroom: props.numOfTwoBedroom, + threeBedroom: props.numOfThreeBedroom, + fourBedroom: props.numOfFourBedroom, + other: props.other, + numOfOther: props.numOfOther, + }, }, }; } @@ -39,10 +41,18 @@ class BuildingInfo extends Component { } handleInputChangeSubComponent = (name, val) => { + const unitInfo = {}; + Object.entries(this.state.form.unitInfo).forEach(entry => { + if (entry[0] === name) { + unitInfo[name] = parseInt(val, 10); + } else { + unitInfo[entry[0]] = entry[1]; + } + }); this.setState({ form: { ...this.state.form, - [name]: parseInt(val, 10), + unitInfo, }, }, () => { this.props.onChangeEvent('buildingInfo', this.state.form); @@ -135,10 +145,10 @@ class BuildingInfo extends Component {
Number of Studio
-
@@ -79,7 +83,7 @@ class FinanacialInitial extends Component { - +
@@ -92,7 +92,7 @@ class RemoteSurvey extends Component { - +
@@ -120,7 +120,7 @@ class RemoteSurvey extends Component { this.handleInputChange(e)} > @@ -128,7 +128,7 @@ class RemoteSurvey extends Component { - +
@@ -283,7 +283,7 @@ class RemoteSurvey extends Component { - +
@@ -319,7 +319,7 @@ class RemoteSurvey extends Component { - +
@@ -354,7 +354,7 @@ class RemoteSurvey extends Component { - +
@@ -76,7 +77,7 @@ const BuildingInfo = (props) => { Number of Studio
- {props.data.numOfStudio} + {props.data.unitInfo.studio}
@@ -94,7 +95,7 @@ const BuildingInfo = (props) => { Number of Two Bedroom Apartment
- {props.data.numOfTwoBedroom} + {props.data.unitInfo.twoBedroom}
@@ -112,7 +113,7 @@ const BuildingInfo = (props) => { Number of Four Bedroom Apartment
- {props.data.numOfFourBedroom} + {props.data.unitInfo.fourBedroom}
diff --git a/src/components/Ashp/ReviewAnswers/FinancialInitial.js b/src/components/Ashp/ReviewAnswers/FinancialInitial.js index 70bab548..e8e9d3d3 100644 --- a/src/components/Ashp/ReviewAnswers/FinancialInitial.js +++ b/src/components/Ashp/ReviewAnswers/FinancialInitial.js @@ -9,6 +9,7 @@ const FinancialInitial = (props) => { fontWeight: 'bold', color: '#BBBBBB', }; + return (
@@ -84,7 +85,7 @@ const BuildingInfo = (props) => { Number of One Bedroom Apartment
- {props.data.numOfOneBedroom} + {props.data.unitInfo.OneBedroom}
@@ -102,7 +103,7 @@ const BuildingInfo = (props) => { Number of Three Bedroom Apartment
- {props.data.numOfThreeBedroom} + {props.data.unitInfo.threeBedroom}
@@ -120,7 +121,7 @@ const BuildingInfo = (props) => { Other Apartment
- {props.data.other} {props.data.numOfOther} + {props.data.unitInfo.other} {props.data.unitInfo.numOfOther}
@@ -23,7 +24,11 @@ const FinancialInitial = (props) => { Any bankruptcy in the past three years?
- {props.upperFirstLetter(props.data.bankruptyPast)} + { + props.upperFirstLetter( + props.answers[props.data.bankruptcyPast.answer_id] + ) + }
@@ -33,7 +38,11 @@ const FinancialInitial = (props) => { Current on energy bills?
- {props.upperFirstLetter(props.data.currentOnEnergyBills)} + { + props.upperFirstLetter( + props.answers[props.data.currentOnEnergyBills.answer_id] + ) + }
@@ -43,7 +52,11 @@ const FinancialInitial = (props) => { What is the current outstanding balance of the mortgage?
- {props.upperFirstLetter(props.data.currentMortgageBalance)} + { + props.upperFirstLetter( + props.answers[props.data.currentMortgageBalance.answer_id] + ) + }
@@ -53,7 +66,11 @@ const FinancialInitial = (props) => { Is your building currently profitable?
- {props.upperFirstLetter(props.data.profitable)} + { + props.upperFirstLetter( + props.answers[props.data.profitable.answer_id] + ) + }
@@ -63,7 +80,11 @@ const FinancialInitial = (props) => { What is your current budget for a down payment?
- {props.upperFirstLetter(props.data.budgetForDownPayment)} + { + props.upperFirstLetter( + props.answers[props.data.budgetForDownPayment.answer_id] + ) + }
@@ -77,6 +98,7 @@ FinancialInitial.propTypes = { title: PropTypes.string, data: PropTypes.objectOf, upperFirstLetter: PropTypes.func, + answers: PropTypes.objectOf, }; export default FinancialInitial; diff --git a/src/components/Ashp/ReviewAnswers/RemoteSurvey.js b/src/components/Ashp/ReviewAnswers/RemoteSurvey.js index c7bc75c8..04afeb1d 100644 --- a/src/components/Ashp/ReviewAnswers/RemoteSurvey.js +++ b/src/components/Ashp/ReviewAnswers/RemoteSurvey.js @@ -23,7 +23,11 @@ const RemoteSurvey = (props) => { Heating System
- {props.upperFirstLetter(props.data.heatingSystem)} + { + props.upperFirstLetter( + props.answers[props.data.heatingSystem.answer_id] + ) + }
@@ -41,7 +49,11 @@ const RemoteSurvey = (props) => { Is Domestic Hot Water (DHW) and heat prepared by the same boiler?
- {props.upperFirstLetter(props.data.DHWSameBoiler)} + { + props.upperFirstLetter( + props.answers[props.data.DHWSameBoiler.answer_id] + ) + }
@@ -51,7 +63,11 @@ const RemoteSurvey = (props) => { Age of heat generating system?
- {props.upperFirstLetter(props.data.AgeOfHeatGenerateSystem)} + { + props.upperFirstLetter( + props.answers[props.data.ageOfHeatGenerateSystem.answer_id] + ) + }
@@ -61,7 +77,11 @@ const RemoteSurvey = (props) => { When do you plan to replace the heating system?
- {props.upperFirstLetter(props.data.planToReplaceHS)} + { + props.upperFirstLetter( + props.answers[props.data.planToReplaceHS.answer_id] + ) + }
@@ -71,7 +91,11 @@ const RemoteSurvey = (props) => { Hallways heated?
- {props.upperFirstLetter(props.data.hallwaysHeated)} + { + props.upperFirstLetter( + props.answers[props.data.hallwaysHeated.answer_id] + ) + }
@@ -89,7 +117,11 @@ const RemoteSurvey = (props) => { Stairwells heated?
- {props.upperFirstLetter(props.data.stairwellsHeated)} + { + props.upperFirstLetter( + props.answers[props.data.stairwellsHeated.answer_id] + ) + }
@@ -107,7 +143,11 @@ const RemoteSurvey = (props) => { Is the roof flat and easily accessible by a stairwell?
- {props.upperFirstLetter(props.data.accessibleByStairwell)} + { + props.upperFirstLetter( + props.answers[props.data.accessibleByStairwell.answer_id] + ) + }
@@ -117,7 +157,11 @@ const RemoteSurvey = (props) => { Is the back facade of your building attached to an adjacent building or structure?
- {props.upperFirstLetter(props.data.backFacadeAttached)} + { + props.upperFirstLetter( + props.answers[props.data.backFacadeAttached.answer_id] + ) + }
@@ -127,7 +171,11 @@ const RemoteSurvey = (props) => { Are the exterior walls of your building attached to an adjacent building or structure?
- {props.upperFirstLetter(props.data.exteriorWallsAttached)} + { + props.upperFirstLetter( + props.answers[props.data.exteriorWallsAttached.answer_id] + ) + }
@@ -137,7 +185,11 @@ const RemoteSurvey = (props) => { Any tenant complaints about comfort issues? (Temperature)
- {props.upperFirstLetter(props.data.tenantComplaintsComfort)} + { + props.upperFirstLetter( + props.answers[props.data.tenantComplaintsComfort.answer_id] + ) + }
@@ -147,7 +199,11 @@ const RemoteSurvey = (props) => { Any tenant complaints about drafty windows?
- {props.upperFirstLetter(props.data.tenantComplaintsWindows)} + { + props.upperFirstLetter( + props.answers[props.data.tenantComplaintsWindows.answer_id] + ) + }
@@ -157,7 +213,11 @@ const RemoteSurvey = (props) => { Is the building directly metered for electricity (tenants pay ConEd bills)?
- {props.upperFirstLetter(props.data.meteredForElectricity)} + { + props.upperFirstLetter( + props.answers[props.data.meteredForElectricity.answer_id] + ) + }
@@ -171,6 +231,7 @@ RemoteSurvey.propTypes = { title: PropTypes.string, data: PropTypes.objectOf, upperFirstLetter: PropTypes.func, + answers: PropTypes.objectOf, }; export default RemoteSurvey; diff --git a/src/components/Ashp/ReviewAnswers/index.js b/src/components/Ashp/ReviewAnswers/index.js index 034b60b3..b939e10c 100644 --- a/src/components/Ashp/ReviewAnswers/index.js +++ b/src/components/Ashp/ReviewAnswers/index.js @@ -26,6 +26,7 @@ const ReviewAnswers = (props) => { tableHeader={props.tableHeader} title={'Remote Survey'} data={props.remoteSurvey} + answers={props.answers} upperFirstLetter={upperFirstLetter} /> @@ -34,6 +35,7 @@ const ReviewAnswers = (props) => { tableHeader={props.tableHeader} title={'Financial Initial Go/NoGo'} data={props.financialInitials} + answers={props.answers} upperFirstLetter={upperFirstLetter} /> @@ -47,6 +49,7 @@ ReviewAnswers.propTypes = { buildingInfo: PropTypes.objectOf, remoteSurvey: PropTypes.objectOf, financialInitials: PropTypes.objectOf, + answers: PropTypes.objectOf, }; export default ReviewAnswers; diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index eb82eeff..81dd558a 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -52,8 +52,6 @@ class Questionnaire extends Component { remoteSurvey: {}, financialInitials: {}, showReviewAnswers: false, - submitted: false, - calculated: false, }; } @@ -85,16 +83,13 @@ class Questionnaire extends Component { }; if (this.validateInputs(data)) { + // this.props.submitQuestionnaire(this.props.building.building_id, data); + // console.log('Saving answers!'); // eslint-disable-line this.props.submitQuestionnaire(this.props.building.building_id, data); - console.log('Saving answers!'); // eslint-disable-line - // this.setState({ - // submitted: true, - // showReviewAnswers: true, - // }, () => { - // console.log(this.state); // eslint-disable-line - // this.props.submitQuestionnaire(this.props.building.building_id, data); - // console.log('Saving answers!'); // eslint-disable-line - // }); + this.setState({ + submitted: true, + showReviewAnswers: true, + }); } return false; } @@ -176,12 +171,22 @@ class Questionnaire extends Component { const { buildingInfo, submittedAnswers, + answers, + submitted, + calculated, } = questionnaire; if (buildingInfo.data !== undefined && buildingInfo.data !== null && submittedAnswers.data !== undefined && submittedAnswers.data !== null && building !== undefined) { + console.log(questionnaire); // eslint-disable-line + console.log(submittedAnswers.data); // eslint-disable-line + console.log(submittedAnswers.data.remoteSurvey); // eslint-disable-line + console.log(submittedAnswers.data.financialInitials); // eslint-disable-line + console.log(submitted); // eslint-disable-line + console.log(calculated); // eslint-disable-line + const address = building.street_address.map(addressItem => { return `${addressItem}, ${building.borough}`; }); @@ -215,7 +220,7 @@ class Questionnaire extends Component { }; let forms = ''; - if (this.state.showReviewAnswers === false) { + if (submitted === false) { forms = (
@@ -298,7 +303,7 @@ class Questionnaire extends Component { let message = ''; let editLink = ''; let submitButton = ''; - if (this.state.showReviewAnswers === false) { + if (submitted === false) { submitButton = (
this.handleInputChange(e)} + onChange={e => this.handleOtherInputChange(e)} > diff --git a/src/components/Ashp/ReviewAnswers/BuildingInfo.js b/src/components/Ashp/ReviewAnswers/BuildingInfo.js index 9eec5cb0..d7671691 100644 --- a/src/components/Ashp/ReviewAnswers/BuildingInfo.js +++ b/src/components/Ashp/ReviewAnswers/BuildingInfo.js @@ -9,13 +9,17 @@ const BuildingInfo = (props) => { fontWeight: 'bold', color: '#CCCCCC', }; - const address = props.data.address.map(addressItem => { - return ( -
- {addressItem} -
- ); - }); + + let address = props.data.address; // eslint-disable-line + if (Array.isArray(props.data.address)) { + address = props.data.address.map(addressItem => { + return ( +
+ {addressItem} +
+ ); + }); + } return (
diff --git a/src/containers/Questionnaire/actions.js b/src/containers/Questionnaire/actions.js index 97387abc..e828ca4d 100644 --- a/src/containers/Questionnaire/actions.js +++ b/src/containers/Questionnaire/actions.js @@ -5,6 +5,8 @@ import { SUBMIT_QUESTIONNAIRE_REQUESTED, SUBMIT_QUESTIONNAIRE_SUCCEEDED, SUBMIT_QUESTIONNAIRE_FAILED, + EDIT_QUESTIONNAIRE_REQUESTED, + EDIT_QUESTIONNAIRE_SUCCEEDED, CALCULATE_COST_REQUESTED, CALCULATE_COST_SUCCEEDED, CALCULATE_COST_FAILED, @@ -24,6 +26,9 @@ export const submitQuestionnaire = makeActionCreator(SUBMIT_QUESTIONNAIRE_REQUES export const submitQuestionnaireSucceeded = makeActionCreator(SUBMIT_QUESTIONNAIRE_SUCCEEDED, 'instance'); export const submitQuestionnaireFailed = makeActionCreator(SUBMIT_QUESTIONNAIRE_FAILED, 'error'); +export const editQuestionnaire = makeActionCreator(EDIT_QUESTIONNAIRE_REQUESTED, 'buildingId', 'payload'); +export const editQuestionnaireSucceeded = makeActionCreator(EDIT_QUESTIONNAIRE_SUCCEEDED, 'instance'); + export const calculateCost = makeActionCreator(CALCULATE_COST_REQUESTED, 'buildingId', 'id'); export const calculateCostSucceeded = makeActionCreator(CALCULATE_COST_SUCCEEDED, 'id'); export const calculateCostFailed = makeActionCreator(CALCULATE_COST_FAILED, 'id', 'error'); diff --git a/src/containers/Questionnaire/constants.js b/src/containers/Questionnaire/constants.js index 1f1286de..774531af 100644 --- a/src/containers/Questionnaire/constants.js +++ b/src/containers/Questionnaire/constants.js @@ -6,6 +6,9 @@ export const SUBMIT_QUESTIONNAIRE_REQUESTED = 'SUBMIT_QUESTIONNAIRE_REQUESTED'; export const SUBMIT_QUESTIONNAIRE_SUCCEEDED = 'SUBMIT_QUESTIONNAIRE_SUCCEEDED'; export const SUBMIT_QUESTIONNAIRE_FAILED = 'SUBMIT_QUESTIONNAIRE_FAILED'; +export const EDIT_QUESTIONNAIRE_REQUESTED = 'EDIT_QUESTIONNAIRE_REQUESTED'; +export const EDIT_QUESTIONNAIRE_SUCCEEDED = 'EDIT_QUESTIONNAIRE_SUCCEEDED'; + export const CALCULATE_COST_REQUESTED = 'CALCULATE_COST_REQUESTED'; export const CALCULATE_COST_SUCCEEDED = 'CALCULATE_COST_SUCCEEDED'; export const CALCULATE_COST_FAILED = 'CALCULATE_COST_FAILED'; diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 81dd558a..0651abba 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -8,6 +8,7 @@ import buildingDetailPropTypes from '../Building/propTypes'; import { loadQuestionnaire, submitQuestionnaire, + editQuestionnaire, calculateCost, downloadReport, } from './actions'; @@ -83,8 +84,6 @@ class Questionnaire extends Component { }; if (this.validateInputs(data)) { - // this.props.submitQuestionnaire(this.props.building.building_id, data); - // console.log('Saving answers!'); // eslint-disable-line this.props.submitQuestionnaire(this.props.building.building_id, data); this.setState({ submitted: true, @@ -112,11 +111,9 @@ class Questionnaire extends Component { } editForm = () => { - this.setState({ - showReviewAnswers: false, - submitted: false, - calculated: false, - }); + this.props.editQuestionnaire( + this.props.building.building_id, this.props.questionnaire + ); } validateInputs(data) { @@ -179,14 +176,7 @@ class Questionnaire extends Component { if (buildingInfo.data !== undefined && buildingInfo.data !== null && submittedAnswers.data !== undefined && submittedAnswers.data !== null && building !== undefined) { - console.log(questionnaire); // eslint-disable-line - console.log(submittedAnswers.data); // eslint-disable-line - console.log(submittedAnswers.data.remoteSurvey); // eslint-disable-line - console.log(submittedAnswers.data.financialInitials); // eslint-disable-line - console.log(submitted); // eslint-disable-line - console.log(calculated); // eslint-disable-line - const address = building.street_address.map(addressItem => { return `${addressItem}, ${building.borough}`; }); @@ -409,6 +399,7 @@ Questionnaire.propTypes = { building: buildingDetailPropTypes, loadQuestionnaire: PropTypes.func, submitQuestionnaire: PropTypes.func, + editQuestionnaire: PropTypes.func, questionnaire: PropTypes.objectOf, }; @@ -416,6 +407,7 @@ const mapDispatchToProps = dispatch => ( bindActionCreators({ loadQuestionnaire, submitQuestionnaire, + editQuestionnaire, calculateCost, downloadReport, }, dispatch) diff --git a/src/containers/Questionnaire/reducer.js b/src/containers/Questionnaire/reducer.js index 62519bfd..3b73009c 100644 --- a/src/containers/Questionnaire/reducer.js +++ b/src/containers/Questionnaire/reducer.js @@ -5,6 +5,8 @@ import { SUBMIT_QUESTIONNAIRE_REQUESTED, SUBMIT_QUESTIONNAIRE_SUCCEEDED, SUBMIT_QUESTIONNAIRE_FAILED, + EDIT_QUESTIONNAIRE_REQUESTED, + EDIT_QUESTIONNAIRE_SUCCEEDED, CALCULATE_COST_REQUESTED, CALCULATE_COST_SUCCEEDED, CALCULATE_COST_FAILED, @@ -48,8 +50,6 @@ export default function (state = questionnaireInitialState, action) { }; case LOAD_QUESTIONNAIRE_SUCCEEDED: - console.log(questionnaireInitialState); // eslint-disable-line - console.log(action); // eslint-disable-line return { ...state, buildingInfo: { @@ -126,6 +126,41 @@ export default function (state = questionnaireInitialState, action) { }, }; + case EDIT_QUESTIONNAIRE_REQUESTED: + return { + ...state, + buildingInfo: { + ...state.buildingInfo, + loading: true, + error: false, + }, + submittedAnswers: { + ...state.submittedAnswers, + loading: true, + error: false, + }, + }; + + case EDIT_QUESTIONNAIRE_SUCCEEDED: + return { + ...state, + buildingInfo: { + data: action.instance.buildingInfo.data, + loading: false, + error: false, + }, + submittedAnswers: { + data: { + remoteSurvey: action.instance.submittedAnswers.data.remoteSurvey, + financialInitials: action.instance.submittedAnswers.data.financialInitials, + }, + loading: false, + error: false, + }, + answers: {}, + submitted: false, + }; + case CALCULATE_COST_REQUESTED: return { ...state, diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index bd9986e8..d29791ad 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -5,6 +5,7 @@ import request from '../../utils/request'; import { LOAD_QUESTIONNAIRE_REQUESTED, SUBMIT_QUESTIONNAIRE_REQUESTED, + EDIT_QUESTIONNAIRE_REQUESTED, CALCULATE_COST_REQUESTED, DOWNLOAD_REPORT_REQUESTED, } from './constants'; @@ -14,6 +15,7 @@ import { loadQuestionnaireLFailed, submitQuestionnaireSucceeded, submitQuestionnaireFailed, + editQuestionnaireSucceeded, calculateCostSucceeded, calculateCostFailed, downloadReportSucceeded, @@ -28,7 +30,6 @@ function* loadQuestionnaire(action) { yield SagaRequests.get(action, url, loadQuestionnaireSucceeded, loadQuestionnaireLFailed); } - function* submitQuestionnaire(action) { console.log(action); // eslint-disable-line const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/questionnaire/`; @@ -51,6 +52,11 @@ function* submitQuestionnaire(action) { } } +function* editQuestionnaire(action) { + console.log(action); // eslint-disable-line + yield put(editQuestionnaireSucceeded(action.payload)); +} + function* calculateCost(action) { const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/calculate/`; yield SagaRequests.get(action, url, calculateCostSucceeded, calculateCostFailed); @@ -61,11 +67,12 @@ function* downloadReport(action) { yield SagaRequests.get(action, url, downloadReportSucceeded, downloadReportFailed); } -function* engWatcher() { +function* questionnaireWatcher() { yield takeEvery(LOAD_QUESTIONNAIRE_REQUESTED, loadQuestionnaire); yield takeEvery(SUBMIT_QUESTIONNAIRE_REQUESTED, submitQuestionnaire); + yield takeEvery(EDIT_QUESTIONNAIRE_REQUESTED, editQuestionnaire); yield takeEvery(CALCULATE_COST_REQUESTED, calculateCost); yield takeEvery(DOWNLOAD_REPORT_REQUESTED, downloadReport); } -export default engWatcher; +export default questionnaireWatcher; -- GitLab From a4e8d64fc68ddf5c3420db6784c89da676cd4d7e Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 21 Aug 2019 19:08:26 -0400 Subject: [PATCH 10/20] Add calculate and download buttons feature --- src/containers/Questionnaire/actions.js | 6 +++--- src/containers/Questionnaire/index.js | 24 ++++++------------------ src/containers/Questionnaire/sagas.js | 2 -- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/containers/Questionnaire/actions.js b/src/containers/Questionnaire/actions.js index e828ca4d..7ba76557 100644 --- a/src/containers/Questionnaire/actions.js +++ b/src/containers/Questionnaire/actions.js @@ -29,9 +29,9 @@ export const submitQuestionnaireFailed = makeActionCreator(SUBMIT_QUESTIONNAIRE_ export const editQuestionnaire = makeActionCreator(EDIT_QUESTIONNAIRE_REQUESTED, 'buildingId', 'payload'); export const editQuestionnaireSucceeded = makeActionCreator(EDIT_QUESTIONNAIRE_SUCCEEDED, 'instance'); -export const calculateCost = makeActionCreator(CALCULATE_COST_REQUESTED, 'buildingId', 'id'); -export const calculateCostSucceeded = makeActionCreator(CALCULATE_COST_SUCCEEDED, 'id'); -export const calculateCostFailed = makeActionCreator(CALCULATE_COST_FAILED, 'id', 'error'); +export const calculateCost = makeActionCreator(CALCULATE_COST_REQUESTED, 'buildingId'); +export const calculateCostSucceeded = makeActionCreator(CALCULATE_COST_SUCCEEDED, 'instance'); +export const calculateCostFailed = makeActionCreator(CALCULATE_COST_FAILED, 'error'); export const downloadReport = makeActionCreator(DOWNLOAD_REPORT_REQUESTED, 'buildingId'); export const downloadReportSucceeded = makeActionCreator(DOWNLOAD_REPORT_SUCCEEDED, 'payload'); diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 0651abba..d744a8fa 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -52,7 +52,6 @@ class Questionnaire extends Component { buildingInfo: {}, remoteSurvey: {}, financialInitials: {}, - showReviewAnswers: false, }; } @@ -85,29 +84,16 @@ class Questionnaire extends Component { if (this.validateInputs(data)) { this.props.submitQuestionnaire(this.props.building.building_id, data); - this.setState({ - submitted: true, - showReviewAnswers: true, - }); } return false; } - calculate = () => { - this.setState({ - submitted: false, - calculated: true, - }, () => { - console.log('Calculated!'); // eslint-disable-line - }); + calculateCost = () => { + this.props.calculateCost(this.props.building.building_id); } downloadReport = () => { - this.setState({ - calculated: false, - }, () => { - console.log('Dowmloaded!'); // eslint-disable-line - }); + this.props.downloadReport(this.props.building.building_id); } editForm = () => { @@ -311,7 +297,7 @@ class Questionnaire extends Component { {' '} @@ -400,6 +386,8 @@ Questionnaire.propTypes = { loadQuestionnaire: PropTypes.func, submitQuestionnaire: PropTypes.func, editQuestionnaire: PropTypes.func, + calculateCost: PropTypes.func, + downloadReport: PropTypes.func, questionnaire: PropTypes.objectOf, }; diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index d29791ad..b7179064 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -44,8 +44,6 @@ function* submitQuestionnaire(action) { ); if (!res.err) { - console.log(res); // eslint-disable-line - console.log(action); // eslint-disable-line yield put(submitQuestionnaireSucceeded(Object.assign({}, res, action.payload))); } else { yield put(submitQuestionnaireFailed(res.err)); -- GitLab From 26aa1be5bc5f2c17d78c93546cab80294778e05b Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 21 Aug 2019 19:40:27 -0400 Subject: [PATCH 11/20] Fix download and calculate button bugs --- src/containers/Questionnaire/index.js | 7 ++++--- src/containers/Questionnaire/reducer.js | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index d744a8fa..e57002c4 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -196,7 +196,7 @@ class Questionnaire extends Component { }; let forms = ''; - if (submitted === false) { + if (submitted === false && calculated === false) { forms = (
@@ -279,7 +279,7 @@ class Questionnaire extends Component { let message = ''; let editLink = ''; let submitButton = ''; - if (submitted === false) { + if (submitted === false && calculated === false) { submitButton = (
- {props.data.unitInfo.OneBedroom} + {props.data.unitInfo.oneBedroom}
-- GitLab From 19661f8c932e60834e9c74cc96b545aab65026f6 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 09:52:10 -0400 Subject: [PATCH 13/20] Made review answers components responsive --- src/components/Ashp/ReviewAnswers/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/Ashp/ReviewAnswers/index.js b/src/components/Ashp/ReviewAnswers/index.js index b939e10c..b83b0223 100644 --- a/src/components/Ashp/ReviewAnswers/index.js +++ b/src/components/Ashp/ReviewAnswers/index.js @@ -1,4 +1,5 @@ import React from 'react'; +import { Row, Col } from 'reactstrap'; import PropTypes from 'prop-types'; import BuildingInfo from './BuildingInfo'; import RemoteSurvey from './RemoteSurvey'; @@ -12,16 +13,16 @@ const ReviewAnswers = (props) => { return (
-
-
+ +
- -
+ +
{ answers={props.answers} upperFirstLetter={upperFirstLetter} /> - -
+ +
{ answers={props.answers} upperFirstLetter={upperFirstLetter} /> - - + + ); }; -- GitLab From edb8ecf90ded73f9a8408d517bede42691e977f6 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 10:45:20 -0400 Subject: [PATCH 14/20] Change component folder name to make container folder name, fix empty other field issue --- .../{Ashp => Questionnaire}/BuildingInfo.js | 1 + .../BuildingUnitDropdown.js | 0 .../{Ashp => Questionnaire}/FinancialInitial.js | 0 .../{Ashp => Questionnaire}/RemoteSurvey.js | 14 +++++++------- .../ReviewAnswers/BuildingInfo.js | 0 .../ReviewAnswers/FinancialInitial.js | 0 .../ReviewAnswers/RemoteSurvey.js | 0 .../{Ashp => Questionnaire}/ReviewAnswers/index.js | 0 src/containers/Questionnaire/index.js | 8 ++++---- 9 files changed, 12 insertions(+), 11 deletions(-) rename src/components/{Ashp => Questionnaire}/BuildingInfo.js (99%) rename src/components/{Ashp => Questionnaire}/BuildingUnitDropdown.js (100%) rename src/components/{Ashp => Questionnaire}/FinancialInitial.js (100%) rename src/components/{Ashp => Questionnaire}/RemoteSurvey.js (97%) rename src/components/{Ashp => Questionnaire}/ReviewAnswers/BuildingInfo.js (100%) rename src/components/{Ashp => Questionnaire}/ReviewAnswers/FinancialInitial.js (100%) rename src/components/{Ashp => Questionnaire}/ReviewAnswers/RemoteSurvey.js (100%) rename src/components/{Ashp => Questionnaire}/ReviewAnswers/index.js (100%) diff --git a/src/components/Ashp/BuildingInfo.js b/src/components/Questionnaire/BuildingInfo.js similarity index 99% rename from src/components/Ashp/BuildingInfo.js rename to src/components/Questionnaire/BuildingInfo.js index 585ec813..2dbd4187 100644 --- a/src/components/Ashp/BuildingInfo.js +++ b/src/components/Questionnaire/BuildingInfo.js @@ -230,6 +230,7 @@ class BuildingInfo extends Component {
this.handleOtherInputChange(e)} /> diff --git a/src/components/Ashp/BuildingUnitDropdown.js b/src/components/Questionnaire/BuildingUnitDropdown.js similarity index 100% rename from src/components/Ashp/BuildingUnitDropdown.js rename to src/components/Questionnaire/BuildingUnitDropdown.js diff --git a/src/components/Ashp/FinancialInitial.js b/src/components/Questionnaire/FinancialInitial.js similarity index 100% rename from src/components/Ashp/FinancialInitial.js rename to src/components/Questionnaire/FinancialInitial.js diff --git a/src/components/Ashp/RemoteSurvey.js b/src/components/Questionnaire/RemoteSurvey.js similarity index 97% rename from src/components/Ashp/RemoteSurvey.js rename to src/components/Questionnaire/RemoteSurvey.js index dd2badfa..f1bfc3e3 100644 --- a/src/components/Ashp/RemoteSurvey.js +++ b/src/components/Questionnaire/RemoteSurvey.js @@ -281,9 +281,10 @@ class RemoteSurvey extends Component { onChange={e => this.handleInputChange(e)} > - - - + + + + @@ -316,10 +317,9 @@ class RemoteSurvey extends Component { onChange={e => this.handleInputChange(e)} > - - - - + + + diff --git a/src/components/Ashp/ReviewAnswers/BuildingInfo.js b/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js similarity index 100% rename from src/components/Ashp/ReviewAnswers/BuildingInfo.js rename to src/components/Questionnaire/ReviewAnswers/BuildingInfo.js diff --git a/src/components/Ashp/ReviewAnswers/FinancialInitial.js b/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js similarity index 100% rename from src/components/Ashp/ReviewAnswers/FinancialInitial.js rename to src/components/Questionnaire/ReviewAnswers/FinancialInitial.js diff --git a/src/components/Ashp/ReviewAnswers/RemoteSurvey.js b/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js similarity index 100% rename from src/components/Ashp/ReviewAnswers/RemoteSurvey.js rename to src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js diff --git a/src/components/Ashp/ReviewAnswers/index.js b/src/components/Questionnaire/ReviewAnswers/index.js similarity index 100% rename from src/components/Ashp/ReviewAnswers/index.js rename to src/components/Questionnaire/ReviewAnswers/index.js diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index e57002c4..a30c51a5 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -13,10 +13,10 @@ import { downloadReport, } from './actions'; import LinkBarDetail from '../../components/LinkBarDetail'; -import BuildingInfo from '../../components/Ashp/BuildingInfo'; -import FinancialInitial from '../../components/Ashp/FinancialInitial'; -import RemoteSurvey from '../../components/Ashp/RemoteSurvey'; -import ReviewAnswers from '../../components/Ashp/ReviewAnswers'; +import BuildingInfo from '../../components/Questionnaire/BuildingInfo'; +import FinancialInitial from '../../components/Questionnaire/FinancialInitial'; +import RemoteSurvey from '../../components/Questionnaire/RemoteSurvey'; +import ReviewAnswers from '../../components/Questionnaire/ReviewAnswers'; class Questionnaire extends Component { -- GitLab From 7c6a90355b5fbd75a516c464072ff789bccaf2e7 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 10:51:20 -0400 Subject: [PATCH 15/20] Fix special character issue --- src/components/Questionnaire/RemoteSurvey.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Questionnaire/RemoteSurvey.js b/src/components/Questionnaire/RemoteSurvey.js index f1bfc3e3..e3f4cf12 100644 --- a/src/components/Questionnaire/RemoteSurvey.js +++ b/src/components/Questionnaire/RemoteSurvey.js @@ -317,8 +317,8 @@ class RemoteSurvey extends Component { onChange={e => this.handleInputChange(e)} > - - + + -- GitLab From 906595316a9e82bf0d012919d9ebb6dc57dceead Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 14:41:41 -0400 Subject: [PATCH 16/20] Updates on submit button --- src/containers/Questionnaire/index.js | 9 +++++---- src/containers/Questionnaire/sagas.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index a30c51a5..b28714c7 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -10,7 +10,7 @@ import { submitQuestionnaire, editQuestionnaire, calculateCost, - downloadReport, + // downloadReport, } from './actions'; import LinkBarDetail from '../../components/LinkBarDetail'; import BuildingInfo from '../../components/Questionnaire/BuildingInfo'; @@ -93,7 +93,8 @@ class Questionnaire extends Component { } downloadReport = () => { - this.props.downloadReport(this.props.building.building_id); + window.open('http://0.0.0.0:5410/buildings/12345/pna/report/download/', '_blank'); + // this.props.downloadReport(this.props.building.building_id); } editForm = () => { @@ -388,7 +389,7 @@ Questionnaire.propTypes = { submitQuestionnaire: PropTypes.func, editQuestionnaire: PropTypes.func, calculateCost: PropTypes.func, - downloadReport: PropTypes.func, + // downloadReport: PropTypes.func, questionnaire: PropTypes.objectOf, }; @@ -398,7 +399,7 @@ const mapDispatchToProps = dispatch => ( submitQuestionnaire, editQuestionnaire, calculateCost, - downloadReport, + // downloadReport, }, dispatch) ); diff --git a/src/containers/Questionnaire/sagas.js b/src/containers/Questionnaire/sagas.js index b7179064..99cc3eb0 100644 --- a/src/containers/Questionnaire/sagas.js +++ b/src/containers/Questionnaire/sagas.js @@ -56,12 +56,12 @@ function* editQuestionnaire(action) { } function* calculateCost(action) { - const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/calculate/`; + const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/report/generate/`; yield SagaRequests.get(action, url, calculateCostSucceeded, calculateCostFailed); } function* downloadReport(action) { - const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/download-report/`; + const url = `${process.env.REACT_APP_BLOCLINK_URL}/buildings/${action.buildingId}/pna/report/download/`; yield SagaRequests.get(action, url, downloadReportSucceeded, downloadReportFailed); } -- GitLab From e430a8ac399b73fbc118a76de4aa9f00e3a4e9fa Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 16:17:30 -0400 Subject: [PATCH 17/20] Update download report URi --- src/containers/Questionnaire/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index b28714c7..01d44aa4 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -93,8 +93,7 @@ class Questionnaire extends Component { } downloadReport = () => { - window.open('http://0.0.0.0:5410/buildings/12345/pna/report/download/', '_blank'); - // this.props.downloadReport(this.props.building.building_id); + window.open(`${process.env.REACT_APP_BLOCLINK_URL}/buildings/${this.props.building.building_id}/pna/report/download/`, '_blank'); } editForm = () => { -- GitLab From 931409286263051c2f51405d78a475d81a3f88a1 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 22 Aug 2019 17:36:53 -0400 Subject: [PATCH 18/20] Update submit, calculate states --- src/containers/Questionnaire/index.js | 14 ++++++++------ src/containers/Questionnaire/reducer.js | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 01d44aa4..6b2d4d11 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -183,10 +183,12 @@ class Questionnaire extends Component { }; const successMsgStyle = { - padding: '15px 50px 15px 50px', - border: '2px solid #CCCCCC', - marginBottom: '20px', + padding: '25px 50px 25px 50px', + border: '4px solid #CCCCCC', + marginBottom: '25px', background: '#B8DFC2', + fontWeight: 'bold', + borderRadius: '5px', }; const editStyle = { @@ -291,7 +293,7 @@ class Questionnaire extends Component { } let calculateButton = ''; - if (submitted === true) { + if (submitted === true && calculated === false) { calculateButton = ( {' '} @@ -305,7 +307,7 @@ class Questionnaire extends Component { ); message = (
- Successfully submitted. + ⚑  Your questionnaire has been submitted.
); } @@ -325,7 +327,7 @@ class Questionnaire extends Component { ); message = (
- Calculation completed. + ✔  Your report is ready.
); } diff --git a/src/containers/Questionnaire/reducer.js b/src/containers/Questionnaire/reducer.js index ac536d91..651cbf2c 100644 --- a/src/containers/Questionnaire/reducer.js +++ b/src/containers/Questionnaire/reducer.js @@ -62,6 +62,9 @@ export default function (state = questionnaireInitialState, action) { loading: false, error: false, }, + answers: action.instance.answers, + submitted: action.instance.submitted, + calculated: action.instance.calculated, }; case LOAD_QUESTIONNAIRE_FAILED: -- GitLab From a92341c8f2b4b9fb30f2c99aae5f37f6db588c6e Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 26 Aug 2019 11:02:02 -0400 Subject: [PATCH 19/20] Added seperated dropdown for Q-5 --- src/components/Questionnaire/RemoteSurvey.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Questionnaire/RemoteSurvey.js b/src/components/Questionnaire/RemoteSurvey.js index e3f4cf12..fface7fd 100644 --- a/src/components/Questionnaire/RemoteSurvey.js +++ b/src/components/Questionnaire/RemoteSurvey.js @@ -147,7 +147,8 @@ class RemoteSurvey extends Component { - + +
@@ -31,7 +35,11 @@ const RemoteSurvey = (props) => { Heating Fuel Source
- {props.upperFirstLetter(props.data.heatingFuelSource)} + { + props.upperFirstLetter( + props.answers[props.data.heatingFuelSource.answer_id] + ) + }
@@ -79,7 +103,11 @@ const RemoteSurvey = (props) => { Basement heated?
- {props.upperFirstLetter(props.data.basementHeated)} + { + props.upperFirstLetter( + props.answers[props.data.basementHeated.answer_id] + ) + }
@@ -97,7 +129,11 @@ const RemoteSurvey = (props) => { Floors heated?
- {props.upperFirstLetter(props.data.floorsHeated)} + { + props.upperFirstLetter( + props.answers[props.data.floorsHeated.answer_id] + ) + }
-- GitLab From 6b869a1eed054a1bce2e7fe095443d1efdeaae85 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 26 Aug 2019 11:58:06 -0400 Subject: [PATCH 20/20] Dropdown fix --- src/components/Questionnaire/RemoteSurvey.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Questionnaire/RemoteSurvey.js b/src/components/Questionnaire/RemoteSurvey.js index fface7fd..8cf65b7b 100644 --- a/src/components/Questionnaire/RemoteSurvey.js +++ b/src/components/Questionnaire/RemoteSurvey.js @@ -148,7 +148,7 @@ class RemoteSurvey extends Component { - + -- GitLab