Skip to content

Commit

Permalink
Solution. Corrections 2
Browse files Browse the repository at this point in the history
  • Loading branch information
momos1703 committed Oct 31, 2024
1 parent e5c2d00 commit 0c89f0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const App = () => {
getUsers()
.then(setUsers)
.catch(usersLoadingError => {
setError('usersLoadingError');
setError(`usersLoadingError ${usersLoadingError}`);

throw usersLoadingError;
});
Expand All @@ -52,8 +52,7 @@ export const App = () => {
getPosts(selectedUser.id)
.then(setPosts)
.catch(loadingError => {
// setError(true);
setError('postsLoadingError');
setError(`postsLoadingError ${loadingError}`);

throw loadingError;
})
Expand Down
6 changes: 3 additions & 3 deletions src/components/NewCommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const NewCommentForm: React.FC<Props> = ({
id="comment-author-name"
placeholder="Name Surname"
className={classNames('input', {
'is-danger': false,
'is-danger': hasErrorMessage.nameError.length > 0,
})}
value={commentData.name}
onChange={event =>
Expand Down Expand Up @@ -139,7 +139,7 @@ export const NewCommentForm: React.FC<Props> = ({
id="comment-author-email"
placeholder="email@test.com"
className={classNames('input', {
'is-danger': false,
'is-danger': hasErrorMessage.emailError.length > 0,
})}
value={commentData.email}
onChange={event =>
Expand Down Expand Up @@ -182,7 +182,7 @@ export const NewCommentForm: React.FC<Props> = ({
name="body"
placeholder="Type comment here"
className={classNames('textarea', {
'is-danger': false,
'is-danger': hasErrorMessage.bodyError.length > 0,
})}
value={commentData.body}
onChange={event =>
Expand Down
9 changes: 5 additions & 4 deletions src/components/PostDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const PostDetails: React.FC<Props> = ({
});
})
.catch(loadingError => {
setError('commentAddError');
setError(`commentAddError ${loadingError}`);

throw loadingError;
})
Expand All @@ -59,8 +59,9 @@ export const PostDetails: React.FC<Props> = ({
: [],
);

deleteComment(commentId).catch(() => {
setError('commentDeletingError');
deleteComment(commentId)
.catch(deletingError => {
setError(`commentDeletingError ${deletingError}`);
});
};

Expand All @@ -72,7 +73,7 @@ export const PostDetails: React.FC<Props> = ({
getComments(selectedPost.id)
.then(setComments)
.catch(loadingError => {
setError('commentsLoadingError');
setError(`commentsLoadingError ${loadingError}`);

throw loadingError;
})
Expand Down

0 comments on commit 0c89f0f

Please sign in to comment.