-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathTaskItem.tsx
More file actions
21 lines (18 loc) · 670 Bytes
/
TaskItem.tsx
File metadata and controls
21 lines (18 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import React from "react"
import { Task } from "@/lib/schema/tasks"
import { Checkbox } from "@/components/ui/checkbox"
interface TaskItemProps {
task: Task
onUpdateTask: (taskId: string, updates: Partial<Task>) => void
}
export const TaskItem: React.FC<TaskItemProps> = ({ task, onUpdateTask }) => {
const statusChange = (checked: boolean) => {
onUpdateTask(task.id, { status: checked ? "done" : "todo" })
}
return (
<li className="flex items-center space-x-2">
<Checkbox checked={task.status === "done"} onCheckedChange={statusChange} />
<span className={task.status === "done" ? "text-foreground line-through" : ""}>{task.title}</span>
</li>
)
}