Skip to content

Commit 6ed860e

Browse files
committed
redirect
1 parent b348d35 commit 6ed860e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

server/client/src/actions/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export const handleToken = token => async dispatch => {
1313
dispatch({ type: FETCH_USER, payload: res.data });
1414
};
1515

16-
export const submitSurvey = values => async dispatch => {
16+
export const submitSurvey = (values, history) => async dispatch => {
1717
const res = await axios.post('/api/surveys', values);
1818

19+
history.push('/surveys');
1920
dispatch({ type: FETCH_USER, payload: res.data });
2021
};

server/client/src/components/surveys/SurveyFormReview.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import _ from 'lodash';
33
import React from 'react';
44
import { connect } from 'react-redux';
55
import formFields from './formFields';
6+
import { withRouter } from 'react-router-dom';
67
import * as actions from '../../actions';
78

8-
const SurveyFormReview = ({ onCancel, formValues, submitSurvey }) => {
9+
const SurveyFormReview = ({ onCancel, formValues, submitSurvey, history }) => {
910
const reviewFields = _.map(formFields, ({ name, label }) => {
1011
return (
1112
<div key={name}>
@@ -28,7 +29,7 @@ const SurveyFormReview = ({ onCancel, formValues, submitSurvey }) => {
2829
Back
2930
</button>
3031
<button
31-
onClick={() => submitSurvey(formValues)}
32+
onClick={() => submitSurvey(formValues, history)}
3233
className="green btn-flat right white-text"
3334
>
3435
Send Survey
@@ -42,4 +43,4 @@ function mapStateToProps(state) {
4243
return { formValues: state.form.surveyForm.values };
4344
}
4445

45-
export default connect(mapStateToProps, actions)(SurveyFormReview);
46+
export default connect(mapStateToProps, actions)(withRouter(SurveyFormReview));

0 commit comments

Comments
 (0)