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

17 lines
434 B
JavaScript
Raw Normal View History

2020-02-04 17:20:39 +01:00
import { LOGIN_SUCCESS, LOGIN_FAILURE } from '../actions/login';
const defaultState = {
isLoggedIn: false,
username: null,
}
export default function loginReducer(state = defaultState, action) {
switch (action.type) {
case LOGIN_SUCCESS:
return { ...state, isLoggedIn: true, username: action.data.Username };
case LOGIN_FAILURE:
return { ...state, isLoggedIn: false, username: null };
}
return state;
}