mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
feat(insights): port the target reference panel onto the category pages
Grow the per-category insights target summary from a one-line range card into a compact reference panel that surfaces the band range, the verbal status, the guideline source, the in-target share, the 30-day average, the range bar and the 7-day consistency strip — all from the Targets data already on the wire, reading the same shared cache. Extract the status pill and the source-link resolver into shared primitives so the Targets card and the insights panel can never disagree, and wire blood glucose into the summary with its per-context split and unit conversion.
This commit is contained in:
1 parent
5de9ddb0cc
commit
0f7ca61e2f
10 files changed
+844
-269
No files matched your search
@@ -25,6 +25,7 @@ export default function InsightsBlutzuckerPage() {
|
||||
yAxisUnit="mg/dL"
|
||||
emptyStateIcon={<Droplet className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
targetSummarySlug="blood-glucose"
|
||||
coachPrefill="I haven't logged any blood glucose yet — what does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type TargetCardData,
|
||||
} from "@/components/targets/target-card";
|
||||
import { TargetsSummaryHeader } from "@/components/targets/targets-summary-header";
|
||||
import { getTargetSourceLink } from "@/lib/targets/source-link";
|
||||
import { CoachDrawer } from "@/components/insights/coach-panel/coach-drawer";
|
||||
import { useCoachHandoff } from "@/hooks/use-coach-handoff";
|
||||
import { useFeatureFlags } from "@/hooks/use-feature-flags";
|
||||
@@ -92,41 +93,6 @@ function sortKey(target: TargetData): number {
|
||||
return FIXED_TARGET_ORDER[target.type] ?? 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Source-citation URL for each target type. Kept on the page (rather
|
||||
* than the card) so the card stays presentational and the routing
|
||||
* stays declarative.
|
||||
*/
|
||||
function getTargetSourceLink(target: TargetData): 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;
|
||||
}
|
||||
|
||||
export default function TargetsPage() {
|
||||
const { t } = useTranslations();
|
||||
const { isAuthenticated, user } = useAuth();
|
||||
|
||||
Reference in new issue
Block a user