Liking posts with Redux and Material UI

This commit is contained in:
2019-12-02 20:18:44 -05:00
parent e218708e0a
commit e4ea325fb8
8 changed files with 324 additions and 86 deletions

View File

@@ -1,4 +1,4 @@
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED} from '../types';
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED, LIKE_POST, UNLIKE_POST, SET_LIKES} from '../types';
const initialState = {
authenticated: false,
@@ -19,9 +19,25 @@ export default function(state = initialState, action) {
return initialState;
case SET_USER:
return {
...state,
authenticated: true,
...action.payload,
};
case LIKE_POST:
return {
...state,
...action.payload
}
case UNLIKE_POST:
return {
...state,
...action.payload
}
case SET_LIKES:
return {
...state,
...action.payload
}
default:
return state;
}