tasks: assign a task to a specific person

Backend: add tasks.assignee_user_id (nullable, fk user) + migration; persist
it through create/update and surface tasks to the assigned person in listTasks.

Frontend: New Task dialog gains a three-way Assignee control
(Myself / Department / Person) with a provider picker from /api/staff/providers;
task card + detail show the assignee's name when set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-06-20 18:40:56 +03:00
parent 1d9b1b1d22
commit bbc6869745
11 changed files with 4131 additions and 20 deletions
+9 -1
View File
@@ -24,6 +24,7 @@ function toTask(row: TaskRow): Task {
title: row.title,
assignee: row.assignee,
assigneeRole: row.assigneeRole,
assigneeUserId: row.assigneeUserId,
due: row.due,
priority: row.priority,
status: row.status,
@@ -48,7 +49,11 @@ export async function listTasks(
let where = eq(tasks.organizationId, orgId);
if (!isAdmin) {
const visible = [eq(tasks.createdBy, viewer.userId)];
const visible = [
eq(tasks.createdBy, viewer.userId),
// Tasks assigned to this person specifically.
eq(tasks.assigneeUserId, viewer.userId),
];
if (roles.length) visible.push(inArray(tasks.assigneeRole, roles));
where = and(where, or(...visible))!;
}
@@ -73,6 +78,7 @@ export async function createTask(
title: input.title,
assignee: input.assignee,
assigneeRole: input.assigneeRole ?? null,
assigneeUserId: input.assigneeUserId ?? null,
due: input.due,
priority: input.priority,
status: input.status,
@@ -100,6 +106,8 @@ export async function updateTask(
if (patch.assignee !== undefined) set.assignee = patch.assignee;
if (patch.assigneeRole !== undefined)
set.assigneeRole = patch.assigneeRole ?? null;
if (patch.assigneeUserId !== undefined)
set.assigneeUserId = patch.assigneeUserId ?? null;
if (patch.due !== undefined) set.due = patch.due;
if (patch.priority !== undefined) set.priority = patch.priority;
if (patch.patient !== undefined) set.patient = patch.patient ?? null;