-
Notifications
You must be signed in to change notification settings - Fork 1.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
finalize solution with some skipped tests #822
base: master
Are you sure you want to change the base?
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.
src/App.tsx
Outdated
const [activeTodosCount, setActiveTodosCount] = useState<number>(0); | ||
const [isAnyTodoCompleted, setIsAnyTodoCompleted] = useState(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.
Do you really need state for this, can it be just constants?
src/App.tsx
Outdated
id: todo.id, | ||
title: newTodoTitle, | ||
userId: todo.userId, | ||
completed: todo.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.
id: todo.id, | |
title: newTodoTitle, | |
userId: todo.userId, | |
completed: todo.completed, | |
...todo, | |
title: newTodoTitle, |
src/App.tsx
Outdated
setTodos(prevState => prevState.map(currentTodo => ( | ||
currentTodo.id !== updatedTodo.id | ||
? currentTodo | ||
: updatedTodo | ||
))); |
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.
This logic repeats some times, maybe let's move this to separate function
src/App.tsx
Outdated
)} | ||
</section> | ||
|
||
{/* Hide the footer if there are no 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.
Don't leave comments in code
src/App.tsx
Outdated
</section> | ||
|
||
{/* Hide the footer if there are no todos */} | ||
{(todos.length !== 0) && ( |
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.
{(todos.length !== 0) && ( | |
{!!todos.length && ( |
src/App.tsx
Outdated
{/* Notification is shown in case of any error */} | ||
{/* Add the 'hidden' class to hide the message smoothly */} |
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.
Delete comments
src/App.tsx
Outdated
<div | ||
data-cy="ErrorNotification" | ||
className={classNames( | ||
'notification', | ||
'is-danger', | ||
'is-light', | ||
'has-text-weight-normal', | ||
{ | ||
hidden: !errorMessage, | ||
}, | ||
)} | ||
> | ||
<button | ||
data-cy="HideErrorButton" | ||
type="button" | ||
className="delete" | ||
onClick={() => { | ||
setErrorMessage(''); | ||
}} | ||
/> | ||
{errorMessage} | ||
</div> |
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.
Move this to separate component
src/Components/TodoFooter.tsx
Outdated
))} | ||
</nav> | ||
|
||
{/* don't show this button if there are no completed 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.
Delete
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 👍
But check some comments below
const activeTodosCount = todos.filter(todo => todo.completed !== true).length; | ||
const isAnyTodoCompleted = todos.some(todo => 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.
const activeTodosCount = todos.filter(todo => todo.completed !== true).length; | |
const isAnyTodoCompleted = todos.some(todo => todo.completed === true); | |
const activeTodosCount = todos.filter(({ completed })=> !completed).length; | |
const isAnyTodoCompleted = todos.some(({ completed }) => completed); |
}); | ||
}; | ||
|
||
const handleRenameTodo = (todo: Todo, newTodoTitle: string) => { |
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.
This function and handleToggleTodo
are very similar, we can combine them
|
||
</div> | ||
<ErrorMessage |
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.
</div> | |
<ErrorMessage | |
</div> | |
<ErrorMessage |
demo link