diff --git a/bun.lockb b/bun.lockb index 8d317c47..dc8827a8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/web/components/routes/task/TaskForm.tsx b/web/components/routes/task/TaskForm.tsx index 8d1d15ad..7304a12a 100644 --- a/web/components/routes/task/TaskForm.tsx +++ b/web/components/routes/task/TaskForm.tsx @@ -1,25 +1,30 @@ "use client" import { useState, useEffect, useRef } from "react" import { motion, AnimatePresence } from "framer-motion" -import { Task } from "@/lib/schema/tasks" +import { ListOfTasks, Task } from "@/lib/schema/tasks" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { useAccount } from "@/lib/providers/jazz-provider" import { LaIcon } from "@/components/custom/la-icon" -interface TaskFormProps { - onAddTask: (task: Task) => void -} +interface TaskFormProps {} -export const TaskForm: React.FC = ({ onAddTask }) => { +export const TaskForm: React.FC = ({}) => { const [title, setTitle] = useState("") const [inputVisible, setInputVisible] = useState(false) - const { me } = useAccount() + const { me } = useAccount({ root: {} }) const inputRef = useRef(null) const handleSubmit = (e: React.FormEvent) => { e.preventDefault() - if (title.trim() && me) { + console.log(title.trim()) + console.log(me, "me") + if (title.trim()) { + if (me?.root?.tasks === undefined) { + if (!me) return + me.root.tasks = ListOfTasks.create([], { owner: me }) + } + const newTask = Task.create( { title, @@ -30,7 +35,7 @@ export const TaskForm: React.FC = ({ onAddTask }) => { }, { owner: me._owner } ) - onAddTask(newTask) + me.root.tasks?.push(newTask) resetForm() } } diff --git a/web/components/routes/task/TaskList.tsx b/web/components/routes/task/TaskList.tsx index c5497b52..41e1e1d5 100644 --- a/web/components/routes/task/TaskList.tsx +++ b/web/components/routes/task/TaskList.tsx @@ -1,18 +1,16 @@ import React from "react" -import { Task } from "@/lib/schema/tasks" +import { ListOfTasks, Task } from "@/lib/schema/tasks" import { TaskItem } from "./TaskItem" interface TaskListProps { - tasks: Task[] + tasks?: ListOfTasks onUpdateTask: (taskId: string, updates: Partial) => void } export const TaskList: React.FC = ({ tasks, onUpdateTask }) => { return (
    - {tasks.map(task => ( - - ))} + {tasks?.map(task => task?.id && )}
) } diff --git a/web/components/routes/task/TaskRoute.tsx b/web/components/routes/task/TaskRoute.tsx index 7ef2d180..88cad071 100644 --- a/web/components/routes/task/TaskRoute.tsx +++ b/web/components/routes/task/TaskRoute.tsx @@ -7,13 +7,8 @@ import { TaskForm } from "./TaskForm" export const TaskRoute: React.FC = () => { const { me } = useAccount({ root: { tasks: [] } }) - const tasks = me?.root?.tasks || [] - - const addTask = (newTask: Task) => { - if (me?.root?.tasks) { - me.root.tasks.push(newTask) - } - } + const tasks = me?.root.tasks + console.log(tasks, "tasks here") const updateTask = (taskId: string, updates: Partial) => { if (me?.root?.tasks) { @@ -27,8 +22,8 @@ export const TaskRoute: React.FC = () => { return (

Tasks

- - + +
) } diff --git a/web/lib/schema/tasks.ts b/web/lib/schema/tasks.ts index 71cf643f..31451616 100644 --- a/web/lib/schema/tasks.ts +++ b/web/lib/schema/tasks.ts @@ -6,6 +6,7 @@ export class Task extends CoMap { status = co.literal("todo", "in_progress", "done") createdAt = co.encoded(Encoders.Date) updatedAt = co.encoded(Encoders.Date) + completedAt = co.optional.encoded(Encoders.Date) } export class ListOfTasks extends CoList.Of(co.ref(Task)) {} diff --git a/web/middleware.ts b/web/middleware.ts index 9081e846..32be843a 100644 --- a/web/middleware.ts +++ b/web/middleware.ts @@ -10,7 +10,8 @@ const ROUTE_PATTERNS = { "/search(.*)", "/settings(.*)", "/tauri(.*)", - "/onboarding(.*)" + "/onboarding(.*)", + "/tasks(.*)" ] }