mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(daily-loop): thread the overdue medication id into the digest's Log-dose link
The Today digest's dose-window rail item linked to the bare /medications list even though the overdue medication's id was already resolved server-side alongside its name — a tap landed the user on a generic list they then had to scan themselves. buildMedsTodayBlock now carries nextDueMedicationId; the digest's "Log dose" action links to /medications?highlight=<id> when the id is known, falling back to the bare list for an older cached block. The medications page reads the highlight param, scrolls the matching card into view, and rings it briefly (mirrors the vault's duplicate-upload highlight) in both the card grid and the table view. Regenerates docs/api/openapi.yaml for the new medsToday field.
This commit is contained in:
1 parent
844b24c7ba
commit
2b3ff0e58f
15 files changed
+213
-8
No files matched your search
@@ -169,6 +169,14 @@ export default function MedicationsPage() {
|
||||
// the param from the URL so a manual close + refresh stays closed.
|
||||
const shouldOpenFromUrl = searchParams?.get("new") === "1";
|
||||
const [dialogOpen, setDialogOpen] = useState(shouldOpenFromUrl);
|
||||
// v1.29.x — the Today digest's "Log dose" action deep-links straight to
|
||||
// the overdue medication (`/medications?highlight=<id>`) instead of the
|
||||
// bare list. Read once on mount; a scroll effect below (once the list
|
||||
// resolves) brings the target card into view and rings it briefly, then
|
||||
// clears the state so the ring doesn't linger indefinitely.
|
||||
const [highlightId, setHighlightId] = useState<string | null>(
|
||||
() => searchParams?.get("highlight") ?? null,
|
||||
);
|
||||
// v1.14.0 — the medications-page "Add" choice. The top button now offers
|
||||
// two paths: log an intake (incl. a backdated one) against an existing
|
||||
// medication, or create a new medication (the existing wizard).
|
||||
@@ -213,6 +221,21 @@ export default function MedicationsPage() {
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
|
||||
// v1.29.x — once the highlighted card is in the DOM, scroll it into view
|
||||
// and clear the highlight state after a few seconds so the ring is a
|
||||
// one-time "you tapped here" cue, not a permanent tint (mirrors the
|
||||
// vault's upload-duplicate flash-highlight, `HIGHLIGHT_MS` in
|
||||
// `use-document-upload.ts`).
|
||||
useEffect(() => {
|
||||
if (!highlightId || !medications?.length) return;
|
||||
const card = document.querySelector(
|
||||
`[data-medication-id="${highlightId}"]`,
|
||||
);
|
||||
card?.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
const timer = setTimeout(() => setHighlightId(null), 3000);
|
||||
return () => clearTimeout(timer);
|
||||
}, [highlightId, medications]);
|
||||
|
||||
// v1.16.11 — the same reminder-thresholds read the cards make (shared
|
||||
// key + cache), so the header's due-set derivation tiers late /
|
||||
// very_late exactly like the card pills. Null on failure keeps the
|
||||
@@ -468,6 +491,7 @@ export default function MedicationsPage() {
|
||||
<MedicationTable
|
||||
activeMedications={activeMeds}
|
||||
inactiveMedications={inactiveMeds}
|
||||
highlightId={highlightId}
|
||||
/>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
@@ -485,6 +509,7 @@ export default function MedicationsPage() {
|
||||
medication={med}
|
||||
onEdit={openEdit}
|
||||
onOpenHistory={openHistory}
|
||||
highlighted={highlightId === med.id}
|
||||
/>
|
||||
) : (
|
||||
<MedicationCard
|
||||
@@ -492,6 +517,7 @@ export default function MedicationsPage() {
|
||||
medication={med}
|
||||
onEdit={openEdit}
|
||||
onOpenHistory={openHistory}
|
||||
highlighted={highlightId === med.id}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
@@ -513,6 +539,7 @@ export default function MedicationsPage() {
|
||||
medication={med}
|
||||
onEdit={openEdit}
|
||||
onOpenHistory={openHistory}
|
||||
highlighted={highlightId === med.id}
|
||||
/>
|
||||
) : (
|
||||
<MedicationCard
|
||||
@@ -520,6 +547,7 @@ export default function MedicationsPage() {
|
||||
medication={med}
|
||||
onEdit={openEdit}
|
||||
onOpenHistory={openHistory}
|
||||
highlighted={highlightId === med.id}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user