mirror of
https://github.com/temetro/temetro.git
synced 2026-07-27 04:08:56 +00:00
4f8793c765
- Hide "Create clinic" (sidebar footer) for non-admins; only owner/admin can spin up additional clinics. Onboarding for brand-new users is unaffected. - Analysis: drop the bar charts; show line charts (Sparkline) inside KPI cards that open a detail dialog with the full chart + per-point breakdown. - Add Team Member: validate the username client-side (no spaces; letters, numbers, dots, underscores) with a clear warning + field hint. - Tasks: New Task now has an Assignee selector (Myself / Other → department). Tasks are visible to the department they're assigned to (or the creator), and show who created them. Backend adds assignee_role + created_by_name with visibility filtering in listTasks; owners/admins see all. - Care team: removing a member now asks for confirmation first (dialog) and surfaces success/failure + refreshes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 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;
|
|
// Department (member role) the task is assigned to; null = personal task.
|
|
assigneeRole: string | null;
|
|
due: string;
|
|
priority: Priority;
|
|
patient: string | null;
|
|
notes: string | null;
|
|
done: boolean;
|
|
createdById: string | null;
|
|
createdByName: string | null;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
// Fields the "New task" dialog collects.
|
|
export type TaskInput = {
|
|
title: string;
|
|
assignee?: string;
|
|
assigneeRole?: string | null;
|
|
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" });
|
|
}
|