fix(insights): draw the blood-pressure zones from the record's resolved band

The blood-pressure chart rebuilt its target zones in the browser from the
signed-in account's date of birth. A band the person had set themselves never
reached the chart, and inside a shared or managed record the zones followed
the viewer's age instead of the record's.

The targets payload already resolves for the record on screen. Its blood-
pressure card now honours the user's own band too (labelled Custom, like the
weight card), and the chart reads its zones from that card, so the chart and
the reference panel under it name one band.
This commit is contained in:
Marc-André Bombeck committed 2026-10-01 09:46:16 +02:00
1 parent 1b694ec222
commit ef420f9e2a
6 files changed
+211 -10

No files matched your search

+20
View File
@@ -371,6 +371,26 @@ export function resolveEffectiveBpTargets(
};
}
/**
* The user's own blood-pressure band, or `null` when they have not set one.
*
* `resolveEffectiveBpTargets` answers "which band applies" and falls back to
* the age default; this answers "did the person pick it", which is what a
* surface needs to label the band as their own rather than as the guideline.
* A one-sided override (systolic only) still counts: the other half is the
* age default, exactly as `resolveEffectiveBpTargets` fills it.
*/
export function resolveBpTargetOverride(
profile: UserProfileForRange,
thresholdsJson: unknown,
): BpTargets | null {
const hasOverride =
resolveThresholdOverride(thresholdsJson, "BLOOD_PRESSURE_SYS") != null ||
resolveThresholdOverride(thresholdsJson, "BLOOD_PRESSURE_DIA") != null;
if (!hasOverride) return null;
return resolveEffectiveBpTargets(profile, thresholdsJson);
}
/**
* Convenience: resolve every supported metric at once. Useful for /targets
* and the insight generator.