fix: clinic creation gating, analysis line charts, username + task assignee, delete confirm

- 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>
This commit is contained in:
Khalid Abdi
2026-06-08 19:52:12 +03:00
parent 8ab0552cf8
commit 4f8793c765
19 changed files with 2878 additions and 144 deletions
+6
View File
@@ -22,6 +22,9 @@ export const tasks = pgTable(
.references(() => organization.id, { onDelete: "cascade" }),
title: text("title").notNull(),
assignee: text("assignee").notNull().default("Unassigned"),
// The department (member role) a task is assigned to, e.g. "reception".
// Null means a personal task belonging to its creator. Drives who sees it.
assigneeRole: text("assignee_role"),
due: text("due").notNull().default("No due date"),
priority: text("priority").$type<TaskPriority>().notNull(),
patient: text("patient"),
@@ -30,6 +33,9 @@ export const tasks = pgTable(
createdBy: text("created_by").references(() => user.id, {
onDelete: "set null",
}),
// Denormalised creator name so "created by …" survives even if the user is
// later removed (createdBy is set null on delete).
createdByName: text("created_by_name"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()