diff --git a/src/App.tsx b/src/App.tsx index 0b1b24b00..4bdfcda62 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -34,7 +34,7 @@ export const App = () => { getUsers() .then(setUsers) .catch(usersLoadingError => { - setError('usersLoadingError'); + setError(`usersLoadingError ${usersLoadingError}`); throw usersLoadingError; }); @@ -52,8 +52,7 @@ export const App = () => { getPosts(selectedUser.id) .then(setPosts) .catch(loadingError => { - // setError(true); - setError('postsLoadingError'); + setError(`postsLoadingError ${loadingError}`); throw loadingError; }) diff --git a/src/components/NewCommentForm.tsx b/src/components/NewCommentForm.tsx index 6174d94c6..e9c33ad64 100644 --- a/src/components/NewCommentForm.tsx +++ b/src/components/NewCommentForm.tsx @@ -95,7 +95,7 @@ export const NewCommentForm: React.FC = ({ id="comment-author-name" placeholder="Name Surname" className={classNames('input', { - 'is-danger': false, + 'is-danger': hasErrorMessage.nameError.length > 0, })} value={commentData.name} onChange={event => @@ -139,7 +139,7 @@ export const NewCommentForm: React.FC = ({ 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 => @@ -182,7 +182,7 @@ export const NewCommentForm: React.FC = ({ name="body" placeholder="Type comment here" className={classNames('textarea', { - 'is-danger': false, + 'is-danger': hasErrorMessage.bodyError.length > 0, })} value={commentData.body} onChange={event => diff --git a/src/components/PostDetails.tsx b/src/components/PostDetails.tsx index c9a8b2f7f..f17544df4 100644 --- a/src/components/PostDetails.tsx +++ b/src/components/PostDetails.tsx @@ -43,7 +43,7 @@ export const PostDetails: React.FC = ({ }); }) .catch(loadingError => { - setError('commentAddError'); + setError(`commentAddError ${loadingError}`); throw loadingError; }) @@ -59,8 +59,9 @@ export const PostDetails: React.FC = ({ : [], ); - deleteComment(commentId).catch(() => { - setError('commentDeletingError'); + deleteComment(commentId) + .catch(deletingError => { + setError(`commentDeletingError ${deletingError}`); }); }; @@ -72,7 +73,7 @@ export const PostDetails: React.FC = ({ getComments(selectedPost.id) .then(setComments) .catch(loadingError => { - setError('commentsLoadingError'); + setError(`commentsLoadingError ${loadingError}`); throw loadingError; })