useProjectTasks() hook
useProjectTasks() is the project task board hook. It returns the current task items for one project and exposes the task-level create, archive, and unarchive helpers used by task board screens.Usage
The following example shows a basic usage of useProjectTasks().
import { useProjectTasks } from '@wacht/nextjs';export default function ProjectTasks({ projectId,}: { projectId: string;}) { const { tasks, createTask } = useProjectTasks(projectId, true, { limit: 40, }); return ( <div> <button onClick={async () => { await createTask({ title: 'Review webhook errors', priority: 'high', }); }} > New task </button> <ul> {tasks.map((task) => ( <li key={task.id}>{task.title}</li> ))} </ul> </div> );}Return value
The hook returns the following fields and methods.
›tasks?: ProjectTaskBoardItem[] | undefined;
tasks?: ProjectTaskBoardItem[] | undefined;Flattened task items for the current filter.
›createTask?: (request: CreateProjectTaskBoardItemRequest, files?: File[]) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;
createTask?: (request: CreateProjectTaskBoardItemRequest, files?: File[]) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;Creates a task board item and returns the created item on `result.data`.
›archiveTask?: (itemId: string) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;
archiveTask?: (itemId: string) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;Archives one task item and returns the archived item on `result.data`.
›unarchiveTask?: (itemId: string) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;
unarchiveTask?: (itemId: string) => Promise<ApiResult<ProjectTaskBoardItem>> | undefined;Restores one task item and returns the restored item on `result.data`.
Overview
This hook is a paged task board list, not a single task detail hook. It can filter the task list by status, include archived items, or show archived items only, which is why it works for the active board and the archived column with the same API.