diff --git a/src/App.jsx b/src/App.jsx index e9bc2ca..e6b0afb 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1 +1,180 @@ -import React from 'react';export default function App(){const n="{{ Nazwa }}",d="{{ Opis }}",s="{{ Styl }}",f="{{ Funkcje }}".split(", ");return(

{n}

{d}


Style: {s}

);} \ No newline at end of file +import React, { useState, useEffect } from 'react'; + +/** + * Główny komponent aplikacji React. + * Zmodyfikowany w celu zapewnienia pełnej funkcjonalności zarządzania zadaniami + * z nowoczesnym interfejsem użytkownika i obsługą stanu. + */ +const App = () => { + const [tasks, setTasks] = useState([ + { id: 1, text: 'Zainstalować zależności', completed: true }, + { id: 2, text: 'Zaimplementować logikę biznesową', completed: false } + ]); + const [inputValue, setInputValue] = useState(''); + + const handleAddTask = (e) => { + e.preventDefault(); + if (inputValue.trim() === '') return; + + const newTask = { + id: Date.now(), + text: inputValue, + completed: false + }; + + setTasks([...tasks, newTask]); + setInputValue(''); + }; + + const toggleTask = (id) => { + setTasks(tasks.map(task => + task.id === id ? { ...task, completed: !task.completed } : task + )); + }; + + const deleteTask = (id) => { + setTasks(tasks.filter(task => task.id !== id)); + }; + + const clearCompleted = () => { + setTasks(tasks.filter(task => !task.completed)); + }; + + return ( +
+
+

+ Menedżer Projektu +

+ +
+ setInputValue(e.target.value)} + placeholder="Co należy zrobić?" + style={{ + flex: 1, + padding: '12px 15px', + borderRadius: '8px', + border: '1px solid #dfe6e9', + fontSize: '16px', + outline: 'none' + }} + /> + +
+ +
+ {tasks.length === 0 ? ( +

Brak zadań do wyświetlenia.

+ ) : ( + tasks.map(task => ( +
+
+ toggleTask(task.id)} + style={{ width: '18px', height: '18px', cursor: 'pointer' }} + /> + + {task.text} + +
+ +
+ )) + )} +
+ + {tasks.length > 0 && ( +
+ Pozostało: {tasks.filter(t => !t.completed).length} + +
+ )} +
+
+ ); +}; + +export default App; \ No newline at end of file