-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
commited unworking code #804
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, your project is not reachable via the demo link(
src/components/Todos.tsx
Outdated
removeItem, | ||
markAsCompleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u don't use these 2 functions in this component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls watch the video review via the link :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to fix this difference in height when user tries to edit the todo
https://github.com/mate-academy/react_todo-app/assets/70220667/e87259cc-b553-4ed8-8eb8-a2df19c16ff5
src/components/Todos.tsx
Outdated
{filter === 'all' && ( | ||
todos | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} | ||
{filter === 'active' && ( | ||
todos | ||
.filter((todoItem) => todoItem.completed === false) | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} | ||
{filter === 'completed' && ( | ||
todos | ||
.filter((todoItem) => todoItem.completed === true) | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks too complex, just filter the array before the jsx, save in some variable and map in return
src/components/Footer.tsx
Outdated
|
||
export const Footer = () => { | ||
const { state: { todos }, dispatch } = React.useContext(TodosContext); | ||
const [state, setState] = useState(todos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be the simple variable instead of the state
src/App.tsx
Outdated
<input type="text" className="edit" /> | ||
</li> | ||
const { state: { todos } } = React.useContext(TodosContext); | ||
const [tasksLength, setTasksLength] = useState(todos.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/Main.tsx
Outdated
if (labelClick % 2 === 0) { | ||
dispatch({ type: 'MARK_ALL_AS_UNCOMPLETED' }); | ||
} else { | ||
dispatch({ type: 'MARK_ALL_AS_COMPLETED' }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (labelClick % 2 === 0) { | |
dispatch({ type: 'MARK_ALL_AS_UNCOMPLETED' }); | |
} else { | |
dispatch({ type: 'MARK_ALL_AS_COMPLETED' }); | |
} | |
dispatch({ type: !(labelClick % 2) | |
? 'MARK_ALL_AS_UNCOMPLETED' | |
: 'MARK_ALL_AS_COMPLETED' | |
}); |
src/components/Main.tsx
Outdated
if (!todos.length) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<section className="main"> | ||
<input | ||
onClick={handleToggleAll} | ||
type="checkbox" | ||
id="toggle-all" | ||
className="toggle-all" | ||
data-cy="toggleAll" | ||
/> | ||
<label | ||
htmlFor="toggle-all" | ||
> | ||
Mark all as completed | ||
</label> | ||
<Todos /> | ||
</section> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!todos.length) { | |
return null; | |
} | |
return ( | |
<section className="main"> | |
<input | |
onClick={handleToggleAll} | |
type="checkbox" | |
id="toggle-all" | |
className="toggle-all" | |
data-cy="toggleAll" | |
/> | |
<label | |
htmlFor="toggle-all" | |
> | |
Mark all as completed | |
</label> | |
<Todos /> | |
</section> | |
); | |
return ( | |
{ todos.length > 0 && ( | |
<section className="main"> | |
<input | |
onClick={handleToggleAll} | |
type="checkbox" | |
id="toggle-all" | |
className="toggle-all" | |
data-cy="toggleAll" | |
/> | |
<label | |
htmlFor="toggle-all" | |
> | |
Mark all as completed | |
</label> | |
<Todos /> | |
</section> | |
) | |
} | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not fixed
src/components/Todos.tsx
Outdated
return ( | ||
<ul className="todo-list" data-cy="todoList"> | ||
{filter === 'all' && ( | ||
todos | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} | ||
{filter === 'active' && ( | ||
activeFilter | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} | ||
{filter === 'completed' && ( | ||
complietedFilter | ||
.map((todoItem) => ( | ||
<Todo | ||
key={todoItem.id} | ||
todoItem={todoItem} | ||
onItemDelete={handleDelete} | ||
/> | ||
)) | ||
)} | ||
|
||
</ul> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prepare filtered todos before render just, and then use only variable filteredTodos
, now logic is too complicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also create an enum for filter types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/Main.tsx
Outdated
if (!todos.length) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<section className="main"> | ||
<input | ||
onClick={handleToggleAll} | ||
type="checkbox" | ||
id="toggle-all" | ||
className="toggle-all" | ||
data-cy="toggleAll" | ||
/> | ||
<label | ||
htmlFor="toggle-all" | ||
> | ||
Mark all as completed | ||
</label> | ||
<Todos /> | ||
</section> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve it, but still not clear that i'm able to remove todo
https://OPTIMISTIXX.github.io/react_todo-app/