This commit is contained in:
Dominik Klarkowski
2026-06-18 11:02:31 +02:00
parent d00a5a42ac
commit 047e580da0
32 changed files with 735 additions and 189 deletions

View File

@@ -6,6 +6,7 @@ import { formatDate, formatDateShort } from "@/lib/format";
import { getLatestAnalysisForTarget, serializeAnalysis } from "@/lib/models/analysis";
import { getStrengthWorkout, listStrengthWorkouts } from "@/lib/models/strength";
import { exerciseE1rm, getExerciseHistory } from "@/lib/strength/stats";
import { getCurrentUserId } from "@/lib/session";
export const dynamic = "force-dynamic";
@@ -17,14 +18,15 @@ export default async function StrengthWorkoutPage({
params: Promise<{ id: string }>;
}) {
const { id } = await params;
const workout = await getStrengthWorkout(id);
const userId = await getCurrentUserId();
const workout = await getStrengthWorkout(userId, id);
if (!workout) {
notFound();
}
const analysis = await getLatestAnalysisForTarget("strength", workout._id);
const allWorkouts = await listStrengthWorkouts();
const analysis = await getLatestAnalysisForTarget(userId, "strength", workout._id);
const allWorkouts = await listStrengthWorkouts(userId);
const pastWorkouts = allWorkouts.filter((w) => w.date <= workout.date);
const exercisesWithHistory = workout.exercises.map((exercise) => ({
@@ -73,9 +75,9 @@ export default async function StrengthWorkoutPage({
{exercisesWithHistory.some(({ history }) => history.length >= 2) ? (
<div className="flex flex-col gap-3">
<h2 className="flex items-center gap-1.5 text-sm font-semibold text-fg/70">
Postęp ćwiczeń
<InfoTooltip text="Wolumen (ciężar × powtórzenia) i maksymalny ciężar na tle poprzednich sesji z tym samym ćwiczeniem." />
</h2>
Postęp ćwiczeń
<InfoTooltip text="Wolumen (ciężar × powtórzenia) i maksymalny ciężar na tle poprzednich sesji z tym samym ćwiczeniem." />
</h2>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
{exercisesWithHistory
.filter(({ history }) => history.length >= 2)

View File

@@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
import { revalidatePath } from "next/cache";
import { parseStrongShareText } from "@/lib/strong/parser";
import { upsertStrengthWorkout } from "@/lib/models/strength";
import { getCurrentUserId } from "@/lib/session";
export type ImportStrongWorkoutState = { error: string } | null;
@@ -27,8 +28,9 @@ export async function importStrongWorkout(
return { error: "Nie znaleziono żadnego treningu w podanym tekście." };
}
const userId = await getCurrentUserId();
for (const workout of workouts) {
await upsertStrengthWorkout(workout);
await upsertStrengthWorkout(userId, workout);
}
revalidatePath("/strength");

View File

@@ -5,13 +5,15 @@ import { VolumeChart } from "@/components/volume-chart";
import { formatDateShort } from "@/lib/format";
import { listStrengthWorkouts } from "@/lib/models/strength";
import { workoutVolumeKg } from "@/lib/strength/stats";
import { getCurrentUserId } from "@/lib/session";
export const dynamic = "force-dynamic";
const VOLUME_CHART_LIMIT = 12;
export default async function StrengthPage() {
const workouts = await listStrengthWorkouts();
const userId = await getCurrentUserId();
const workouts = await listStrengthWorkouts(userId);
const volumeData = workouts
.slice(0, VOLUME_CHART_LIMIT)