24 lines
508 B
JavaScript
24 lines
508 B
JavaScript
|
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 {
|
||
|
...state.user,
|
||
|
isLoggedIn: true,
|
||
|
user: {
|
||
|
username: action.username,
|
||
|
},
|
||
|
}
|
||
|
};
|