feat(date): add DateTimeField and migrate datetime inputs

Add a dependency-free DateTimeField that paints the date part in the
user's date-order preference and the time part in the hour-cycle
preference over a hidden native datetime-local input, preserving the
local yyyy-MM-ddTHH:mm value contract. Migrate the seven DateTimeInput
callsites (measurement add/edit, mood add/edit, lab add/edit,
medication intake quick-add) so the chosen format is honoured there too,
and cover the field's value contract and per-preference rendering with a
component test.
This commit is contained in:
Marc-André Bombeck committed 2026-06-26 13:17:55 +02:00
1 parent 0816b3b0c0
commit 01b24c4d73
9 files changed
+394 -21

No files matched your search

+3 -3
View File
@@ -7,7 +7,7 @@ import { Loader2 } from "lucide-react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { DateTimeInput } from "@/components/ui/date-input";
import { DateTimeField } from "@/components/ui/date-time-field";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { ResponsiveSheet } from "@/components/ui/responsive-sheet";
@@ -310,10 +310,10 @@ export function LabForm({
</div>
<div className="space-y-1.5">
<Label htmlFor="lab-takenAt">{t("labs.form.takenAt")}</Label>
<DateTimeInput
<DateTimeField
id="lab-takenAt"
value={takenAt}
onChange={(e) => setTakenAt(e.target.value)}
onChange={setTakenAt}
max={defaultTakenAtValue()}
required
/>
+3 -3
View File
@@ -7,7 +7,7 @@ import { toast } from "sonner";
import { DeleteButton } from "@/components/data-list";
import { Button } from "@/components/ui/button";
import { DateTimeInput } from "@/components/ui/date-input";
import { DateTimeField } from "@/components/ui/date-time-field";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { ResponsiveSheet } from "@/components/ui/responsive-sheet";
@@ -285,10 +285,10 @@ export function LabHistoryList({ readings }: { readings: LabResultDto[] }) {
</div>
<div className="space-y-1.5">
<Label htmlFor="lab-edit-takenAt">{t("labs.form.takenAt")}</Label>
<DateTimeInput
<DateTimeField
id="lab-edit-takenAt"
value={editTakenAt}
onChange={(e) => setEditTakenAt(e.target.value)}
onChange={setEditTakenAt}
required
/>
</div>