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 task solution #797

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

Conversation

ydratsevska
Copy link

@ydratsevska ydratsevska commented Sep 26, 2023

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.

Deploy your app and add the link to preview so interviewers can test it.

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, take a look. Also, add loaders for todos when the user changes todo status or clicks toggleAll button

src/App.tsx Outdated

const USER_ID = 0;
const filterTodos = (todos: Todo[], filterStatus: Status): Todo[] => {

Choose a reason for hiding this comment

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

Move to utils/helpers folder

src/App.tsx Outdated
.catch(() => {
setErrorMessage(ErrorMessages.UnableAddTodo);
setTempTodo(null);
throw new Error();

Choose a reason for hiding this comment

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

You don't need to throw an error here as you handle errors in this block

src/App.tsx Outdated
Comment on lines 102 to 107
TodoSevise.updateTodo({
id: todo.id,
title: newTitle,
userId: todo.userId,
completed: todo.completed,
})

Choose a reason for hiding this comment

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

Suggested change
TodoSevise.updateTodo({
id: todo.id,
title: newTitle,
userId: todo.userId,
completed: todo.completed,
})
TodoSevise.updateTodo({
...todo,
title: newTitle,
})

src/App.tsx Outdated
Comment on lines 121 to 126
TodoSevise.updateTodo({
id: todo.id,
title: todo.title,
userId: todo.userId,
completed: !todo.completed,
})

Choose a reason for hiding this comment

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

The same

src/App.tsx Outdated
Comment on lines 172 to 196
<section className="todoapp__main" data-cy="TodoList">
{visibleTodos.map(todo => (
<TodoItem
todo={todo}
onTodoDelete={handleDeleteTodo}
isLoading={isLoading}
handleLoading={handleLoading}
key={todo.id}
onTodoUpdate={handleUpdateTodo}
onToggleChange={handleToggleChange}
/>
))}

{(tempTodo) && (
<TodoItem
todo={tempTodo}
onTodoDelete={handleDeleteTodo}
isLoading={isLoading}
handleLoading={handleLoading}
onTodoUpdate={handleUpdateTodo}
onToggleChange={handleToggleChange}
key={tempTodo.id}
/>
)}
</section>

Choose a reason for hiding this comment

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

Create a TodoList component

src/App.tsx Outdated
Comment on lines 210 to 212
<div
data-cy="ErrorNotification"
className={classNames(

Choose a reason for hiding this comment

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

Create an ErrorNotification component, and also move related logic to it too, this one:
image

setTodoTitle: (value: string) => void;
};

const USER_ID = 11516;

Choose a reason for hiding this comment

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

I see this constant created in the API too. It must be only one USER_ID, move it constants and use it

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.

Looks better, but you should get rid of all comments and there are still no loaders when the user changes the todo status
https://www.loom.com/share/b891778c03f74e2f9d8f14c3546b0014?sid=17028e00-2bb8-43b2-b192-005624336478

src/App.tsx Outdated

const USER_ID = 0;
import React, { useEffect, useRef, useState } from 'react';
// import classNames from 'classnames';

Choose a reason for hiding this comment

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

Remove comments

src/App.tsx Outdated
Comment on lines 43 to 53
/* const timerId: React.MutableRefObject<number> = useRef<number>(0);

useEffect(() => {
if (timerId.current) {
window.clearTimeout(timerId.current);
}

timerId.current = window.setTimeout(() => {
setErrorMessage('');
}, 3000);
}, [errorMessage]); */

Choose a reason for hiding this comment

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

Get rid of all comments in your code

Comment on lines 77 to 78
<>
<div

Choose a reason for hiding this comment

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

As you have only one element in a row you don't need to use the react fragment

Comment on lines 142 to 144
</div>

</div>

Choose a reason for hiding this comment

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

Don't leave blank lines between parent and child components

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 👍
But, don't forget to get rid of comments

.catch(() => {
setErrorMessage(ErrorMessages.UnableAddTodo);
setTempTodo(null);
// throw new Error();

Choose a reason for hiding this comment

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

Don't forget to remove comments

Comment on lines +159 to +183
{/* <section className="todoapp__main" data-cy="TodoList">
{visibleTodos.map(todo => (
<TodoItem
todo={todo}
onTodoDelete={handleDeleteTodo}
isLoading={isLoading}
handleLoading={handleLoading}
key={todo.id}
onTodoUpdate={handleUpdateTodo}
onToggleChange={handleToggleChange}
/>
))}

{(tempTodo) && (
<TodoItem
todo={tempTodo}
onTodoDelete={handleDeleteTodo}
isLoading={isLoading}
handleLoading={handleLoading}
onTodoUpdate={handleUpdateTodo}
onToggleChange={handleToggleChange}
key={tempTodo.id}
/>
)}
</section> */}

Choose a reason for hiding this comment

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

Get rid of all commented code

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.

2 participants