mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
feat(labs): refuse a biomarker unit change while readings are linked
Readers label every linked reading with the marker's unit, so changing
it relabelled stored numbers without converting them. PUT
/api/biomarkers/{id} now answers 422 biomarkers.unit.locked with
meta.readingCount when the unit differs and any reading (tombstoned
ones included) is linked. The marker editor says so under the unit
field.
This commit is contained in:
1 parent
7022b698e7
commit
dd7636e147
6 files changed
+143
-27
No files matched your search
@@ -70,6 +70,7 @@ export function BiomarkerForm({
|
||||
}: BiomarkerFormProps) {
|
||||
const { t } = useTranslations();
|
||||
const formId = useId();
|
||||
const unitHintId = `${formId}-unit-hint`;
|
||||
|
||||
const [name, setName] = useState(existing?.name ?? "");
|
||||
const [unit, setUnit] = useState(existing?.unit ?? "");
|
||||
@@ -225,7 +226,16 @@ export function BiomarkerForm({
|
||||
placeholder={t("labs.biomarker.form.unitPlaceholder")}
|
||||
maxLength={40}
|
||||
required
|
||||
aria-describedby={existing ? unitHintId : undefined}
|
||||
/>
|
||||
{existing ? (
|
||||
// The server refuses a unit change while readings are linked:
|
||||
// every reading is shown in the marker's unit, so a new unit
|
||||
// would relabel stored numbers without converting them.
|
||||
<p id={unitHintId} className="text-muted-foreground text-xs">
|
||||
{t("labs.biomarker.form.unitLockedHint")}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="biomarker-panel">
|
||||
|
||||
Reference in new issue
Block a user