43 lines
741 B
JavaScript
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;
|
|
}
|
|
};
|