From 8c5ef5df10dde36277c18195c76e8d335117d6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 26 Jun 2026 14:03:39 +0200 Subject: [PATCH] fix(medications): render intake datetime fields through the format-aware picker The three intake dialogs (log, edit, dose-history add) still used a raw datetime-local input, so they ignored the user's date-format preference. Route them through DateTimeField like every other date surface. Also correct a stale diastolic-floor comment in the dashboard verdict. --- .../intake-edit-dialog-seed.test.tsx | 27 +++++++++++++++++++ .../medications/dose-history-add-dialog.tsx | 7 +++-- .../medications/intake-edit-dialog.tsx | 7 +++-- .../medications/log-intake-dialog.tsx | 6 ++--- src/lib/dashboard/verdict.ts | 3 ++- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/components/medications/__tests__/intake-edit-dialog-seed.test.tsx b/src/components/medications/__tests__/intake-edit-dialog-seed.test.tsx index efd0f2435..684e72dfe 100644 --- a/src/components/medications/__tests__/intake-edit-dialog-seed.test.tsx +++ b/src/components/medications/__tests__/intake-edit-dialog-seed.test.tsx @@ -26,6 +26,33 @@ vi.mock("@tanstack/react-query", () => ({ useQueryClient: () => ({}), })); +// DateTimeField reads the client date/hour-cycle preference context, which the +// wholesale i18n mock above strips. The dialog test pins the field's value/max +// contract, not the field's own rendering, so a passthrough native input keeps +// the assertions meaningful while staying SSR-renderable. +vi.mock("@/components/ui/date-time-field", () => ({ + DateTimeField: ({ + id, + value, + max, + disabled, + }: { + id?: string; + value?: string; + max?: string; + disabled?: boolean; + }) => ( + + ), +})); + vi.mock("@/components/ui/dialog", () => ({ Dialog: ({ children }: { children: React.ReactNode }) => (
{children}
diff --git a/src/components/medications/dose-history-add-dialog.tsx b/src/components/medications/dose-history-add-dialog.tsx index 3a03865b8..49587bea0 100644 --- a/src/components/medications/dose-history-add-dialog.tsx +++ b/src/components/medications/dose-history-add-dialog.tsx @@ -32,7 +32,7 @@ import { DialogTitle, } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; -import { Input } from "@/components/ui/input"; +import { DateTimeField } from "@/components/ui/date-time-field"; import { Switch } from "@/components/ui/switch"; import { useTranslations } from "@/lib/i18n/context"; import { invalidateKeys, medicationDependentKeys } from "@/lib/query-keys"; @@ -227,12 +227,11 @@ export function LedgerAddDialog({ - setTakenAt(e.target.value)} + onChange={(value) => setTakenAt(value)} disabled={skipped} /> diff --git a/src/components/medications/intake-edit-dialog.tsx b/src/components/medications/intake-edit-dialog.tsx index 07c102539..f009fbb20 100644 --- a/src/components/medications/intake-edit-dialog.tsx +++ b/src/components/medications/intake-edit-dialog.tsx @@ -34,7 +34,7 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { Input } from "@/components/ui/input"; +import { DateTimeField } from "@/components/ui/date-time-field"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { useFormatters, useTranslations } from "@/lib/i18n/context"; @@ -166,12 +166,11 @@ function IntakeEditDialogBody({ - setTakenAt(e.target.value)} + onChange={(value) => setTakenAt(value)} disabled={skipped} /> {scheduledFor && ( diff --git a/src/components/medications/log-intake-dialog.tsx b/src/components/medications/log-intake-dialog.tsx index 251c6ed5a..b5dff31bf 100644 --- a/src/components/medications/log-intake-dialog.tsx +++ b/src/components/medications/log-intake-dialog.tsx @@ -35,6 +35,7 @@ import { } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; +import { DateTimeField } from "@/components/ui/date-time-field"; import { NativeSelect } from "@/components/ui/native-select"; import { Switch } from "@/components/ui/switch"; import { useTranslations } from "@/lib/i18n/context"; @@ -297,12 +298,11 @@ export function LogIntakeDialog({ - setTakenAt(e.target.value)} + onChange={(value) => setTakenAt(value)} disabled={skipped} />

diff --git a/src/lib/dashboard/verdict.ts b/src/lib/dashboard/verdict.ts index f693ae19b..ef5b255aa 100644 --- a/src/lib/dashboard/verdict.ts +++ b/src/lib/dashboard/verdict.ts @@ -126,7 +126,8 @@ export function resolveDashboardVerdict( const lastSeen = snapshot.tiles.lastSeenByType; // ── 1 · bpCritical ───────────────────────────────────────────────── - // Fixed floors (sys ≥ 180 OR dia ≥ 110), never user thresholds, and + // Fixed floors (sys ≥ 180 OR dia ≥ 120, from clinical-floors), never user + // thresholds, and // only while the reading is fresh (≤ 1 day, re-derived against the // injected `now`). Sits ABOVE the overdue dose: a fresh crisis-level // reading is the one item that must not hide behind a routine