From 38182aa402984fda71e90b6ed7a9c570cb679f10 Mon Sep 17 00:00:00 2001 From: Rock3r Date: Mon, 27 Apr 2026 14:09:45 +0200 Subject: [PATCH] feat(task): add functionality to create new tasks using controlled input --- src/App.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 7c16a26..87342c6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,11 +3,35 @@ import type { Task } from "./assets/types/task"; function App() { const [tasks, setTasks] = useState([]); + const [inputValue, setInputValue] = useState(''); + + const addTask = () => { + if (inputValue.trim() === '') return; + + const newTask: Task = { + id: Date.now(), + title: inputValue, + completed: false, + createdAt: new Date().toISOString() + }; + + setTasks([...tasks, newTask]); + + setInputValue(''); + }; return (

SmartX Task Manager

+
+ setInputValue(e.target.value)} + /> + +
{tasks.length === 0 ? (

No task found. Lets add!