You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
956 B
34 lines
956 B
import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
export const postSlice = createSlice({
|
|
name: "post",
|
|
initialState: {
|
|
post : {
|
|
},
|
|
},
|
|
reducers: {
|
|
setPostData: (state,action) => {
|
|
state.post = action.payload;
|
|
console.log(state.post)
|
|
},
|
|
setPostLikeData: (state,action) => {
|
|
if (state.post._id === action.payload.postId) {
|
|
state.post = {
|
|
...state.post,
|
|
likers: [action.payload.userId, ...state.post.likers],
|
|
};
|
|
}
|
|
console.log(state.post)
|
|
},
|
|
setPostUnLikeData: (state,action) => {
|
|
console.log(state);
|
|
console.log(action);
|
|
}
|
|
},
|
|
});
|
|
|
|
export const {setPostUnLikeData} = postSlice.actions;
|
|
export const {setPostLikeData} = postSlice.actions;
|
|
export const {setPostData} = postSlice.actions;
|
|
export default postSlice.reducer;
|