mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
The first page of the workout list now carries the fitness-fatigue model over the day-total heart-rate impulse the nightly strain run already stores: fitness as the 42-day and fatigue as the 7-day exponentially weighted average, form as their difference. A day without a stored impulse counts as rest. It needs 28 days and three training days, flags the first six weeks as warming up, and reads in the person's own units only. The workouts page shows the three figures above the list.
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
"use client";
|
|
|
|
import { Gauge } from "lucide-react";
|
|
|
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
|
import { TileHeader } from "@/components/insights/tile-header";
|
|
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
|
import type { TrainingLoad } from "@/lib/insights/training-load";
|
|
|
|
/**
|
|
* v1.44 — fitness, fatigue and form from the stored training impulse, the
|
|
* server's figures as given. Renders nothing until the model has 28 days and
|
|
* three training days to stand on.
|
|
*/
|
|
export function TrainingLoadCard({
|
|
trainingLoad,
|
|
}: {
|
|
trainingLoad: TrainingLoad | undefined;
|
|
}) {
|
|
const { t } = useTranslations();
|
|
const fmt = useFormatters();
|
|
if (!trainingLoad || trainingLoad.status !== "ok") return null;
|
|
|
|
const stats = [
|
|
{ key: "fitness", value: trainingLoad.ctl },
|
|
{ key: "fatigue", value: trainingLoad.atl },
|
|
{ key: "form", value: trainingLoad.tsb },
|
|
] as const;
|
|
|
|
return (
|
|
<Card data-slot="training-load">
|
|
<CardHeader>
|
|
<TileHeader icon={Gauge} title={t("insights.workouts.load.title")} />
|
|
</CardHeader>
|
|
<CardContent className="space-y-2">
|
|
<dl className="grid grid-cols-3 gap-3">
|
|
{stats.map((stat) => (
|
|
<div key={stat.key} data-slot={`training-load-${stat.key}`}>
|
|
<dt className="text-muted-foreground text-xs">
|
|
{t(`insights.workouts.load.${stat.key}`)}
|
|
</dt>
|
|
<dd className="text-foreground text-lg font-semibold tabular-nums">
|
|
{stat.key === "form" && stat.value > 0 ? "+" : ""}
|
|
{fmt.number(stat.value, 0)}
|
|
</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
<p className="text-sm">{t("insights.workouts.load.explainer")}</p>
|
|
{trainingLoad.warmingUp ? (
|
|
<p className="text-muted-foreground text-xs">
|
|
{t("insights.workouts.load.warmingUp", {
|
|
days: trainingLoad.daysCovered,
|
|
})}
|
|
</p>
|
|
) : null}
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|