From 3c88b8777ebba7acb7df3d9e9cb5a3da708dfb7c Mon Sep 17 00:00:00 2001 From: Andrean <88448470+QkoSad@users.noreply.github.com> Date: Mon, 8 May 2023 16:48:43 +0000 Subject: [PATCH] Update post.js --- client/src/reducers/post.js | 86 +------------------------------------ 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/client/src/reducers/post.js b/client/src/reducers/post.js index ac280c2..ec90e37 100644 --- a/client/src/reducers/post.js +++ b/client/src/reducers/post.js @@ -1,5 +1,4 @@ import { -<<<<<<< HEAD GET_POSTS, POST_ERROR, UPDATE_LIKES, @@ -82,87 +81,4 @@ function postReducer(state = initialState, action) { } export default postReducer; -======= - GET_POSTS, - POST_ERROR, - UPDATE_LIKES, - DELETE_POST, - ADD_POST, - GET_POST, - ADD_COMMENT, - REMOVE_COMMENT - } from '../actions/types'; - - const initialState = { - posts: [], - post: null, - loading: true, - error: {} - }; - - function postReducer(state = initialState, action) { - const { type, payload } = action; - - switch (type) { - case GET_POSTS: - return { - ...state, - posts: payload, - loading: false - }; - case GET_POST: - return { - ...state, - post: payload, - loading: false - }; - case ADD_POST: - return { - ...state, - posts: [payload, ...state.posts], - loading: false - }; - case DELETE_POST: - return { - ...state, - posts: state.posts.filter((post) => post._id !== payload), - loading: false - }; - case POST_ERROR: - return { - ...state, - error: payload, - loading: false - }; - case UPDATE_LIKES: - return { - ...state, - posts: state.posts.map((post) => - post._id === payload.id ? { ...post, likes: payload.likes } : post - ), - loading: false - }; - case ADD_COMMENT: - return { - ...state, - post: { ...state.post, comments: payload }, - loading: false - }; - case REMOVE_COMMENT: - return { - ...state, - post: { - ...state.post, - comments: state.post.comments.filter( - (comment) => comment._id !== payload - ) - }, - loading: false - }; - default: - return state; - } - } - - export default postReducer; ->>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb +