Files
HealthLog/src/components/charts/mini-window.ts
T
Marc-André Bombeck fea1d1e0b5 chore: strip planning tags from comments and enable the rule
Output of `node scripts/strip-planning-tags.mjs --write`: 3,157 comment
lines in 1,308 files lose the work-item identifier at their head. Release
versions and issue references stay; nothing outside comment text
changes, which the script checks per file against a comment-free
printout. healthlog/no-planning-tags is enabled at error level with this
commit, so the tree it lands on is clean.
2026-10-20 09:08:40 +02:00

38 lines
1.3 KiB
TypeScript

/**
* v1.4.16 — shared chart-mini window vocabulary.
*
* The Oura-style RecommendationCard (B5c) embeds a mini-chart that
* pins to the recommendation's `rationale.dataWindow`. This helper
* maps the rationale enum onto the calendar-day window used by the
* existing chart wrappers.
*
* last7days → 7-day window
* last30days → 30-day window
* last90days → 90-day window
* allTime → 0 (HealthChart treats 0 as "no window — show all")
*
* The values mirror the existing `TIME_RANGES_KEYS` definition in
* `health-chart.tsx`; the helper is a pure function so unit tests
* pin the contract without depending on Recharts internals. The
* exported name keeps the historical `rangePoints` vocabulary because
* it feeds the chart state/preference field of that name (a persisted
* wire field) — the VALUE has always been calendar days.
*/
export type DataWindow = "last7days" | "last30days" | "last90days" | "allTime";
const DAYS_BY_WINDOW: Record<DataWindow, number> = {
last7days: 7,
last30days: 30,
last90days: 90,
allTime: 0,
};
/**
* Returns the day-window value the chart wrapper expects for a given
* rationale dataWindow enum value.
*/
export function resolveMiniRangePoints(window: DataWindow): number {
return DAYS_BY_WINDOW[window];
}