mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
liking and quoting work
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { LIKE_POST, UNLIKE_POST} from '../types';
|
||||
|
||||
const initialState = {
|
||||
likes: [],
|
||||
credentials: {}
|
||||
}
|
||||
|
||||
export default function(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case LIKE_POST:
|
||||
return {
|
||||
...state,
|
||||
likes: [
|
||||
...state.likes,
|
||||
{
|
||||
userHandle: state.credentials.handle,
|
||||
postId: action.payload.postId
|
||||
}
|
||||
]
|
||||
}
|
||||
case UNLIKE_POST:
|
||||
return {
|
||||
...state,
|
||||
likes: state.likes.filter(
|
||||
(like) => like.postId === action.payload.postId
|
||||
)
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user