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

solved task #1486

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

solved task #1486

wants to merge 7 commits into from

Conversation

PikalovAndrey
Copy link

Copy link

@Ann-Maksay Ann-Maksay left a comment

Choose a reason for hiding this comment

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

Nice work, but you should consider code consistency. For example, if some logic is in the hook, it should all be there. I won't reject it, but I highly recommend you to pay attention to it.
And a lot of code duplication.

setLoadingTodosCount,
setTodos,
setInputValue,
} = useTodos(setErrorMessage);

Choose a reason for hiding this comment

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

In my opinion, it's rather confusing. Part of the logic associated with todo is in the custom hook, and the other part is spread across components. It is better to either put everything in the hook or not use it at all.

Choose a reason for hiding this comment

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

Good point!

src/App.tsx Outdated

Promise.all(
todosForDeleting.map(id =>
deleteTodos(id)

Choose a reason for hiding this comment

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

I'd rather think about how to avoid repeating the code. It uses the same logic as deleting a single element, so maybe you should think about how to reuse the already existing code?
This applies to deletion as well as any updates.

onSubmit,
onInputChange,
}) => {
const isLoading = loadingTodos.length > 0;

Choose a reason for hiding this comment

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

Suggested change
const isLoading = loadingTodos.length > 0;
!!loadingTodos.length

onTodoDelete: (todoId: number) => void;
onTodoToggle: (todoId: number, currentCompletedStatus: boolean) => void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onUpdateTodo: any;

Choose a reason for hiding this comment

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

Suggested change
onUpdateTodo: any;
onUpdateTodo: Promise<Todo>;

Wouldn't that be better? Or Promise<unknown> at least

Copy link

@igorkruz igorkruz 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 👍
let's improve your solution

setLoadingTodosCount,
setTodos,
setInputValue,
} = useTodos(setErrorMessage);

Choose a reason for hiding this comment

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

Good point!

return (
<footer className="todoapp__footer" data-cy="Footer">
<span className="todo-count" data-cy="TodosCounter">
{todos.length - completedTodos.length} items left

Choose a reason for hiding this comment

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

Create a variable for this calculation

if (isEditing && inputRef.current) {
inputRef.current.focus();
}
}, [isEditing, inputRef]); //?

Choose a reason for hiding this comment

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

Delete commented code

Comment on lines 19 to 22
? operation(id, { completed: newStatus })
: deleteOperation
? deleteOperation(id)
: operation(id);

Choose a reason for hiding this comment

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

The nested ternary operator can be hard to read. Consider refactoring that section for clarity.

src/App.tsx Outdated
Comment on lines 47 to 55
useEffect(() => {
if (errorMessage) {
const timer = setTimeout(() => {
setErrorMessage(ErrorMessages.NO_ERRORS);
}, 3000);

return () => clearTimeout(timer);
}
}, [errorMessage]);

Choose a reason for hiding this comment

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

Move to error notification file

Copy link

@KosolapovAnatolii KosolapovAnatolii left a comment

Choose a reason for hiding this comment

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

2024-10-23.14.25.15.mov

Good job! Left fix few bugs. Watch video, I've showed input doesn't recive focus after adding new todo, but it has to.
Fix it and go forward to the next task!
P.s.: cool case to slove this task using custom hook! 🆒 😎

src/components/Errors.tsx Outdated Show resolved Hide resolved
@PikalovAndrey
Copy link
Author

It's strange, that you have such behaviour, because from my side it works perfectly.🤨

Copy link

@KosolapovAnatolii KosolapovAnatolii left a comment

Choose a reason for hiding this comment

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

Completed! 🔥 🔥

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