-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Task solution #2693
base: master
Are you sure you want to change the base?
Task solution #2693
Conversation
Good code! |
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.
Good work!
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.
Thank you for your hard work on this pull request! There are a few critical issues that need to be addressed to ensure the functionality and correctness of the code:
-
Typing Issues: The
setSelectedTodo
,setFilterBy
, andsetQuery
props need to be correctly typed to accept the appropriate parameters. This is crucial for the components to function as expected. -
Error Messages: There are typos in the error messages, such as 'occured' instead of 'occurred', and 'toods' instead of 'todos'. Clear and typo-free error messages are important for a good user experience.
-
Descriptive Error Handling: Consider providing more descriptive error messages in the
catch
blocks to aid in debugging.
Please address these issues to ensure the code meets the core requirements. Once these changes are made, the pull request will be ready for approval. Keep up the great work! 🌟
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
src/App.tsx
Outdated
export const App: React.FC = () => { | ||
const [todoList, setTodoList] = useState<Todo[]>([]); | ||
const [isLoading, setLoading] = useState(false); | ||
const [selectedTodo, setSelectedTodo] = useState<Todo>(null); |
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 useState
hook for selectedTodo
is initialized with null
, which is correct. However, ensure that the setSelectedTodo
function in the TodoList
and TodoModal
components is typed to accept a Todo
object or null
.
src/App.tsx
Outdated
|
||
getTodos() | ||
.then(setTodoList) | ||
.catch(e => setErrorMessage(e)) |
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 providing a more descriptive error message in the catch
block to help with debugging. For example, setErrorMessage('Failed to load todos: ' + e.message)
.
src/App.tsx
Outdated
return ( | ||
<> | ||
<div className="section"> | ||
<div className="container"> | ||
{hasErrorMessage && ( | ||
<h1 className="title">Error has occured while downloading toods</h1> |
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.
There is a typo in the error message: 'toods' should be 'todos'. Ensure that error messages are clear and free of typos to improve user experience.
</span> | ||
type Props = { | ||
query: string; | ||
setQuery: () => void; |
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 setQuery
prop should be a function that accepts a string parameter, not a function that returns void. Update the type to (value: string) => void
.
type Props = { | ||
query: string; | ||
setQuery: () => void; | ||
setFilterBy: () => void; |
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 setFilterBy
prop should be a function that accepts a parameter, likely a string or a specific type related to FilterByState
, not a function that returns void. Update the type to (value: string) => void
or the appropriate type.
src/components/TodoList/TodoList.tsx
Outdated
</thead> | ||
type Props = { | ||
todoList: Todo[]; | ||
setSelectedTodo: () => void; |
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 setSelectedTodo
prop should be a function that accepts a Todo
object, not a function that returns void. Update the type to (todo: Todo) => void
.
|
||
type Props = { | ||
selectedTodo: Todo; | ||
setSelectedTodo: () => void; |
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 setSelectedTodo
prop should be a function that accepts a Todo
object or null
, not a function that returns void. Update the type to (todo: Todo | null) => void
.
if (userId) { | ||
getUser(userId) | ||
.then(data => setUserData(data)) | ||
.catch(e => setErrorMessage(e)) |
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 providing a more descriptive error message in the catch
block to help with debugging. For example, setErrorMessage('Failed to load user data: ' + e.message)
.
<Loader /> | ||
) : ( | ||
<div className="modal-card"> | ||
<header className="modal-card-head"> | ||
{hasErrorMessage && ( | ||
<p>An Error occured while downloading user data</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.
There is a typo in the error message: 'occured' should be 'occurred'. Ensure that error messages are clear and free of typos to improve user experience.
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 addressing the previous issues! 🎉 Your code now meets the task requirements and constraints. Here are a few points to consider for further improvement:
-
Typing Issues: Ensure that the
setSelectedTodo
,setFilterBy
, andsetQuery
props are correctly typed. This is crucial for the components to function as expected. For instance,setSelectedTodo
should acceptTodo | null
, andsetFilterBy
should handleFilterByState
correctly, especially when dealing withevent.target.value
. -
Error Messages: It's important to have clear and typo-free error messages. You've corrected the typo in 'todos', which is great. Consider making error messages more descriptive to aid in debugging.
Your efforts in resolving the issues are commendable. Keep up the good work, and continue to refine your skills by addressing these points. This will help you avoid similar issues in the future and enhance your coding proficiency. 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
getTodos() | ||
.then(setTodoList) | ||
.catch(e => setErrorMessage('Failed to download the todos' + e.message)) |
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.
There is a typo in the error message: 'Failed to download the todos'. Ensure that error messages are clear and typo-free for a good user experience.
<TodoFilter /> | ||
<TodoFilter | ||
query={query} | ||
setQuery={setQuery} |
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 setQuery
prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.
<TodoFilter | ||
query={query} | ||
setQuery={setQuery} | ||
setFilterBy={setFilterBy} |
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 setFilterBy
prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.
{!isLoading && !hasErrorMessage && ( | ||
<TodoList | ||
todoList={filteredTodos} | ||
setSelectedTodo={setSelectedTodo} |
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 setSelectedTodo
prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.
<span className="select"> | ||
<select | ||
data-cy="statusSelect" | ||
onChange={event => setFilterBy(event.target.value as FilterByState)} |
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 setFilterBy
function is typed to accept a FilterByState
but event.target.value
is of type string
. Consider using a type assertion or a type-safe way to convert the string to FilterByState
.
if (userId) { | ||
getUser(userId) | ||
.then(data => setUserData(data)) | ||
.catch(e => setErrorMessage(e.message)) |
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 providing more descriptive error messages in the catch
block to aid in debugging. This will help identify the source of the error more easily.
|
||
type Props = { | ||
selectedTodo: Todo; | ||
setSelectedTodo: (todo: Todo | null) => void; |
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 setSelectedTodo
function is correctly typed to accept Todo | null
. This is crucial for the component to function as expected.
DEMO LINK