Skip to content

Commit

Permalink
added reset functionality on survey submit to prevent question storag…
Browse files Browse the repository at this point in the history
…e on new survey
  • Loading branch information
cShingleton committed Sep 22, 2017
1 parent 4f17269 commit 4b6f2b4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
3 changes: 3 additions & 0 deletions js/redux/modules/actions/surveyActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
2 changes: 2 additions & 0 deletions js/redux/modules/reducers/surveyReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
68 changes: 38 additions & 30 deletions js/scenes/SurveyComplete/SurveyComplete.js
Original file line number Diff line number Diff line change
@@ -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 (
<View style={styles.sceneContainer}>
<View style={styles.background}>
<View style={styles.contentContainer}>
<Text style={styles.title}>Thanks!</Text>
<Text style={styles.text}>Your feedback has been submitted.</Text>
{buttons.map(button => (
<SurveyButton
key={button.text}
text={button.text}
onPress={() => 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 (
<View style={styles.sceneContainer}>
<View style={styles.background}>
<View style={styles.contentContainer}>
<Text style={styles.title}>Thanks!</Text>
<Text style={styles.text}>Your feedback has been submitted.</Text>
{buttons.map(button => (
<SurveyButton
key={button.text}
text={button.text}
onPress={() => button.action()}
cStyle={styles.buttonContainer}
/>
))}
</View>
</View>
</View>
</View>
)
}

SurveyCompleteContainer.route = {
navigationBar: {
title: "Submit Complete",
renderLeft: () => null
)
}
}

export default SurveyCompleteContainer;
export default connect()(SurveyCompleteContainer);

0 comments on commit 4b6f2b4

Please sign in to comment.