Fixing after react update
This commit is contained in:
@@ -15,4 +15,8 @@ function alertReducer(state = initialState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export default alertReducer;
|
||||
<<<<<<< HEAD
|
||||
export default alertReducer;
|
||||
=======
|
||||
export default alertReducer;
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
@@ -50,4 +50,8 @@ function authReducer(state = initialState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export default authReducer;
|
||||
<<<<<<< HEAD
|
||||
export default authReducer;
|
||||
=======
|
||||
export default authReducer;
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
@@ -9,4 +9,8 @@ export default combineReducers({
|
||||
auth,
|
||||
profile,
|
||||
post
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
});
|
||||
=======
|
||||
});
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
@@ -1,4 +1,88 @@
|
||||
import {
|
||||
<<<<<<< HEAD
|
||||
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;
|
||||
=======
|
||||
GET_POSTS,
|
||||
POST_ERROR,
|
||||
UPDATE_LIKES,
|
||||
@@ -80,4 +164,5 @@ import {
|
||||
}
|
||||
}
|
||||
|
||||
export default postReducer;
|
||||
export default postReducer;
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
@@ -5,15 +5,24 @@ import {
|
||||
UPDATE_PROFILE,
|
||||
GET_PROFILES,
|
||||
GET_REPOS,
|
||||
<<<<<<< HEAD
|
||||
NO_REPOS
|
||||
} from '../actions/types';
|
||||
=======
|
||||
NO_REPOS,
|
||||
} from "../actions/types";
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
const initialState = {
|
||||
profile: null,
|
||||
profiles: [],
|
||||
repos: [],
|
||||
loading: true,
|
||||
<<<<<<< HEAD
|
||||
error: {}
|
||||
=======
|
||||
error: {},
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
|
||||
function profileReducer(state = initialState, action) {
|
||||
@@ -25,37 +34,61 @@ function profileReducer(state = initialState, action) {
|
||||
return {
|
||||
...state,
|
||||
profile: payload,
|
||||
<<<<<<< HEAD
|
||||
loading: false
|
||||
=======
|
||||
loading: false,
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
case GET_PROFILES:
|
||||
return {
|
||||
...state,
|
||||
profiles: payload,
|
||||
<<<<<<< HEAD
|
||||
loading: false
|
||||
=======
|
||||
loading: false,
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
case PROFILE_ERROR:
|
||||
return {
|
||||
...state,
|
||||
error: payload,
|
||||
loading: false,
|
||||
<<<<<<< HEAD
|
||||
profile: null
|
||||
=======
|
||||
profile: null,
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
case CLEAR_PROFILE:
|
||||
return {
|
||||
...state,
|
||||
profile: null,
|
||||
<<<<<<< HEAD
|
||||
repos: []
|
||||
=======
|
||||
repos: [],
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
case GET_REPOS:
|
||||
return {
|
||||
...state,
|
||||
repos: payload,
|
||||
<<<<<<< HEAD
|
||||
loading: false
|
||||
=======
|
||||
loading: false,
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
case NO_REPOS:
|
||||
return {
|
||||
...state,
|
||||
<<<<<<< HEAD
|
||||
repos: []
|
||||
=======
|
||||
repos: [],
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user