From 8f5128f4717ff01585fbd6a9e7cce1d432fd3cf0 Mon Sep 17 00:00:00 2001 From: Roman Martseniuk Date: Sat, 21 Dec 2024 12:40:30 +0200 Subject: [PATCH] complete 2.0 --- src/App.tsx | 4 ++-- src/components/Header/Header.tsx | 23 ++++++++++------------- src/components/TodoItem/TodoItem.tsx | 7 ++----- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 570b366a4..1bfad25d8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -227,9 +227,9 @@ export const App: React.FC = () => { inputRef={inputRef} inputText={inputText} setInputText={setInputText} - createFunc={handleAddingTodo} + handleCreateTodo={handleAddingTodo} todos={todos} - completeFunc={handleSwitchTodosStatus} + handleCompleteTodo={handleSwitchTodosStatus} loadingTodos={loadingTodos} /> diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index a26f87cf9..793764219 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -8,8 +8,8 @@ type Props = { inputRef: React.RefObject; inputText: string; setInputText: (value: string) => void; - createFunc: () => void; - completeFunc: () => void; + handleCreateTodo: () => void; + handleCompleteTodo: () => void; todos: Todo[]; loadingTodos: number[]; }; @@ -18,11 +18,13 @@ export const Header: React.FC = ({ inputRef, inputText, setInputText, - createFunc, - completeFunc, + handleCreateTodo, + handleCompleteTodo, todos, loadingTodos, }) => { + const includesActiveTodos = todos.filter(todo => !todo.completed).length > 0; + return (
{/* this button should have `active` class only if all todos are completed */} @@ -30,12 +32,10 @@ export const Header: React.FC = ({