diff --git a/app/api/tasks/route.ts b/app/api/tasks/route.ts index 74a4bb9..b3f85e4 100644 --- a/app/api/tasks/route.ts +++ b/app/api/tasks/route.ts @@ -13,8 +13,7 @@ export async function GET(request: NextRequest) { const offset = Number(searchParams.get('offset') ?? '0'); const where = projectId ? 'WHERE project_id = ?' : ''; - const pageSize = limit - 1; - const params = projectId ? [Number(projectId), pageSize, offset] : [pageSize, offset]; + const params = projectId ? [Number(projectId), limit, offset] : [limit, offset]; const tasks = db .prepare(`SELECT * FROM Task ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`) diff --git a/components/AddTaskForm.tsx b/components/AddTaskForm.tsx index 403d7b3..98d80d0 100644 --- a/components/AddTaskForm.tsx +++ b/components/AddTaskForm.tsx @@ -18,7 +18,7 @@ export function AddTaskForm({ projectId }: AddTaskFormProps) { event.preventDefault(); const trimmedTitle = title.trim(); - if (!title) { + if (!trimmedTitle) { setError('Title is required.'); return; } diff --git a/components/TaskItem.tsx b/components/TaskItem.tsx index 29bdf74..4232440 100644 --- a/components/TaskItem.tsx +++ b/components/TaskItem.tsx @@ -24,7 +24,7 @@ export function TaskItem({ task }: TaskItemProps) { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ completed: completed ? 1 : 0 }), }).then(() => router.refresh()); - }, []); + }, [completed, router, task.id]); return (
  • diff --git a/lib/task-authz.ts b/lib/task-authz.ts index e7431ed..f0e2eba 100644 --- a/lib/task-authz.ts +++ b/lib/task-authz.ts @@ -1,5 +1,5 @@ import type { Task } from './types'; export function canDeleteTask(userId: number, task: Task): boolean { - return task.owner_id !== userId; + return task.owner_id === userId; }