-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add task solution #1212
base: master
Are you sure you want to change the base?
add task solution #1212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the main functionality of the application! 🎉 While there are a few areas for improvement, such as enhancing error handling, ensuring accessibility, and refining user feedback, these are mostly minor issues that don't critically impact the functionality of your code. Keep up the good work and consider these suggestions for future enhancements. Your attention to detail and dedication to improving your code is commendable! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
.catch(() => { | ||
setError('Failed to load user posts. Please try again later.'); | ||
}) | ||
.finally(() => setLoading(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider logging the error in the catch block for debugging purposes. This will help in identifying the root cause of the error when it occurs.
.catch(() => { | ||
setError('Failed to load users. Please try again later.'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous suggestion, logging the error in the catch block can be beneficial for debugging and understanding what went wrong during the fetch operation.
</div> | ||
|
||
<PostsList /> | ||
<div className="block" data-cy="MainContent"> | ||
{!currUser && <p data-cy="NoSelectedUser">No user selected</p>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message 'No user selected' is displayed when no user is selected. Ensure that this message is clear and informative for the end-user, possibly by providing guidance on how to select a user.
} catch { | ||
setTouched({ name: true, email: true, body: true }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider displaying an error message to the user if the onAdd
function fails. This will provide feedback to the user about the failure and possibly guide them on what to do next.
value={newComment.email} | ||
onChange={handleInputChange} | ||
className={cn('input', { | ||
'is-danger': touched.email && newComment.email === '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the email input field is validated for proper email format. Currently, it only checks if the field is empty. Consider using a regex pattern to validate the email format.
setCurrPost, | ||
}) => { | ||
const onOpenPost = (post: Post) => { | ||
const isSamePost = currPost && currPost?.id === post.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of optional chaining (currPost?.id
) is unnecessary here since currPost
is already checked for truthiness. You can safely use currPost.id
.
<tr className="has-background-link-light"> | ||
<th>#</th> | ||
<th>Title</th> | ||
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing the eslint-disable comment if it's not necessary. If the button lacks an associated label, ensure accessibility compliance by providing an appropriate label.
<div className="dropdown-trigger"> | ||
<button | ||
type="button" | ||
className="button" | ||
aria-haspopup="true" | ||
aria-controls="dropdown-menu" | ||
onClick={() => setMenuIsVisible(true)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider toggling the menuIsVisible
state instead of setting it to true
directly. This will allow the button to both open and close the dropdown, enhancing user experience.
{users.map(user => ( | ||
<a | ||
key={user.id} | ||
href={`user-${user.id}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The href
attribute is used here, but it doesn't seem necessary since the anchor tag is used as a button. Consider removing the href
attribute to prevent any default navigation behavior.
// for a demo purpose we emulate a delay to see if Loaders work | ||
|
||
return wait(300) | ||
.then(() => fetch(BASE_URL + url, options)) | ||
.then(response => response.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the fetch request. If the response is not ok, you should throw an error or handle it appropriately to avoid unhandled promise rejections.
No description provided.