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

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