diff --git a/src/pages/Index.jsx b/src/pages/Index.jsx index 3922835..bbb3c0f 100644 --- a/src/pages/Index.jsx +++ b/src/pages/Index.jsx @@ -1,20 +1,85 @@ -// Update this page (the content is just a fallback if you fail and example) -// Use chakra-ui -import { Container, Text, VStack } from "@chakra-ui/react"; - -// Example of using react-icons -// import { FaRocket } from "react-icons/fa"; -// } size="lg" />; // IconButton would also have to be imported from chakra +import React, { useState } from 'react'; +import { Container, VStack, HStack, Input, Button, Text, IconButton, Checkbox } from "@chakra-ui/react"; +import { FaEdit, FaTrash } from "react-icons/fa"; const Index = () => { + const [tasks, setTasks] = useState([]); + const [newTask, setNewTask] = useState(""); + const [editingTask, setEditingTask] = useState(null); + const [editingText, setEditingText] = useState(""); + + const addTask = () => { + if (newTask.trim() !== "") { + setTasks([...tasks, { text: newTask, completed: false }]); + setNewTask(""); + } + }; + + const deleteTask = (index) => { + const newTasks = tasks.filter((_, i) => i !== index); + setTasks(newTasks); + }; + + const editTask = (index) => { + setEditingTask(index); + setEditingText(tasks[index].text); + }; + + const saveTask = (index) => { + const newTasks = tasks.map((task, i) => (i === index ? { ...task, text: editingText } : task)); + setTasks(newTasks); + setEditingTask(null); + setEditingText(""); + }; + + const toggleComplete = (index) => { + const newTasks = tasks.map((task, i) => (i === index ? { ...task, completed: !task.completed } : task)); + setTasks(newTasks); + }; + return ( - - - Your Blank Canvas - Chat with the agent to start making edits. + + + + setNewTask(e.target.value)} + /> + + + + {tasks.map((task, index) => ( + + toggleComplete(index)}> + {editingTask === index ? ( + setEditingText(e.target.value)} + onBlur={() => saveTask(index)} + /> + ) : ( + {task.text} + )} + + + } + onClick={() => editTask(index)} + aria-label="Edit Task" + /> + } + onClick={() => deleteTask(index)} + aria-label="Delete Task" + /> + + + ))} + ); }; -export default Index; +export default Index; \ No newline at end of file