fix(medications): localise the dose unit and lift it onto its own line

A medication's dose is stored as free text the wizard composes from an
amount and a unit token ("1 pieces", "2 tablets"), and the card rendered
that token verbatim glued onto the name — so the unit showed in English
on every locale and the title read "Test ABC 1 pieces".

Translate the dose at display time: a formatDose helper splits the stored
string and runs a known unit token through the existing unit messages, so
"1 pieces" reads "1 Stück" / "1 piece(s)" per locale while a custom
free-text dose passes through untouched. The card header now carries the
name alone on its title line with the dose on a muted line beneath it,
above the category badge; the detail view, table and intake dialogs
localise the same way. Vorsorge and lab rows pass an empty dose so they
render no extra line.
This commit is contained in:
Marc-André Bombeck committed 2026-06-30 13:39:23 +02:00
1 parent a31711699c
commit 6fe552ffdf
14 files changed
+180 -43

No files matched your search

@@ -22,30 +22,11 @@ import {
} from "@/lib/medications/injection-sites";
import type { MedicationDeliveryForm } from "@/lib/validations/medication";
import { unitsPerDoseOptionsFor } from "@/components/medications/units-per-dose";
import { DOSE_UNIT_KEYS } from "@/lib/medications/dose-units";
import { useTranslations } from "@/lib/i18n/context";
import type { StepProps } from "./step1-name";
/**
* Dose unit choices, ordered so mg / ml / IE / µg lead and the
* device-form units (Tablette, Hub, Sprühstoß, …) follow. Mirrors the
* v1.5.3 list with the maintainer-requested order tightening.
*/
const DOSE_UNIT_KEYS = [
"mg",
"ml",
"iu",
"mcg",
"g",
"tablets",
"capsules",
"drops",
"puffs",
"sprays",
"pieces",
"other",
] as const;
const DELIVERY_FORM_KEYS: readonly MedicationDeliveryForm[] = [
"ORAL",
"INJECTION",