dgdgproto/client/src/reducers/appData.js
2020-03-25 03:54:31 +01:00

43 lines
741 B
JavaScript

import {
USER_AUTHENTICATED,
USER_LOGGED_OUT,
QUESTIONS_LOADED,
QUESTIONS_LOAD_ERROR
} from '../actions/types';
const initialState = {
user: undefined,
questions: []
};
export default function (state = initialState, action) {
switch (action.type) {
case USER_AUTHENTICATED: {
return {
...state,
user: action.data
};
}
case USER_LOGGED_OUT: {
return {
...state,
user: undefined
};
}
case QUESTIONS_LOADED: {
return {
...state,
questions: action.data
};
}
case QUESTIONS_LOAD_ERROR: {
return {
...state,
questionsLoadError: action.error
};
}
default:
return state;
}
};