Skip to content

Commit a0b3fd5

Browse files
committed
wiring surveys
1 parent 53c1246 commit a0b3fd5

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

server/client/src/actions/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import axios from 'axios';
2-
import { FETCH_USER } from './types';
2+
import { FETCH_USER, FETCH_SURVEYS } from './types';
33

44
export const fetchUser = () => async dispatch => {
55
const res = await axios.get('/api/current_user');
@@ -19,3 +19,9 @@ export const submitSurvey = (values, history) => async dispatch => {
1919
history.push('/surveys');
2020
dispatch({ type: FETCH_USER, payload: res.data });
2121
};
22+
23+
export const fetchSurveys = () => async dispatch => {
24+
const res = await axios.get('/api/surveys');
25+
26+
dispatch({ type: FETCH_SURVEYS, payload: res.data });
27+
};

server/client/src/actions/types.js

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const FETCH_USER = 'fetch_user';
2+
export const FETCH_SURVEYS = 'fetch_surveys';

server/client/src/reducers/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { combineReducers } from 'redux';
22
import { reducer as reduxForm } from 'redux-form';
33
import authReducer from './authReducer';
4+
import surveysReducer from './surveysReducer';
45

56
export default combineReducers({
67
auth: authReducer,
7-
form: reduxForm
8+
form: reduxForm,
9+
surveys: surveysReducer
810
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { FETCH_SURVEYS } from '../actions/types';
2+
3+
export default function(state = [], action) {
4+
switch (action.type) {
5+
case FETCH_SURVEYS:
6+
return action.payload;
7+
default:
8+
return state;
9+
}
10+
}

0 commit comments

Comments
 (0)