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

need help #858

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

need help #858

wants to merge 4 commits into from

Conversation

HYPER2307
Copy link

@HYPER2307 HYPER2307 commented Oct 6, 2023

Copy link

@sTorba24 sTorba24 left a comment

Choose a reason for hiding this comment

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

Good start! Keep it up :)

Ask for help in your fe_chat and try to find a solution

then request review on github(only when you solve issues, because it's hard to contact on github, mentors can see your comments only after your task appears in queue).

@HYPER2307
Copy link
Author

image
image
image
image
this problems in form edit

@HYPER2307 HYPER2307 requested a review from sTorba24 October 9, 2023 20:31
Copy link

@lerastarynets lerastarynets left a comment

Choose a reason for hiding this comment

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

I see you did a hard work) Let's improve it a little bit

Comment on lines +9 to +26
todos: [],
setTodos: () => {},
errorMessage: '',
setErrorMessage: () => {},
preparedTodos: [],
sortQuery: '',
setSortQuery: () => {},
tempTodo: {
id: 0,
userId: 0,
title: '',
completed: false,
},
setTempTodo: () => {},
todosInProcess: [],
setTodosInProcess: () => {},
completedTodos: [],
});

Choose a reason for hiding this comment

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

try reducing the amount of props in the component, it's bad practice to have big amount of props

const preparedTodos = todos?.filter(todo => {
switch (sortQuery as SortType) {
case SortType.Active:
return todo.completed === false;

Choose a reason for hiding this comment

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

Suggested change
return todo.completed === false;
return !todo.completed;

return todo.completed === false;

case SortType.Completed:
return todo.completed === true;

Choose a reason for hiding this comment

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

Suggested change
return todo.completed === true;
return todo.completed;

}) || todos;

const completedTodos = todos?.filter(todo => (
todo.completed !== false

Choose a reason for hiding this comment

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

Suggested change
todo.completed !== false
todo.completed

Comment on lines 44 to 47
{/* <br />
Unable to delete a todo
<br />
Unable to update a todo */}

Choose a reason for hiding this comment

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

what is the purpose of these commented blocks?

} = useTodos();

const notCompletedTodosLength = todos?.filter(todo => (
todo.completed === false

Choose a reason for hiding this comment

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

Suggested change
todo.completed === false
!todo.completed

)).length;

const completedTodos = todos?.filter(todo => (
todo.completed !== false

Choose a reason for hiding this comment

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

Suggested change
todo.completed !== false
todo.completed

};

const toggleAllTodos = () => {
if (activeTodos?.length === 0) {

Choose a reason for hiding this comment

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

Suggested change
if (activeTodos?.length === 0) {
if (!activeTodos?.length) {

Comment on lines 188 to 191
onDoubleClick={() => {
setNewTitle(newTitle.trim());
setIsEditing(true);
}}

Choose a reason for hiding this comment

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

Pls move the function inside onDoubleClick handler to a separate const and use as a callback here

placeholder="Empty todo will be deleted"
value={newTitle}
onChange={(event) => setNewTitle(event.target.value)}
onBlur={() => handleOnBlur()}

Choose a reason for hiding this comment

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

Suggested change
onBlur={() => handleOnBlur()}
onBlur={handleOnBlur}

Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

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

Toggle all button works incorrect - it should make all uncompleted todos completed without additional requests, other way if all todos are completed - they should became active
https://github.com/mate-academy/react_todo-app-with-api/assets/61904995/d6c38594-5e40-4ef8-808e-9e4d458b2f5b

Should be 1 item left
2023-10-10_11h31_48

src/App.tsx Outdated

<TodoList />

{/* Hide the footer if there are no todos */}

Choose a reason for hiding this comment

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

Remove redundant comments

src/App.tsx Outdated
Comment on lines 24 to 25
{/* Notification is shown in case of any error */}
{/* Add the 'hidden' class to hide the message smoothly */}

Choose a reason for hiding this comment

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

Same

Comment on lines 55 to 66
const preparedTodos = todos?.filter(todo => {
switch (sortQuery as SortType) {
case SortType.Active:
return !todo.completed;

case SortType.Completed:
return todo.completed;

default:
return true;
}
}) || todos;

Choose a reason for hiding this comment

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

No need to filter in case SortType is all

type="button"
className="todoapp__clear-completed"
data-cy="ClearCompletedButton"
onClick={() => clearCompleted()}

Choose a reason for hiding this comment

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

Will works same but less callbacks

Suggested change
onClick={() => clearCompleted()}
onClick={clearCompleted}

Comment on lines 23 to 27
useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, [isInputDisabled, !todos?.length, todosInProcess]);

Choose a reason for hiding this comment

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

Check this
2023-10-10_11h35_05

Comment on lines 149 to 156
onClick={() => toggleAllTodos()}
/>
)}

{/* Add a todo on form submit */}
<form
onSubmit={(event) => addTodo(event)}
>

Choose a reason for hiding this comment

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

Suggested change
onClick={() => toggleAllTodos()}
/>
)}
{/* Add a todo on form submit */}
<form
onSubmit={(event) => addTodo(event)}
>
onClick={toggleAllTodos}
/>
)}
{/* Add a todo on form submit */}
<form
onSubmit={addTodo}
>

<span
data-cy="TodoTitle"
className="todo__title"
onDoubleClick={() => onDoubleClick()}

Choose a reason for hiding this comment

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

Suggested change
onDoubleClick={() => onDoubleClick()}
onDoubleClick={onDoubleClick}

@HYPER2307 HYPER2307 requested a review from IvanFesenko October 10, 2023 10:39
Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

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

Looks good.

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.

5 participants