import { notFound } from "next/navigation"; import { AiAnalysisCard } from "@/components/ai-analysis-card"; import { ExerciseProgressChart } from "@/components/exercise-progress-chart"; 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"; export const dynamic = "force-dynamic"; const EXERCISE_HISTORY_LIMIT = 8; export default async function StrengthWorkoutPage({ params, }: { params: Promise<{ id: string }>; }) { const { id } = await params; const workout = await getStrengthWorkout(id); if (!workout) { notFound(); } const analysis = await getLatestAnalysisForTarget("strength", workout._id); const allWorkouts = await listStrengthWorkouts(); const pastWorkouts = allWorkouts.filter((w) => w.date <= workout.date); const exercisesWithHistory = workout.exercises.map((exercise) => ({ exercise, history: getExerciseHistory(exercise.name, pastWorkouts, EXERCISE_HISTORY_LIMIT), })); return (

{workout.name}

{formatDate(workout.date)}

{workout.notes ?

{workout.notes}

: null}
{exercisesWithHistory.map(({ exercise }, index) => (

{exercise.name}

{exercise.notes ?

{exercise.notes}

: null}
{exercise.sets.map((set) => ( {set.reps ?? "?"}×{set.weightKg !== undefined ? `${set.weightKg} kg` : "—"} ))}
))}
{exercisesWithHistory.some(({ history }) => history.length >= 2) ? (

Postęp ćwiczeń

{exercisesWithHistory .filter(({ history }) => history.length >= 2) .map(({ exercise, history }) => ( ({ label: formatDateShort(point.date), volumeKg: point.volumeKg, topWeightKg: point.topWeightKg, }))} /> ))}
) : null} {workout.sourceUrl ? ( {workout.sourceUrl} ) : null}
); }