mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 13:52:20 +00:00
feat(insights): name the part of the day on the blood pressure stats while narrowed
The stat strip reads the chart's visible window, so with the chart narrowed to the morning its figures were morning figures under a plain Systolic label. The column label now says so. Russian texts for the time-of-day card.
This commit is contained in:
1 parent
22f83aed6e
commit
1a4703f4fe
12 files changed
+108
-2
No files matched your search
@@ -145,7 +145,7 @@ export default function InsightsBlutdruckPage() {
|
||||
summary: sysSummary,
|
||||
unit: "mmHg",
|
||||
fractionDigits: 0,
|
||||
seriesLabel: t("charts.systolic"),
|
||||
seriesLabel: timeOfDay.statsLabel(t("charts.systolic")),
|
||||
icon: ArrowUpRight,
|
||||
windowStats: statsByType?.BLOOD_PRESSURE_SYS ?? null,
|
||||
windowPending: !statsSettled,
|
||||
@@ -155,7 +155,7 @@ export default function InsightsBlutdruckPage() {
|
||||
summary: diaSummary,
|
||||
unit: "mmHg",
|
||||
fractionDigits: 0,
|
||||
seriesLabel: t("charts.diastolic"),
|
||||
seriesLabel: timeOfDay.statsLabel(t("charts.diastolic")),
|
||||
icon: ArrowDownRight,
|
||||
windowStats: statsByType?.BLOOD_PRESSURE_DIA ?? null,
|
||||
windowPending: !statsSettled,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
BP_PARTS_OF_DAY,
|
||||
type BpPartOfDay,
|
||||
} from "@/lib/analytics/bp-time-of-day";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useUrlSearch, writeUrlState } from "@/lib/url-state";
|
||||
|
||||
/** The chart's part of the day, or the whole day. */
|
||||
@@ -24,6 +25,13 @@ export function parseBpChartPart(
|
||||
return BP_PARTS_OF_DAY.find((part) => part === raw);
|
||||
}
|
||||
|
||||
/** The stat strip's part-of-day word, so its figures say which readings they are. */
|
||||
const STATS_PART_KEYS: Record<BpPartOfDay, string> = {
|
||||
morning: "insights.bpTimeOfDay.statsPart.morning",
|
||||
midday: "insights.bpTimeOfDay.statsPart.midday",
|
||||
evening: "insights.bpTimeOfDay.statsPart.evening",
|
||||
};
|
||||
|
||||
const CHART_TITLE_KEYS: Record<BpPartOfDay, string> = {
|
||||
morning: "insights.bpTimeOfDay.chartTitle.morning",
|
||||
midday: "insights.bpTimeOfDay.chartTitle.midday",
|
||||
@@ -45,8 +53,11 @@ export function useBpTimeOfDayState(): {
|
||||
/** The chart title's message key while narrowed; undefined for the whole day. */
|
||||
chartTitleKey: string | undefined;
|
||||
setChartPart: (next: BpChartPart) => void;
|
||||
/** A stat column's label, naming the part of the day while narrowed. */
|
||||
statsLabel: (series: string) => string;
|
||||
days: number;
|
||||
} {
|
||||
const { t } = useTranslations();
|
||||
const partOfDay = parseBpChartPart(useUrlSearch());
|
||||
const setChartPart = useCallback((next: BpChartPart) => {
|
||||
writeUrlState(
|
||||
@@ -63,6 +74,13 @@ export function useBpTimeOfDayState(): {
|
||||
partOfDay,
|
||||
chartTitleKey: partOfDay ? CHART_TITLE_KEYS[partOfDay] : undefined,
|
||||
setChartPart,
|
||||
statsLabel: (series) =>
|
||||
partOfDay
|
||||
? t("insights.bpTimeOfDay.statsLabel", {
|
||||
series,
|
||||
part: t(STATS_PART_KEYS[partOfDay]),
|
||||
})
|
||||
: series,
|
||||
days: rangeWindowDays(range),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user