diff --git a/src/App.js b/src/App.js index 17f8a82..8f8a929 100644 --- a/src/App.js +++ b/src/App.js @@ -5,7 +5,7 @@ import Footer from './components/Footer' import Tasks from './components/Tasks' import AddTask from './components/AddTask' import About from './components/About' - + const App = () => { const [showAddTask, setShowAddTask] = useState(false) const [tasks, setTasks] = useState([]) @@ -86,6 +86,9 @@ const App = () => { ) ) } + const edit=(id,text,date)=>{ + setTasks(tasks.map((task)=>task.id===id?{...task,text:text,date:date}:task)); + } return ( @@ -105,6 +108,7 @@ const App = () => { tasks={tasks} onDelete={deleteTask} onToggle={toggleReminder} + edit={edit} /> ) : ( 'No Tasks To Show' diff --git a/src/components/Task.js b/src/components/Task.js index 13c34c1..e8a9e3c 100644 --- a/src/components/Task.js +++ b/src/components/Task.js @@ -1,19 +1,40 @@ -import { FaTimes } from 'react-icons/fa' +import { useState } from 'react' +import { FaTimes,FaCheckCircle,FaPen} from 'react-icons/fa' -const Task = ({ task, onDelete, onToggle }) => { +const Task = ({ task, onDelete, onToggle,edit}) => { + const [showDiv,setShowDiv]=useState(false); + const [text,setText]=useState(''); + const [date,setDate]=useState(''); + + + const show=()=>{ + setShowDiv(!showDiv); + setText(task.text); + setDate(task.date); + } + const save=(id)=>{ + setShowDiv(!showDiv); + edit(id,text,date); + } return (
onToggle(task.id)} > -

- {task.text}{' '} +

+ {showDiv?setText(e.target.value)} />:

{task.text}

} onDelete(task.id)} />

-

{task.day}

+

+ {showDiv?setDate(e.target.value)} />: } + {showDiv?save(task.id)}/>:} +

) } diff --git a/src/components/Tasks.js b/src/components/Tasks.js index 7f67a1d..e06fcc5 100644 --- a/src/components/Tasks.js +++ b/src/components/Tasks.js @@ -1,13 +1,13 @@ import Task from './Task' -const Tasks = ({ tasks, onDelete, onToggle }) => { +const Tasks = ({ tasks, onDelete, onToggle,edit }) => { return ( <> {tasks.map((task, index) => ( - + ))} ) } - + export default Tasks diff --git a/src/index.css b/src/index.css index 29a8bf9..862d37f 100644 --- a/src/index.css +++ b/src/index.css @@ -4,7 +4,7 @@ box-sizing: border-box; margin: 0; padding: 0; -} +} body { font-family: 'Poppins', sans-serif; @@ -105,7 +105,16 @@ body { flex: 2; height: 20px; } +.text-line { + background-color: transparent; + outline: none; + outline-style: none; + border-top: none; + border-left: none; + border-right: none; + padding: 3px 10px; +} footer { margin-top: 30px; text-align: center;