CS307-Team24/twistter-frontend/src/redux/reducers/userReducer.js
2019-12-04 18:15:37 -05:00

63 lines
1.3 KiB
JavaScript

import {
SET_USER,
// SET_ERRORS,
// CLEAR_ERRORS,
// LOADING_UI,
SET_AUTHENTICATED,
SET_UNAUTHENTICATED,
LOADING_USER,
LIKE_POST,
UNLIKE_POST,
SET_LIKES
} from '../types';
const initialState = {
authenticated: false,
credentials: {},
likes: [],
notifications: []
};
export default function(state = initialState, action) {
switch(action.type) {
case SET_AUTHENTICATED:
return {
...state,
authenticated: true,
};
case SET_UNAUTHENTICATED:
return initialState;
case SET_USER:
return {
...state,
authenticated: true,
loading: false,
...action.payload,
};
case LIKE_POST:
return {
...state,
...action.payload
}
case UNLIKE_POST:
return {
...state,
...action.payload
}
case SET_LIKES:
return {
...state,
...action.payload
case LOADING_USER:
return {
...state,
loading: true
}
default:
return state;
}
}