From 0280369952a022dc39f1943be0c8a0bfef3c2121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 17 May 2026 14:44:03 +0200 Subject: [PATCH] refactor(dashboard): self-review polish on the medication-intake quick-add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two findings from the post-implementation self-review: - Empty-state CTA: swap the plain anchor for next/link so the /medications jump stays inside the SPA router instead of triggering a full page reload. - JSDoc accuracy: the original module-level comment claimed a non-default dose 'surfaces as a sonner toast hint' — neither the toast nor a notes-style append actually exists. Rewrite the dose paragraph to honestly describe the contract: the dose input is pre-filled for visual confirmation, editable, but the POST body never carries the dose override. The intake event always references the medication's catalogue dose; a half/double dose still routes through the medication edit on /medications. --- .../dashboard/medication-intake-quick-add.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/dashboard/medication-intake-quick-add.tsx b/src/components/dashboard/medication-intake-quick-add.tsx index 57b80e87a..6e5e89f94 100644 --- a/src/components/dashboard/medication-intake-quick-add.tsx +++ b/src/components/dashboard/medication-intake-quick-add.tsx @@ -15,6 +15,7 @@ import { SelectValue, } from "@/components/ui/select"; import { Loader2, Pill, Plus } from "lucide-react"; +import Link from "next/link"; import { toast } from "sonner"; import { useTranslations } from "@/lib/i18n/context"; import { @@ -44,15 +45,16 @@ import { * due. Disabled when the user has no active medications — the * sheet body renders an EmptyState-style hint instead of an * unusable form. - * 2. Dose. Pre-filled from the medication's default dose; editable - * for the "took half / took double" cases. Free text (the - * medication catalogue stores dose as a free string), so we ship - * it as a notes-style append on the intake event via the - * existing API — the intake POST itself does not persist a dose - * override yet (the event references the medication's current - * dose), so a non-default value surfaces as a sonner toast hint - * only. Keeping the field editable preserves Marc's "few taps" - * contract for the common case while documenting the boundary. + * 2. Dose. Pre-filled from the medication's catalogue dose for + * visual confirmation ("this is the strength I'm logging"); the + * field is editable but the POST body does NOT carry the dose + * override yet — the intake event always references the + * medication's current catalogue dose. The boundary lives in the + * `intakeSchema` (no `dose` field), so when the user wants to + * record a half/double dose they still edit the medication + * itself on `/medications`. Keeping the input editable preserves + * the visual contract Marc asked for ("show me what I'm + * logging") without misrepresenting the wire shape. * 3. Time taken. Defaults to `now` (local datetime-local format * shaped the same as `MoodForm`). * @@ -321,9 +323,9 @@ export function MedicationIntakeQuickAdd({

{footerSlot ? createPortal(emptyFooter, footerSlot) : emptyFooter}