-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 #1051
base: master
Are you sure you want to change the base?
add task solution #1051
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.
Well done 👍
Left comments but they no critical
src/Components/Footer.tsx
Outdated
const { todos, dispatch, handleFilterBy, filteredBy, originalTodos } = | ||
useContext(TodoContext); | ||
|
||
const activeTodos = originalTodos.filter( |
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 activeTodos = originalTodos.filter( | |
const activeTodosCount = originalTodos.filter( |
src/Components/Footer.tsx
Outdated
const activeTodos = originalTodos.filter( | ||
todo => todo.completed === false, | ||
).length; | ||
const disabled = todos.some(todo => 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.
const disabled = todos.some(todo => todo.completed); | |
const isDisabled = todos.some(todo => todo.completed); |
src/Components/Footer.tsx
Outdated
<nav className="filter" data-cy="Filter"> | ||
<a | ||
href="#/" | ||
className={cn('filter__link', { | ||
selected: filteredBy === FilterBy.All, | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={(event: React.MouseEvent<HTMLAnchorElement>) => | ||
handleFilter(event, FilterBy.All) | ||
} | ||
> | ||
All | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={cn('filter__link', { | ||
selected: filteredBy === FilterBy.Active, | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={(event: React.MouseEvent<HTMLAnchorElement>) => | ||
handleFilter(event, FilterBy.Active) | ||
} | ||
> | ||
Active | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className={cn('filter__link', { | ||
selected: filteredBy === FilterBy.Completed, | ||
})} | ||
data-cy="FilterLinkCompleted" | ||
onClick={(event: React.MouseEvent<HTMLAnchorElement>) => | ||
handleFilter(event, FilterBy.Completed) | ||
} | ||
> | ||
Completed | ||
</a> | ||
</nav> |
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.
To make your code cleaner you could use map + Object.values(FilterBy)
src/Components/Header.tsx
Outdated
} | ||
|
||
const newTodo: Todo = { | ||
id: +new Date(), |
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.
lol)
src/Components/Header.tsx
Outdated
dispatch({ type: ActionNames.Add, payload: newTodo }); | ||
}; | ||
|
||
const 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.
const completed = | |
const isCompleted = |
src/Components/Header.tsx
Outdated
const completed = | ||
todos.length && todos.some(todo => todo.completed === false); | ||
|
||
const allCompleted = originalTodos.every(todo => 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.
const allCompleted = originalTodos.every(todo => todo.completed); | |
const isAllCompleted = originalTodos.every(todo => todo.completed); |
setFilteredBy(type); | ||
}, []); | ||
|
||
const value = useMemo( |
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.
🔥
DEMO LINK