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

Develop #1056

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

Develop #1056

wants to merge 7 commits into from

Conversation

vanvalera
Copy link

Copy link

@SanyaBratashchuk SanyaBratashchuk left a comment

Choose a reason for hiding this comment

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

  1. handle plural it should be 1 item left but 2 items left
    image

Comment on lines 19 to 26
switch (filter) {
case Filter.ACTIVE:
return !todo.completed;
case Filter.COMPLETED:
return todo.completed;
default:
return true;
}

Choose a reason for hiding this comment

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

move filter inside swith to avoid extra iteration in default case

Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

looks strange
image

Comment on lines 30 to 41
useEffect(() => {
const savedTodos = localStorage.getItem('todos');

if (savedTodos) {
setTodos(JSON.parse(savedTodos));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
localStorage.setItem('todos', JSON.stringify(todos));
}, [todos]);

Choose a reason for hiding this comment

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

why do you need it in the header, move into state.tsx

Copy link
Author

Choose a reason for hiding this comment

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

what looks strange?))

@vanvalera vanvalera requested a review from etojeDenys October 3, 2024 06:45
Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Hi, the UI bug still not fixed from the previous review on the demo, pls fix it and make a deploy again after your changes
image

);
}

function handleUpdateTodo(id: number, newTitle: string) {

Choose a reason for hiding this comment

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

It is important to stick to one way of creating functions, fix it everywhere

Suggested change
function handleUpdateTodo(id: number, newTitle: string) {
const handleUpdateTodo = (id: number, newTitle: string) => {

{filteredTodos.map((todo: Todo) => (
<div
data-cy="Todo"
className={`todo ${todo.completed ? 'completed' : ''}`}

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

Copy link
Author

Choose a reason for hiding this comment

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

why i need use this lebrary? for me vanilla is better =)

Comment on lines 29 to 54
<a
href="#/"
className={`filter__link ${filter === Filter.ALL ? 'selected' : ''}`}
data-cy="FilterLinkAll"
onClick={() => handleFilterChange(Filter.ALL)}
>
All
</a>

<a
href="#/active"
className={`filter__link ${filter === Filter.ACTIVE ? 'selected' : ''}`}
data-cy="FilterLinkActive"
onClick={() => handleFilterChange(Filter.ACTIVE)}
>
Active
</a>

<a
href="#/completed"
className={`filter__link ${filter === Filter.COMPLETED ? 'selected' : ''}`}
data-cy="FilterLinkCompleted"
onClick={() => handleFilterChange(Filter.COMPLETED)}
>
Completed
</a>

Choose a reason for hiding this comment

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

Use Object.values(your enum) and render these options with map() method

className="todo__title"
onDoubleClick={() => setEditingTodoId(todo.id)}
>
{todo.title}

Choose a reason for hiding this comment

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

Use destructuring for todo

Comment on lines 35 to 44
onClick={() => {
const allCompleted = todos.every((todo: Todo) => todo.completed);

setTodos((currentTodos: Todo[]) =>
currentTodos.map((todo: Todo) => ({
...todo,
completed: !allCompleted,
})),
);
}}

Choose a reason for hiding this comment

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

Move this logic to the handler function

Comment on lines 51 to 62
value={{
todos,
setTodos,
title,
setTitle,
filter,
setFilter,
editingTodoId,
setEditingTodoId,
deleteTodo,
inputRef,
}}

Choose a reason for hiding this comment

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

Move these values to the object and pass it here


return (
<>
{todos.length > 0 ? (

Choose a reason for hiding this comment

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

Suggested change
{todos.length > 0 ? (
{todos.length > 0 && (

{filteredTodos.map((todo: Todo) => (
<div
data-cy="Todo"
className={`todo ${todo.completed ? 'completed' : ''}`}

Choose a reason for hiding this comment

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

Suggested change
className={`todo ${todo.completed ? 'completed' : ''}`}
className={cn('todo', {'completed':todo.completed})}

it's looks much better

also if we will need to add some another class here

without classnames:

className={`todo ${todo.completed ? 'completed' : ''} ${smth ? 'test-class' : ''}`}

with classnames:

className={cn('todo', {'completed':todo.completed, 'test-class': smth})}

@vanvalera vanvalera requested a review from etojeDenys October 3, 2024 08:44
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

good job

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.

4 participants