Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
VenEleni committed Aug 26, 2024
1 parent 8611ccb commit 8c259d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/src/reducers/authReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,28 @@ const authReducer = (state = initialState, action) => {
switch (action.type) {
case REGISTER_SUCCESS:
case LOGIN_SUCCESS:
console.log("Reducer action payload:", action.payload);
const newState = {
console.log("Success - Reducer action payload:", action.payload);
const newStateOnSuccess = {
...state,
token: action.payload.token,
isAuthenticated: true,
user: action.payload.user,
error: null,
};
console.log("New state:", newState);
console.log("Success - New state:", newStateOnSuccess);
return newState;
case REGISTER_FAIL:
case LOGIN_FAIL:
return {
console.log("Fail - Reducer action payload:", action.payload);
const newStateOnFailure = {
...state,
token: null,
isAuthenticated: false,
user: null,
error: action.payload,
};
console.log("Fail - New state:", newStateOnFailure);
return newState;
case LOG_OUT:
return {
...state,
Expand Down

0 comments on commit 8c259d3

Please sign in to comment.