From 634f0d35e13e981f2facab002b7de7c66d629424 Mon Sep 17 00:00:00 2001 From: melliflorGunk Date: Thu, 21 Sep 2017 17:05:43 -0700 Subject: [PATCH 1/5] added fix to ensure survey answer persistence when moving to an already answered question --- js/scenes/Surveys/Pages/Surveys.js | 16 +++++++++++++--- js/scenes/Surveys/SurveysContainer.js | 11 ++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/js/scenes/Surveys/Pages/Surveys.js b/js/scenes/Surveys/Pages/Surveys.js index e363cbd..e73c753 100644 --- a/js/scenes/Surveys/Pages/Surveys.js +++ b/js/scenes/Surveys/Pages/Surveys.js @@ -16,6 +16,7 @@ const Surveys = ({ question, questions, nextQuestion, + nextQuestionFunc, previousQuestionFunc, prevQuestion, selectedValue, @@ -59,7 +60,7 @@ const Surveys = ({ completePerc={questions.indexOf(question) + 1} totalSteps={questions.length + 1} /> - nextQuestion()} /> + nextQuestionFunc(nextQuestion.question)} /> @@ -69,7 +70,8 @@ const Surveys = ({ export default Surveys; Surveys.defaultProps = { - prevQuestion: null + prevQuestion: null, + nextQuestion: null }; Surveys.propTypes = { @@ -95,7 +97,15 @@ Surveys.propTypes = { value: PropTypes.number })) })).isRequired, - nextQuestion: PropTypes.func.isRequired, + nextQuestion: PropTypes.shape({ + quality: PropTypes.string, + question: PropTypes.string, + answers: PropTypes.arrayOf(PropTypes.shape({ + answer: PropTypes.string, + value: PropTypes.number + })) + }), + nextQuestionFunc: PropTypes.func.isRequired, previousQuestionFunc: PropTypes.func.isRequired, prevQuestion: PropTypes.shape({ quality: PropTypes.string, diff --git a/js/scenes/Surveys/SurveysContainer.js b/js/scenes/Surveys/SurveysContainer.js index c1c0a65..0df2cd0 100644 --- a/js/scenes/Surveys/SurveysContainer.js +++ b/js/scenes/Surveys/SurveysContainer.js @@ -64,11 +64,15 @@ class SurveysContainer extends Component { goToSurveyComplete(); } - nextQuestion = () => { + nextQuestion = (nextQuestion) => { + const selectedAnswer = this.props.surveyAnswers[nextQuestion]; if (this.state.selectedValue === -1) { this.setState({ showWarningModal: true }); } else { - this.setState({ n: this.state.n + 1, selectedValue: -1 }); + this.setState({ + n: this.state.n + 1, + selectedValue: (selectedAnswer) ? selectedAnswer.value : -1 + }); } } @@ -104,9 +108,10 @@ class SurveysContainer extends Component { displayGoalModal={this.displayGoalModal} questions={questions} question={questions[n]} - nextQuestion={this.nextQuestion} + nextQuestionFunc={this.nextQuestion} previousQuestionFunc={this.previousQuestion} prevQuestion={questions[n - 1]} + nextQuestion={questions[n + 1]} selectedValue={selectedValue} /> ); From 114c838b39c1b26def243c3257aacd2dee3f9133 Mon Sep 17 00:00:00 2001 From: melliflorGunk Date: Thu, 21 Sep 2017 17:21:43 -0700 Subject: [PATCH 2/5] fixed faulty rendering of comment screen --- js/scenes/Surveys/Pages/Surveys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/scenes/Surveys/Pages/Surveys.js b/js/scenes/Surveys/Pages/Surveys.js index e73c753..c027d4b 100644 --- a/js/scenes/Surveys/Pages/Surveys.js +++ b/js/scenes/Surveys/Pages/Surveys.js @@ -60,7 +60,7 @@ const Surveys = ({ completePerc={questions.indexOf(question) + 1} totalSteps={questions.length + 1} /> - nextQuestionFunc(nextQuestion.question)} /> + nextQuestionFunc((nextQuestion) ? nextQuestion.question : null)} /> From 4f172695b6a48bea4df96dc81f89b415c8826ae7 Mon Sep 17 00:00:00 2001 From: melliflorGunk Date: Thu, 21 Sep 2017 17:23:13 -0700 Subject: [PATCH 3/5] refactored if statement of comment screen --- js/scenes/Surveys/Pages/Surveys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/scenes/Surveys/Pages/Surveys.js b/js/scenes/Surveys/Pages/Surveys.js index c027d4b..594c69a 100644 --- a/js/scenes/Surveys/Pages/Surveys.js +++ b/js/scenes/Surveys/Pages/Surveys.js @@ -60,7 +60,7 @@ const Surveys = ({ completePerc={questions.indexOf(question) + 1} totalSteps={questions.length + 1} /> - nextQuestionFunc((nextQuestion) ? nextQuestion.question : null)} /> + nextQuestionFunc(nextQuestion && nextQuestion.question)} /> From 4b6f2b4cd32f89a0f6aafb9542d3d4868a625d1d Mon Sep 17 00:00:00 2001 From: melliflorGunk Date: Thu, 21 Sep 2017 17:47:02 -0700 Subject: [PATCH 4/5] added reset functionality on survey submit to prevent question storage on new survey --- js/redux/modules/actions/surveyActions.js | 3 + js/redux/modules/reducers/surveyReducer.js | 2 + js/scenes/SurveyComplete/SurveyComplete.js | 68 ++++++++++++---------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/js/redux/modules/actions/surveyActions.js b/js/redux/modules/actions/surveyActions.js index 49d451a..3c6a9e1 100644 --- a/js/redux/modules/actions/surveyActions.js +++ b/js/redux/modules/actions/surveyActions.js @@ -5,6 +5,9 @@ export function setTalkData(talkData) { return { type: 'SET_TALK_DATA', talkData } } +export function resetSurvey() { + return { type: 'RESET_SURVEY' }; +} export function setSurveyAnswers(surveyAnswers) { return { type: 'SET_SURVEY_ANSWERS', surveyAnswers }; diff --git a/js/redux/modules/reducers/surveyReducer.js b/js/redux/modules/reducers/surveyReducer.js index e53c5e5..19e1b55 100644 --- a/js/redux/modules/reducers/surveyReducer.js +++ b/js/redux/modules/reducers/surveyReducer.js @@ -10,6 +10,8 @@ const initialState = { export function SurveyReducer(state = initialState, action) { switch (action.type) { + case 'RESET_SURVEY': + return initialState; case 'SET_SURVEY_ANSWERS': return { ...state, diff --git a/js/scenes/SurveyComplete/SurveyComplete.js b/js/scenes/SurveyComplete/SurveyComplete.js index c2ff4b1..a207c9f 100644 --- a/js/scenes/SurveyComplete/SurveyComplete.js +++ b/js/scenes/SurveyComplete/SurveyComplete.js @@ -1,42 +1,50 @@ -import React from 'react' +import React, { Component } from 'react' import { Text, View } from 'react-native'; +import { connect } from 'react-redux'; +import { resetSurvey } from '../../redux/modules/actions/surveyActions'; import { styles } from './styles'; import SurveyButton from '../../components/SurveyButton'; import { returnToHome, returnToEvents, returnToSpeaker } from '../../navigation/navHelpers'; -const SurveyCompleteContainer = () => { - const buttons = [ - { text: "Home", action: returnToHome }, - { text: "Events", action: returnToEvents }, - { text: "Speaker's Page", action: returnToSpeaker } - ]; +class SurveyCompleteContainer extends Component { - return ( - - - - Thanks! - Your feedback has been submitted. - {buttons.map(button => ( - button.action()} - cStyle={styles.buttonContainer} - /> - ))} + static route = { + navigationBar: { + title: "Submit Complete", + renderLeft: () => null + } + } + + componentDidMount() { + this.props.dispatch(resetSurvey()); + } + + render() { + const buttons = [ + { text: "Home", action: returnToHome }, + { text: "Events", action: returnToEvents }, + { text: "Speaker's Page", action: returnToSpeaker } + ]; + return ( + + + + Thanks! + Your feedback has been submitted. + {buttons.map(button => ( + button.action()} + cStyle={styles.buttonContainer} + /> + ))} + - - ) -} - -SurveyCompleteContainer.route = { - navigationBar: { - title: "Submit Complete", - renderLeft: () => null + ) } } -export default SurveyCompleteContainer; +export default connect()(SurveyCompleteContainer); From b82851fa88ef8a131bc1ca3a01837b4231920f5b Mon Sep 17 00:00:00 2001 From: melliflorGunk Date: Thu, 21 Sep 2017 17:48:50 -0700 Subject: [PATCH 5/5] added dynamic id check on previous survey submission for userid --- js/scenes/Speaker/SpeakerContainer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/scenes/Speaker/SpeakerContainer.js b/js/scenes/Speaker/SpeakerContainer.js index 733ca3c..e7c5707 100644 --- a/js/scenes/Speaker/SpeakerContainer.js +++ b/js/scenes/Speaker/SpeakerContainer.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { auth } from '../../config/firebase'; import Loader from '../../components/Loader'; import { goToSurvey } from '../../navigation/navHelpers'; import Speaker from './Speaker'; @@ -39,8 +40,7 @@ class SpeakerContainer extends Component { checkRespondent = () => { const currTalk = this.props.speakerData.item.talk_id; - // using a static id for testing - const currUser = 'dKJaZ8tuniPW1Ee2BduSQQ8wSsp2'; + const currUser = auth.currentUser.uid; return this.props.talkData[currTalk].respondents[currUser]; }