Skip to content
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 solution #2684

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

TargoniyAnatoliy
Copy link

Copy link

@StasSokolov1 StasSokolov1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done

src/App.tsx Outdated
.filter(todo => todo.title.toLowerCase().includes(query.toLowerCase()))
.filter(todo => {
switch (filterParameter) {
case 'completed':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move completed, active, all to the enum

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum Filters already exists in types folder: enum Filters {
All = 'all',
Active = 'active',
Completed = 'completed',
}

</tr>
) : (
todos.map(todo => (
<tr data-cy="todo" className="" key={todo.id}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<tr data-cy="todo" className="" key={todo.id}>
<tr data-cy="todo" key={todo.id}>

let's remove redundant class name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to use 'has-background-info-light' class if todo is selected

Comment on lines +54 to +58
{todo.completed ? (
<strong className="has-text-success">Done</strong>
) : (
<strong className="has-text-danger">Planned</strong>
)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use one strong tag and just change class name and content

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Desided to use these aproach, because it's more obvious and simplest than using many conditions in className and content

Comment on lines +21 to +23
<option value={Filters.All}>All</option>
<option value={Filters.Active}>Active</option>
<option value={Filters.Completed}>Completed</option>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can show these options using .map()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good idea, but I don't know how to use map to the enum object Filters: enum Filters {
All = 'all',
Active = 'active',
Completed = 'completed',
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good idea, but I don't know how to use map to the enum object Filters: enum Filters { All = 'all', Active = 'active', Completed = 'completed', }

You can use Object.values/key/entries to convert enum into an array

Copy link

@BudnikOleksii BudnikOleksii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +21 to +23
<option value={Filters.All}>All</option>
<option value={Filters.Active}>Active</option>
<option value={Filters.Completed}>Completed</option>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good idea, but I don't know how to use map to the enum object Filters: enum Filters { All = 'all', Active = 'active', Completed = 'completed', }

You can use Object.values/key/entries to convert enum into an array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants