-
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
solution #2669
base: master
Are you sure you want to change the base?
solution #2669
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.
LGTM 🔥
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 task! 🎉 Your code meets the core requirements, and the functionality is working as expected. While there is a minor issue with not using the classnames
library for conditional class definitions, it doesn't significantly impact the functionality. Keep up the good work, and consider addressing this in future projects to enhance code maintainability. Keep learning and coding! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
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 👍
Let's improve your solution slightly
src/App.tsx
Outdated
const [isLoading, setIsLoading] = useState(false); | ||
const [selectedTodo, setSelectedTodo] = useState<Todo | null>(null); | ||
const [query, setQuery] = useState(''); | ||
const [status, setStatus] = useState('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.
Create a corresponding type or enum for status
</span> | ||
|
||
{query && ( | ||
<span className="icon is-right" style={{ pointerEvents: '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.
Avoid inline styles, use classes instead
src/components/TodoList/TodoList.tsx
Outdated
<tbody> | ||
{todos.map(todo => ( | ||
<tr | ||
data-cy="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.
Create a todo component
src/components/TodoList/TodoList.tsx
Outdated
<td className="is-vcentered"> | ||
<span className="icon" data-cy="iconCompleted"> | ||
<i className="fas fa-check" /> | ||
</span> | ||
</td> | ||
) : ( | ||
<td className="is-vcentered" /> |
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.
You have <td className="is-vcentered" />
in both case only content is different
src/components/TodoList/TodoList.tsx
Outdated
<span className="icon"> | ||
<i | ||
className={ | ||
todo.id === selectedTodo?.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.
You compare todo.id === selectedTodo?.id
twice, create a variable
src/components/utils/filterTodos.ts
Outdated
if (status === 'completed') { | ||
return todo.completed === true; | ||
} | ||
|
||
if (status === 'active') { |
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.
- completed/active are magic values
- Use switch case instead
src/components/utils/filterTodos.ts
Outdated
) | ||
.filter(todo => { | ||
if (status === 'completed') { | ||
return todo.completed === 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.
You don't need to compare with true
, it's already boolean
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.
I'm approving it, looks much more better🔥
DEMO LINK