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

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

solution #1558

wants to merge 9 commits into from

Conversation

natalia646
Copy link

Copy link

@OkMoroz OkMoroz 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! 🎉 Keep up the great work!

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 a few comments. And you have a bug when you change the todo title to an empty string it deletes it but shows an error or sometimes it doesn't delete todo
https://www.loom.com/share/5a5cc06e2f6248d7b2a43d65d3eac3bc?sid=47b640b2-e2bc-4328-9cb4-2b1ba5317c83

src/App.tsx Outdated
const [todos, setTodos] = useState<Todo[]>([]);
const [activeStatus, setActiveStatus] = useState(Status.All);
const [tempTodo, setTempTodo] = useState<Todo | null>(null);
const [loadingTodos, setLoadingTodos] = useState<number[]>([]);

Choose a reason for hiding this comment

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

Suggested change
const [loadingTodos, setLoadingTodos] = useState<number[]>([]);
const [loadingTodoIds, setLoadingTodoIds] = useState<number[]>([]);

src/App.tsx Outdated
Comment on lines 71 to 76
const newTodos = [...currentTodos];
const index = newTodos.findIndex(todo => todo.id === updatedTodo.id);

newTodos.splice(index, 1, updatedTodo);

return newTodos;

Choose a reason for hiding this comment

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

Use map instead

currentTodos.map(todo => todo.id === updatedTodo.id ? updatedTodo : todo)

src/App.tsx Outdated
)
.catch(error => {
setErrorMessage(ErrorMessage.UnableToDelete);
throw 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 if you don't handle it on the next step. Fix in all places

}, 3000);

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

Choose a reason for hiding this comment

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

React Hook useEffect has a missing dependency: 'setErrorMessage'. Either include it or remove the dependency array


return onAddTodo(title.trim())
.then(() => setTitle(''))
.catch(() => {});

Choose a reason for hiding this comment

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

You should handle errors. If you have done it previously you don't need a catch at all


type Props = {
error: ErrorMessage;
isToogleAll: boolean | null;

Choose a reason for hiding this comment

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

In what case should it be null? it's a bit confusing

Copy link
Author

Choose a reason for hiding this comment

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

in this case boolean defines 'active' button or not, but null defines is the button in the input at all or not


return (
<header className="todoapp__header">
{isToogleAll !== null && (

Choose a reason for hiding this comment

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

Suggested change
{isToogleAll !== null && (
{isToogleAll && (

<div
data-cy="TodoLoader"
className={cn('modal overlay', {
'is-active': isLoading || todo.id === 0,

Choose a reason for hiding this comment

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

Suggested change
'is-active': isLoading || todo.id === 0,
'is-active': isLoading,

Copy link

@StasSokolov1 StasSokolov1 left a comment

Choose a reason for hiding this comment

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

I'm approving it, just a few minor comments!

export const USER_ID = 2135;

export const getTodos = () => {
return client.get<Todo[]>(`/todos?userId=${USER_ID}`);

Choose a reason for hiding this comment

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

let's move /todos into const and reuse

<a
key={status}
data-cy={`FilterLink${status}`}
href={status === 'All' ? '#/' : `#/${status.toLowerCase()}`}

Choose a reason for hiding this comment

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

Suggested change
href={status === 'All' ? '#/' : `#/${status.toLowerCase()}`}
href={status === Enum ? '#/' : `#/${status.toLowerCase()}`}

let's use enum

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