From ab53d42874dee54f911366a29cc132b98324254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 3 Aug 2026 12:11:52 +0200 Subject: [PATCH] Keep dose marking under a switch, and nothing else on medications Marking a dose taken or skipped is the verb the delegation was written for: somebody looking after a parent confirms the morning tablet. Adding a medication and noting a side effect come with it. The card menu keeps only what survives and disappears entirely when nothing does. Four detail tabs leave the registry inside somebody else's record, because their whole content is owner work: the schedule editor and its plan history, the supply ledger, the external-token row, and the advanced surface holding the wizard, the import and the destructive zone. A stale deep link into one lands on the landing tab, the way an inapplicable tab already does. The take-all-due sweep goes too. It rides the bulk intake route, which the delegation does not name, and a control that half-works is worse than one that is not offered. --- src/app/medications/page-client.tsx | 90 ++++--- src/components/dashboard/dashboard-header.tsx | 116 +++++---- .../medications/__tests__/card-parts.test.tsx | 14 +- .../card-parts/medication-intake-actions.tsx | 6 + .../detail/medication-detail-tabs.tsx | 27 +- .../medications/dose-history-ledger.tsx | 234 ++++++++++-------- .../medications/intake-history-editable.tsx | 5 +- .../medications/intake-history-list-v2.tsx | 4 + .../medications/log-intake-dialog.tsx | 3 + .../medications/medication-card-menu.tsx | 32 ++- .../medications/medication-table.tsx | 6 +- .../sections/intake-history-preview.tsx | 25 +- .../medications/side-effects-section.tsx | 50 ++-- .../medications/use-medication-intake.ts | 38 ++- 14 files changed, 394 insertions(+), 256 deletions(-) diff --git a/src/app/medications/page-client.tsx b/src/app/medications/page-client.tsx index 8013d1f2b..544d2a86c 100644 --- a/src/app/medications/page-client.tsx +++ b/src/app/medications/page-client.tsx @@ -1,5 +1,6 @@ "use client"; +import { useRecordCapabilities } from "@/hooks/use-record-capabilities"; import { useCallback, useEffect, useState } from "react"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import Link from "next/link"; @@ -159,6 +160,11 @@ function MedicationCardSkeleton() { export default function MedicationsPageClient() { const { user, isAuthenticated, isLoading: authLoading } = useAuth(); const { t } = useTranslations(); + // v1.36.x — adding a medication and marking a dose are both admitted + // delegated writes, so a WRITE delegate keeps the Add menu whole. The + // take-all-due sweep is not (it rides the bulk intake route), and neither is + // the customize page, which sharing does not cover at all. + const { canAdd, canManage } = useRecordCapabilities(); // v1.18.1 (D3) — medications is an opt-out module. When the account has it // turned off the whole page disappears (the nav entry is hidden by the same // gate) and the list query never fires (the API would 403 anyway). @@ -417,7 +423,7 @@ export default function MedicationsPageClient() { card's own one-tap job). Calm outline variant so the primary Add button keeps the visual lead; same responsive 44-px mobile tap floor as its neighbours. */} - {dueMeds.length >= 2 && ( + {canManage && dueMeds.length >= 2 && ( + +