Files
HealthLog/src/lib/targets/source-link.ts
T
Marc-André Bombeck d880385635 refactor(targets): retire the standalone Targets page
The standalone /targets (Zielwerte) page is retired. Target editing
moved inline onto the Insights metric pages in v1.8.6 — each metric's
reference panel mounts the editor and writes the same
PUT /api/user/thresholds, reading the same /api/insights/targets
payload. The page carried a deprecation notice and had already dropped
out of the navigation, so removing it is a UI-only change: no data
model, API route, or inline editor moves.

Remove the page and its tests, the components reachable only from it
(target card, per-card coach button, summary header, target prompt /
scope helpers, coach-handoff hook), the now-dead /zielwerte→/targets
proxy redirect, and the orphaned targets.* i18n keys across all six
locales. Repoint the handful of code comments that pointed readers at
the page to the inline Insights panel, and prune the two coach
gate-inventory allowlists plus the queryKey factory guard root that
named the removed files.

The reference panel keeps the range bar, consistency strip, status
pill, edit sheet, and source-link helpers — those are the live editing
surface now.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 7f842c5620087127e980fe22a56133135b7c0531)
2026-06-02 17:01:14 +02:00

41 lines
1.5 KiB
TypeScript

/**
* Resolves the guideline-source citation URL for a target, keyed off
* the target `type` and (for pulse) substrings of the `source` label.
* Pure function with no React coupling so every surface that shows a
* target citation resolves the identical URL — the link can never drift.
*/
export interface TargetSourceLinkInput {
type: string;
source: string;
}
export function getTargetSourceLink(target: TargetSourceLinkInput): string | null {
if (target.type === "WEIGHT" || target.type === "BMI") {
return "https://www.who.int/news-room/fact-sheets/detail/obesity-and-overweight";
}
if (
target.type === "BLOOD_PRESSURE" ||
target.type === "BLOOD_PRESSURE_IN_TARGET"
) {
return "https://academic.oup.com/eurheartj/article/39/33/3021/5079119";
}
if (target.type === "PULSE") {
if (target.source.includes("CDC/NCHS")) {
return "https://www.cdc.gov/nchs/data/nhsr/nhsr041.pdf";
}
if (target.source.includes("AHA")) {
return "https://www.heart.org/en/health-topics/high-blood-pressure/the-facts-about-high-blood-pressure/all-about-heart-rate-pulse";
}
}
if (target.type === "SLEEP_DURATION") {
return "https://aasm.org/seven-or-more-hours-of-sleep-per-night-a-health-necessity-for-adults/";
}
if (target.type === "BODY_FAT") {
return "https://www.acefitness.org/resources/everyone/blog/6596/what-are-the-guidelines-for-percentage-of-body-fat-loss/";
}
if (target.type === "ACTIVITY_STEPS") {
return "https://www.who.int/publications/i/item/9789240015128";
}
return null;
}