-
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
add task solution #2700
base: master
Are you sure you want to change the base?
add task solution #2700
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.
Thank you for your hard work on this project! 😊 While your implementation is mostly correct and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:
-
Dynamic Email Address: The email address in the anchor tag is currently hardcoded. It's important to dynamically set this based on the
user
object to ensure it reflects the correct user's email. -
Loading State Logic: The logic for setting the loading state is inefficient. It sets the loading state to true and then immediately to false after a timeout. This should be revised to better reflect the actual loading state of the application.
-
Typo in Variable Name: There's a typo in the variable name
updatedToods
. It should be corrected toupdatedTodos
to maintain consistency and clarity in your code.
Please address these issues to ensure the functionality and clarity of your code. Once these changes are made, we can proceed with the approval. Keep up the great work, and don't hesitate to reach out if you need any assistance! 🚀
✨ 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
|
||
useEffect(() => { | ||
setLoading(true); | ||
let updatedToods = [...todos]; |
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 variable name updatedToods
. It should be updatedTodos
to match the context of the code.
src/App.tsx
Outdated
setLoading(true); | ||
let updatedToods = [...todos]; | ||
|
||
if (filter === 'active') { | ||
updatedToods = updatedToods.filter(event => !event.completed); | ||
} else if (filter === 'completed') { | ||
updatedToods = updatedToods.filter(event => event.completed); | ||
} | ||
|
||
if (searchFilter) { | ||
updatedToods = updatedToods.filter(todo => | ||
todo.title.toLowerCase().includes(searchFilter.toLowerCase()), | ||
); | ||
} | ||
|
||
setTimeout(() => { | ||
setFilterTodos(updatedToods); | ||
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.
The logic for setting the loading state is inefficient. The loading state is set to true and then immediately set to false after a timeout. Consider revising this logic to better reflect the actual loading state of the application.
|
||
{' by '} | ||
|
||
<a href="mailto:[email protected]">Leanne Graham</a> | ||
<a href="mailto:[email protected]">{user?.name}</a> |
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 email address in the anchor tag is hardcoded. Consider dynamically setting the email address based on the user
object to ensure it reflects the correct user's 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.
Great job on implementing the solution! 🎉 While there are a few critical issues to address, such as dynamically setting the email address based on the user
object, correcting the typo in updatedTodos
, and revising the loading state logic for efficiency, your code meets the task requirements. These improvements will enhance the functionality and clarity of your code. Remember to review the comments and learn from these points to refine your skills further. Keep up the good work and continue to improve! 💪
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
useEffect(() => { | ||
if (selectedTodo?.userId) { | ||
setLoadingModal(true); | ||
getUser(selectedTodo?.userId).then(fetchedUser => setUser(fetchedUser)); |
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 email address in the anchor tag should be dynamically set based on the user
object to ensure it reflects the correct user's email. Please update this logic accordingly.
setTimeout(() => { | ||
setLoadingModal(false); | ||
}, 500); |
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 logic for setting the loading state is inefficient. It sets the loading state to true and then immediately to false after a timeout. This should be revised to better reflect the actual loading state of the application.
|
||
useEffect(() => { | ||
setLoading(true); | ||
let updatedTodos = [...todos]; |
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's a typo in the variable name updatedToods
. It should be corrected to updatedTodos
to maintain consistency and clarity in your code.
|
||
{' by '} | ||
|
||
<a href="mailto:[email protected]">Leanne Graham</a> | ||
<a href={`mailto:${user?.email}`}>{user?.name}</a> |
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 address is dynamically set based on the user
object. This is important to reflect the correct user's email in the anchor tag.
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.
src/App.tsx
Outdated
if (filter === 'active') { | ||
updatedTodos = updatedTodos.filter(event => !event.completed); | ||
} else if (filter === 'completed') { |
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.
Create a enum for 'all', 'active', 'completed' and use it everywhere
src/components/TodoItem/TodoItem.tsx
Outdated
</td> | ||
<td className="is-vcentered is-expanded"> | ||
<p className={todo.completed ? 'has-text-success' : 'has-text-danger'}> | ||
{todo.title}{' '} |
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.
{todo.title}{' '} | |
{todo.title} |
src/components/TodoItem/TodoItem.tsx
Outdated
)} | ||
</td> | ||
<td className="is-vcentered is-expanded"> | ||
<p className={todo.completed ? 'has-text-success' : 'has-text-danger'}> |
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.
Use the classnames library for add classes with condition, fix it everywhere
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 job 👍
Let's improve your code
|
||
export const App: React.FC = () => { | ||
const [todos, setTodo] = useState<Todo[]>([]); | ||
const [filterTodos, setFilterTodos] = useState<Todo[]>([]); |
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.
Don't need to create additional state for filtered todos, use only one state
const [filterTodos, setFilterTodos] = useState<Todo[]>([]); |
src/App.tsx
Outdated
|
||
export const App: React.FC = () => { | ||
const [todos, setTodo] = useState<Todo[]>([]); | ||
const [filterTodos, setFilterTodos] = useState<Todo[]>([]); | ||
const [filter, setFilter] = useState<string>('all'); |
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.
Use enum here for 'all'
src/App.tsx
Outdated
if (filter === FilterType.Active) { | ||
updatedTodos = updatedTodos.filter(event => !event.completed); | ||
} else if (filter === FilterType.Completed) { | ||
updatedTodos = updatedTodos.filter(event => event.completed); | ||
} |
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.
Use switch case here, it will be better
src/App.tsx
Outdated
let updatedTodos = [...todos]; | ||
|
||
if (filter === FilterType.Active) { | ||
updatedTodos = updatedTodos.filter(event => !event.completed); |
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.
updatedTodos = updatedTodos.filter(event => !event.completed); | |
updatedTodos = updatedTodos.filter(todo => !todo.completed); |
<option value="all">All</option> | ||
<option value="active">Active</option> | ||
<option value="completed">Completed</option> |
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.
Also, use a created enum here
src/components/TodoItem/TodoItem.tsx
Outdated
'has-text-danger': !todo.completed, | ||
})} | ||
> | ||
{todo.title} |
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.
Use destructuting for todo
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 job.
DEMO LINK