-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathApp.tsx
More file actions
54 lines (49 loc) · 1.59 KB
/
App.tsx
File metadata and controls
54 lines (49 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { useState } from "react"
import "./App.scss"
import { ReactComponent as Add } from "./assets/icons/add.svg"
import AddEditTaskForm from "./components/AddEditTaskForm"
import Button from "./components/Button"
import DeleteModal from "./components/DeleteModal"
import TaskCard from "./components/TaskCard"
import { taskList as initialTaskList } from "./siteData/taskList"
type Task = {
id: string
title: string
priority: "high" | "medium" | "low"
status: string
progress: number
}
const App = () => {
const [tasks, setTasks] = useState<Task[]>(initialTaskList as Task[])
const [showAddEditModal, setShowAddEditModal] = useState(false)
const showDeleteModal = false
const handleAddTask = (title: string, priority: "high" | "medium" | "low") => {
const newTask: Task = {
id: Date.now().toString(),
title,
priority,
status: "To Do",
progress: 0,
}
setTasks([newTask, ...tasks]) // Add new task at the beginning
setShowAddEditModal(false)
}
return (
<div className="container">
<div className="page-wrapper">
<div className="top-title">
<h2>Task List</h2>
<Button title="Add Task" icon={<Add />} onClick={() => setShowAddEditModal(true)} />
</div>
<div className="task-container">
{tasks.map((task) => (
<TaskCard key={task.id} task={task} />
))}
</div>
</div>
{showAddEditModal && <AddEditTaskForm onClose={() => setShowAddEditModal(false)} onSave={handleAddTask} />}
{showDeleteModal && <DeleteModal />}
</div>
)
}
export default App