react-logo/frontend/src/reducers/session.reducers.js

24 lines
503 B
JavaScript
Raw Normal View History

2020-02-19 12:21:04 +01:00
import { LOGIN_SUCCESS } from "../actions/auth.actions";
const initialState = {
isLoggedIn: false,
user: null,
};
export function sessionReducer(state = initialState, action) {
switch(action.type) {
case LOGIN_SUCCESS:
return handleLoginSuccess(state, action);
};
return state;
}
function handleLoginSuccess(state, action) {
return {
2020-02-19 13:19:04 +01:00
...state,
2020-02-19 12:21:04 +01:00
isLoggedIn: true,
user: {
username: action.username,
},
}
};