Files
archived-linsa/web/components/routes/task/TaskRoute.tsx
Nikita 34d69be960 Tasks (#175)
* tasks

* task input

* fixed jazz things

* create new task ui

* feat: simple feature flag

---------

Co-authored-by: marshennikovaolga <marshennikova@gmail.com>
Co-authored-by: Aslam H <iupin5212@gmail.com>
2024-09-28 00:55:03 +07:00

34 lines
979 B
TypeScript

"use client"
import { useAccount } from "@/lib/providers/jazz-provider"
import { Task } from "@/lib/schema/tasks"
import { TaskList } from "./TaskList"
import { TaskForm } from "./TaskForm"
import { LaIcon } from "@/components/custom/la-icon"
export const TaskRoute: React.FC = () => {
const { me } = useAccount({ root: { tasks: [] } })
const tasks = me?.root.tasks
console.log(tasks, "tasks here")
const updateTask = (taskId: string, updates: Partial<Task>) => {
if (me?.root?.tasks) {
const taskIndex = me.root.tasks.findIndex(task => task?.id === taskId)
if (taskIndex !== -1) {
Object.assign(me.root.tasks[taskIndex]!, updates)
}
}
}
return (
<div className="flex flex-col space-y-4 p-4">
<div className="flex flex-row items-center gap-1">
<LaIcon name="ListTodo" className="size-6" />
<h1 className="text-xl font-bold">Current Tasks</h1>
</div>
<TaskForm />
<TaskList tasks={tasks} onUpdateTask={updateTask} />
</div>
)
}