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 #821

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

Develop #821

wants to merge 8 commits into from

Conversation

Yevheniia-Sid
Copy link

Copy link

@roman-mirzoian roman-mirzoian 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, but there is quite a bit of work to be done.
Now, after pressing Enter, it does not update there (but it should according to the task):
https://gyazo.com/4b857711b0dde3b29be9273e13ae73fd

src/App.tsx Outdated
@@ -1,24 +1,317 @@
/* eslint-disable max-len */
/* eslint-disable jsx-a11y/control-has-associated-label */

Choose a reason for hiding this comment

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

Try to rewrite the code so that it is not necessary to disable the linter

src/App.tsx Outdated

export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [isLoadig, setIsLoading] = useState(false);

Choose a reason for hiding this comment

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

Suggested change
const [isLoadig, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false);

src/App.tsx Outdated

<div className="todoapp__content">
<header className="todoapp__header">
{/* this buttons is active only if there are some active todos */}

Choose a reason for hiding this comment

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

Do not leave unnecessary comments.

src/App.tsx Outdated
/>
)}

{/* Add a todo on form submit */}

Choose a reason for hiding this comment

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

Do not leave unnecessary comments.

src/App.tsx Outdated
handleClearCompleted={handleClearCompleted}
/>
)}

Choose a reason for hiding this comment

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

Suggested change

return (
<footer className="todoapp__footer" data-cy="Footer">
<span className="todo-count" data-cy="TodosCounter">
{`${countActiveTodos} items left`}

Choose a reason for hiding this comment

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

If there is one item, there should not be a plural in the text.

Copy link
Author

Choose a reason for hiding this comment

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

If there is one item, there should not be a plural in the text.

I can't change it because the tests failed

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.

Good work 👍
Left some suggestions, check them

src/App.tsx Outdated
Comment on lines 33 to 39
setIsLoading(false);
})
.catch(error => {
// eslint-disable-next-line no-console
console.warn(error);
setTodoError(ErrorType.GetData);
setIsLoading(false);

Choose a reason for hiding this comment

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

You reset the loading state in both cases so move it to the finally block

src/App.tsx Outdated
Comment on lines 43 to 49
useEffect(() => {
const timeoutId = setTimeout(() => {
setTodoError(null);
}, 3000);

return () => clearTimeout(timeoutId);
}, []);

Choose a reason for hiding this comment

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

Suggested change
useEffect(() => {
const timeoutId = setTimeout(() => {
setTodoError(null);
}, 3000);
return () => clearTimeout(timeoutId);
}, []);
useEffect(() => {
if (!todoError) {
return;
}
const timeoutId = setTimeout(() => {
setTodoError(null);
}, 3000);
return () => clearTimeout(timeoutId);
}, [todoError]);

Add dependency to create timeout every time you have an error.
Also, create an ErrorNotification component and move this logic to it too.

src/App.tsx Outdated
Comment on lines 76 to 78
setTimeout(() => {
setTodoError(null);
}, 3000);

Choose a reason for hiding this comment

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

Set this time in useEffect as I mentioned before

src/App.tsx Outdated
Comment on lines 84 to 85
showError(ErrorType.Title);
} else {

Choose a reason for hiding this comment

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

Suggested change
showError(ErrorType.Title);
} else {
showError(ErrorType.Title);
return;
}
// Other code

Try to avoid else

src/App.tsx Outdated
<h1 className="todoapp__title">todos</h1>

<div className="todoapp__content">
<header className="todoapp__header">

Choose a reason for hiding this comment

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

Create a Header component

src/App.tsx Outdated
</div>

<div
data-cy="ErrorNotification"

Choose a reason for hiding this comment

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

Create an ErrorNotification component

Comment on lines 40 to 42
if (newTitle === todo.title) {
return;
}

Choose a reason for hiding this comment

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

Suggested change
if (newTitle === todo.title) {
return;
}
if (newTitle === todo.title) {
setIsEditing(false);
return;
}

Maybe you should add setIsEditing(false); here, I can't close editing if the title is the same

return;
}

if (newTitle.trim() === '') {

Choose a reason for hiding this comment

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

Suggested change
if (newTitle.trim() === '') {
if (!newTitle.trim()) {

Don't compare it with an empty string, just check if exists

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