diff --git a/src/components/TaskForm.js b/src/components/TaskForm.js index 2feb54c..624190e 100644 --- a/src/components/TaskForm.js +++ b/src/components/TaskForm.js @@ -22,6 +22,7 @@ export default function TaskForm({ addTask, inputText }) { addTask(task) } + // Checks if the input has valid text and creates a new task const submitHandler = () => { if (text.trim() !== "") { newTask(text) diff --git a/src/components/TaskList.js b/src/components/TaskList.js index 3df87d5..f368a4c 100644 --- a/src/components/TaskList.js +++ b/src/components/TaskList.js @@ -5,10 +5,10 @@ import TaskForm from "./TaskForm" import styles from "../styles/TaskList.module.css" - export default function TaskList() { const [tasks, setTasks] = useState([]) const [notDoneCount, setNotDoneCount] = useState(0) + const [doneCount, setDoneCount] = useState(0) const [inputText, setInputText] = useState("") // Find the task position in the tasks array using its id @@ -21,6 +21,7 @@ export default function TaskList() { const doneTasks = messyTasks.filter((task) => task.isDone) const notDoneTasks = messyTasks.filter((task) => !task.isDone) setNotDoneCount(notDoneTasks.length) + setDoneCount(doneTasks.length) const sortedTasks = [...notDoneTasks, ...doneTasks] return sortedTasks } @@ -46,12 +47,11 @@ export default function TaskList() { const index = getIndexById(id) setInputText(tasks[index].text) deleteTask(id) - // TODO: Colocar uma href para focar no input e rolar a tela ate ele ao editar } return (