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

Solution #814

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

Solution #814

wants to merge 7 commits into from

Conversation

viktoria-roik
Copy link

@viktoria-roik viktoria-roik commented Sep 27, 2023

Copy link

@Taras2705 Taras2705 left a comment

Choose a reason for hiding this comment

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

good progress!!

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.
Also, why is there such a large indent on the left when editing the title?
image

src/App.tsx Outdated
@@ -1,24 +1,288 @@
/* 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
Comment on lines 51 to 57
useEffect(() => {
if (errorMessage) {
setTimeout(() => {
setErrorMessage(Error.None);
}, 3000);
}
}, [errorMessage]);

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Please read the article, there is an example of how to correctly work with timers in useEffect.

src/App.tsx Outdated
Comment on lines 160 to 163
const promiseArray = (
allTodosAreCompleted
? completedTodosCount
: activeTodosCount).map((todo: { id: number; completed: boolean; }) => client.patch(`/todos/${todo.id}`, { completed: !todo.completed }));

Choose a reason for hiding this comment

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

For better readability, it is better to split the code into small parts

src/App.tsx Outdated
const [errorMessage, setErrorMessage] = useState(Error.None);
const [value, setValue] = useState('');
const [isSubmitted, setIsSubmitted] = useState(false);
const [areSubmiting, setAreSubmiting] = 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 [areSubmiting, setAreSubmiting] = useState(false);
const [isSubmiting, setIsSubmiting] = useState(false);

src/App.tsx Outdated

<div className="todoapp__content">
<header className="todoapp__header">
{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 && (

Comment on lines 133 to 135
disabled={processingIds.includes(todo.id)
|| togglingId === todo.id
|| areSubmiting}

Choose a reason for hiding this comment

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

It is better to put it in a separate variable.

Comment on lines 144 to 146
'is-active': processingIds.includes(todo.id)
|| togglingId === todo.id
|| areSubmiting,

Choose a reason for hiding this comment

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

It is better to put it in a separate variable.

Comment on lines 27 to 33
{/* <button
type="button"
className="todo__remove"
data-cy="TodoDelete"
>
×
</button> */}

Choose a reason for hiding this comment

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

What is it?


<div
data-cy="TodoLoader"
className={className('modal overlay', {

Choose a reason for hiding this comment

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

Suggested change
className={className('modal overlay', {
className={className('modal', 'overlay', {

export function getItemsLeftCountMessage(activeTodos: Todo[]) {
switch (activeTodos.length) {
case 1:
return '1 items left';

Choose a reason for hiding this comment

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

Suggested change
return '1 items left';
return '1 item left';

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.

Almost done!

src/App.tsx Outdated
Comment on lines 51 to 57
useEffect(() => {
if (errorMessage) {
setTimeout(() => {
setErrorMessage(Error.None);
}, 3000);
}
}, [errorMessage]);

Choose a reason for hiding this comment

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

Please read the article, there is an example of how to correctly work with timers in useEffect.

src/App.tsx Outdated
Comment on lines 269 to 274
style={{
visibility:
completedTodosCount.length
? 'visible'
: 'hidden',
}}

Choose a reason for hiding this comment

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

Using inline styles is a bad practice, use css instead.

Comment on lines 8 to 11
case Status.All: {
filteredTodos = todos;
break;
}

Choose a reason for hiding this comment

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

You do the same in the default block.

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.

Wel done 👍

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