Skip to content

Commit

Permalink
add some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliiaKosenchuk committed Oct 14, 2024
1 parent 0cdb0e4 commit 4c9f6e2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const App = () => {
.catch(() => new Error('Failed to fetch users'));
}, []);

const handleUserPosts = (user: User) => {
const fetchUserPosts = (user: User) => {
setShowPostLoader(true);
getUserPosts(user.id)
.then(res => {
Expand All @@ -59,7 +59,7 @@ export const App = () => {
});
};

const handleShowComment = (currentPost: Post) => {
const fetchPostComments = (currentPost: Post) => {
setIsSidebarVisible(currentPost.id);
setShowCommentLoader(true);

Expand All @@ -78,7 +78,7 @@ export const App = () => {
});
};

const handleDeleteComment = (commentId: number) => {
const removeComment = (commentId: number) => {
deleteComment(commentId)
.then(() => {
setPostComments(prevPostComments =>
Expand All @@ -90,7 +90,7 @@ export const App = () => {
.catch(() => new Error('Failed to delete comment'));
};

const addComment = (newComment: CommentData) => {
const createComment = (newComment: CommentData) => {
setIsAddingComment(true);
addNewComment(newComment)
.then(res => {
Expand All @@ -111,7 +111,7 @@ export const App = () => {
users={users}
setUserSelected={setUserSelected}
userSelected={userSelected}
handleUserPosts={handleUserPosts}
handleUserPosts={fetchUserPosts}
setShowSideBar={setIsSidebarVisible}
/>
</div>
Expand All @@ -135,7 +135,7 @@ export const App = () => {
{userPosts.length > 0 && !showPostLoader && (
<PostsList
userPosts={userPosts}
handleShowComment={handleShowComment}
handleShowComment={fetchPostComments}
showSideBar={isSidebarVisible}
setShowSideBar={setIsSidebarVisible}
setShowCommentForm={setIsCommentFormVisible}
Expand Down Expand Up @@ -172,8 +172,8 @@ export const App = () => {
postComments={postComments}
selectedPost={selectedPost}
errorsComment={hasCommentError}
onDeleteComment={handleDeleteComment}
onAddComment={addComment}
onDeleteComment={removeComment}
onAddComment={createComment}
isButtonAddLoading={isAddingComment}
onShowCommentFormChange={setIsCommentFormVisible}
isCommentFormVisible={isCommentFormVisible}
Expand Down

0 comments on commit 4c9f6e2

Please sign in to comment.