diff --git a/src/App.js b/src/App.js index a93264a2dd19c52991b2aed5f2a8f7a4fae2ee86..44db54049b59b71471ea42ebb6008167f4ab493b 100644 --- a/src/App.js +++ b/src/App.js @@ -8,7 +8,8 @@ import HeatDistribution from './HeatDistribution'; import SeparateBoiler from './SeparateBoiler'; import HeatingSystemAge from './HeatingSystemAge'; import HeatingSystemPlan from './HeatingSystemPlan'; -import UnitBreakdown from './UnitBreakdown' +import UnitBreakdown from './UnitBreakdown'; +import Feedback from './Feedback'; import BuildingTypes from './BuildingTypes'; import UtilityBills from './UtilityBills'; import ComfortIssues from './ComfortIssues'; @@ -183,7 +184,7 @@ class App extends React.Component { value: 0, answerIds: [1, 2], prev: '', - next: 'contact', + next: 'feedback', }, waitList: { id: 10, @@ -192,11 +193,18 @@ class App extends React.Component { value: 0, answerIds: [1, 2], prev: 'buildingTypes', + next: 'feedback', + }, + feedback: { + questionIds: [58], + title: 'How did you hear about us?', + answers: '', + prev: '', next: 'contact', }, contact: { title: 'Your Information', - prev: '', + prev: 'feedback', next: 'reviewAnswers', }, reviewAnswers: { @@ -613,7 +621,7 @@ class App extends React.Component { }, ], prev: 'buildingPastImprovement', - next: 'contact', + next: 'feedback', } }; } @@ -642,13 +650,12 @@ class App extends React.Component { questionAnswers[questions[question].id] = value; } - questions.financeInterest.next = "contact"; this.setState({ questions }, () => { if (question === 'addressSearch') { this.props.onSubmitBuilding({ address: this.state.questions[question].value, }); - } else if (question === 'unitBreakdown'){ + } else if (question === 'unitBreakdown' || question === 'feedback'){ this.setQuestion(this.state.questions[question].next); this.props.onSubmitUserAnswer({ questionId: questions[question]['questionIds'], @@ -701,21 +708,21 @@ class App extends React.Component { let questions = this.state.questions; // If the current question is financeInterset set financeInterset as prev page for contact if (this.props.building.data.surveyId === 1 && question === 'financeInterest') { - questions['contact'].prev = 'financeInterest'; + questions['feedback'].prev = 'financeInterest'; this.setState({ questions, }); } // If the current question is waitList set waitList as prev page for contact if (this.props.building.data.surveyId === 1 && question === 'waitList') { - questions['contact'].prev = 'waitList'; + questions['feedback'].prev = 'waitList'; this.setState({ questions, }); } // If the survey ID is 2 or 3, set buildingFutureWaterImprovement as prev page for contact if ([2, 3].includes(this.props.building.data.surveyId) && question === 'buildingNeeds') { - questions['contact'].prev = 'buildingFutureImprovement'; + questions['feedback'].prev = 'buildingFutureImprovement'; this.setState({ questions, }); @@ -806,7 +813,6 @@ class App extends React.Component { questions['utilityBills'].questions[1].answer = ''; questions['utilityBills'].questions[0].value = 0; questions['utilityBills'].questions[1].value = 0; - questions['comfortIssues'].answer = []; questions['comfortIssues'].value = []; } @@ -870,7 +876,6 @@ class App extends React.Component { questions.buildingTypes.next = 'financeInterest'; questions.financeInterest.prev = 'buildingTypes'; } - questions.financeInterest.next = 'reviewAnswers'; questions.reviewAnswers.next = 'thankYou'; questions.contact.next = "reviewAnswers"; this.setState({ questions }, () => { @@ -1009,6 +1014,11 @@ class App extends React.Component { questions={this.state.questions['unitBreakdown'].questionIds} answers={this.state.questions['unitBreakdown'].answers} />, + feedback: , buildingTypes: Continue > diff --git a/src/Feedback.js b/src/Feedback.js new file mode 100644 index 0000000000000000000000000000000000000000..f6113122d547adf10b76e3207e1908fa3d1d4c1e --- /dev/null +++ b/src/Feedback.js @@ -0,0 +1,84 @@ +import React from "react"; +import { Row, Col, Button } from 'reactstrap'; +import './index.css'; + +export default class Feedback extends React.Component { + constructor(props) { + super(props); + this.state = { + answer: this.props.answer, + }; + } + + handleInputChange = (event) => { + const val = event.target.value; + const name = event.target.name; + this.setState({ + ...this.state, + [name]: val, + }); + } + + prevQuestion = () => { + this.props.prevQuestion('feedback'); + } + + nextQuestion = () => { + this.props.nextQuestion( + 'feedback', + [], + [this.state.answer], + ); + } + + handleFocus = (event) => event.target.select(); + + render() { + const content = ( +
+
+ How did you first hear about us? +
+
+ (Optional) +
+ + + this.handleInputChange(e)}> + + + + + + + {'<'} Back + + + + {/* Button will be disabled only if all inputs are 0 or any of the input is empty. */} + + + +
+ ); + + return ( +
+ {content} +
+ ); + } +} diff --git a/src/ReviewAnswers.js b/src/ReviewAnswers.js index 89682de6644d8d801f022b1ab62d6744e77dffc5..bedd7608bb1de63533f37870981a7dd24816eca9 100644 --- a/src/ReviewAnswers.js +++ b/src/ReviewAnswers.js @@ -167,6 +167,48 @@ export default class ReviewAnswers extends React.Component { } }) } +
+ + +
+ How did you first hear about us? +
+
+ {this.props.questions['feedback'].answers[0]}
+
+ +
+ + this.editAnswer('feedback') } /> + +
+
+
+
+ +
+ + +
+ Apartment Unit Breakdown +
+
+ Studio: {this.props.questions['unitBreakdown'].answers[0]}
+ One Bedroom: {this.props.questions['unitBreakdown'].answers[1]}
+ Two Bedroom: {this.props.questions['unitBreakdown'].answers[2]}
+ Three Bedroom: {this.props.questions['unitBreakdown'].answers[3]}
+ Four Bedroom: {this.props.questions['unitBreakdown'].answers[4]}
+ Other: {this.props.questions['unitBreakdown'].answers[5]} +
+ +
+ + this.editAnswer('unitBreakdown') } /> + +
+
+
+