This commit is contained in:
Dominik Klarkowski
2026-06-16 11:11:19 +02:00
parent 36407f534b
commit 21e5db3409
4 changed files with 158 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ import { InfoTooltip } from "@/components/info-tooltip";
import { formatDate, formatDateShort } from "@/lib/format";
import { getLatestAnalysisForTarget } from "@/lib/models/analysis";
import { getStrengthWorkout, listStrengthWorkouts } from "@/lib/models/strength";
import { getExerciseHistory } from "@/lib/strength/stats";
import { exerciseE1rm, getExerciseHistory } from "@/lib/strength/stats";
export const dynamic = "force-dynamic";
@@ -43,19 +43,31 @@ export default async function StrengthWorkoutPage({
<AiAnalysisCard targetType="strength" targetId={workout._id.toString()} analysis={analysis} />
<div className="grid grid-cols-2 gap-2.5 sm:grid-cols-3">
{exercisesWithHistory.map(({ exercise }, index) => (
<div key={index} className="flex flex-col gap-2 rounded-lg border border-muted/40 bg-surface px-3 py-2.5">
<p className="text-xs font-semibold text-fg">{exercise.name}</p>
{exercise.notes ? <p className="text-xs text-fg/50 italic">{exercise.notes}</p> : null}
<div className="flex flex-wrap gap-1">
{exercise.sets.map((set) => (
<span key={set.order} className="rounded bg-bg px-1.5 py-0.5 text-xs text-fg/70">
{set.reps ?? "?"}×{set.weightKg !== undefined ? `${set.weightKg} kg` : "—"}
</span>
))}
{exercisesWithHistory.map(({ exercise }, index) => {
const e1rm = exerciseE1rm(exercise);
return (
<div key={index} className="flex flex-col gap-2 rounded-lg border border-muted/40 bg-surface px-3 py-2.5">
<p className="text-xs font-semibold text-fg">{exercise.name}</p>
{exercise.notes ? <p className="text-xs text-fg/50 italic">{exercise.notes}</p> : null}
<div className="flex flex-wrap gap-1">
{exercise.sets.map((set) => {
const pct =
e1rm && set.weightKg != null
? Math.round((set.weightKg / e1rm) * 100)
: null;
return (
<span key={set.order} className="rounded bg-bg px-1.5 py-0.5 text-xs text-fg/70">
{set.reps ?? "?"}×{set.weightKg !== undefined ? `${set.weightKg} kg` : "—"}
{pct !== null ? (
<span className="ml-1 text-fg/40">{pct}%</span>
) : null}
</span>
);
})}
</div>
</div>
</div>
))}
);
})}
</div>
{exercisesWithHistory.some(({ history }) => history.length >= 2) ? (
@@ -75,6 +87,7 @@ export default async function StrengthWorkoutPage({
label: formatDateShort(point.date),
volumeKg: point.volumeKg,
topWeightKg: point.topWeightKg,
e1rmKg: point.e1rmKg,
}))}
/>
))}