mirror of
https://github.com/temetro/temetro.git
synced 2026-08-04 07:58:13 +00:00
25254dd4c1
Add the tasks table, validation, service and routes (/api/tasks with a PATCH for partial updates / the done toggle, RBAC-gated) and the frontend data module. The tasks board now loads, creates and toggles real data (optimistic toggle with rollback). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { apiFetch } from "@/lib/api-client";
|
|
|
|
// A care-team task. Mirrors the backend `src/types/task.ts`. Scoped to the active
|
|
// clinic (shared across the care team).
|
|
export type Priority = "high" | "medium" | "low";
|
|
|
|
export type Task = {
|
|
id: string;
|
|
title: string;
|
|
assignee: string;
|
|
due: string;
|
|
priority: Priority;
|
|
patient: string | null;
|
|
notes: string | null;
|
|
done: boolean;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
// Fields the "New task" dialog collects.
|
|
export type TaskInput = {
|
|
title: string;
|
|
assignee?: string;
|
|
due?: string;
|
|
priority?: Priority;
|
|
patient?: string | null;
|
|
notes?: string | null;
|
|
};
|
|
|
|
// Any subset of fields, plus `done` (used by the complete/reopen toggle).
|
|
export type TaskPatch = Partial<TaskInput> & { done?: boolean };
|
|
|
|
export function listTasks(): Promise<Task[]> {
|
|
return apiFetch<Task[]>("/api/tasks");
|
|
}
|
|
|
|
export function createTask(input: TaskInput): Promise<Task> {
|
|
return apiFetch<Task>("/api/tasks", {
|
|
method: "POST",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updateTask(id: string, patch: TaskPatch): Promise<Task> {
|
|
return apiFetch<Task>(`/api/tasks/${id}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(patch),
|
|
});
|
|
}
|
|
|
|
export function deleteTask(id: string): Promise<void> {
|
|
return apiFetch<void>(`/api/tasks/${id}`, { method: "DELETE" });
|
|
}
|