- Add rules_engine.py with quantitative rules for all 8 workout types - Add quality gate retry loop in generate_single_workout() - Expand calibrate_structure_rules to all 120 combinations (8 types × 5 goals × 3 sections) - Wire WeeklySplitPattern DB records into _pick_weekly_split() - Enforce movement patterns from WorkoutStructureRule in exercise selection - Add straight-set strength support (single main lift, 4-6 rounds) - Add modality consistency check for duration-dominant workout types - Add InjuryStep component to onboarding and preferences - Add sibling exercise exclusion in regenerate and preview_day endpoints - Display generator warnings on dashboard - Expand fix_rep_durations, fix_exercise_flags, fix_movement_pattern_typo - Add audit_exercise_data and check_rules_drift management commands - Add Next.js frontend with dashboard, onboarding, preferences, history pages - Add generator app with ML-powered workout generation pipeline - 96 new tests across 7 test modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
3.9 KiB
TypeScript
127 lines
3.9 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import Link from "next/link";
|
|
import { AuthGuard } from "@/components/auth/AuthGuard";
|
|
import { Navbar } from "@/components/layout/Navbar";
|
|
import { BottomNav } from "@/components/layout/BottomNav";
|
|
import { SupersetCard } from "@/components/workout/SupersetCard";
|
|
import { Spinner } from "@/components/ui/Spinner";
|
|
import { api } from "@/lib/api";
|
|
import type { WorkoutDetail } from "@/lib/types";
|
|
|
|
function formatTime(seconds: number | null): string {
|
|
if (!seconds) return "N/A";
|
|
const mins = Math.round(seconds / 60);
|
|
if (mins >= 60) {
|
|
const h = Math.floor(mins / 60);
|
|
const m = mins % 60;
|
|
return m > 0 ? `${h}h ${m}m` : `${h}h`;
|
|
}
|
|
return `${mins}m`;
|
|
}
|
|
|
|
export default function WorkoutDetailPage({
|
|
params,
|
|
}: {
|
|
params: { workoutId: string };
|
|
}) {
|
|
const { workoutId } = params;
|
|
const [workout, setWorkout] = useState<WorkoutDetail | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
api
|
|
.getWorkoutDetail(Number(workoutId))
|
|
.then(setWorkout)
|
|
.catch((err) => console.error("Failed to fetch workout:", err))
|
|
.finally(() => setLoading(false));
|
|
}, [workoutId]);
|
|
|
|
return (
|
|
<AuthGuard>
|
|
<Navbar />
|
|
<BottomNav />
|
|
<main className="pt-20 pb-20 px-4 max-w-4xl mx-auto">
|
|
<Link
|
|
href="/dashboard"
|
|
className="inline-flex items-center gap-1 text-sm text-zinc-400 hover:text-zinc-100 transition-colors mb-4"
|
|
>
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
width="16"
|
|
height="16"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth="2"
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
>
|
|
<polyline points="15 18 9 12 15 6" />
|
|
</svg>
|
|
Back
|
|
</Link>
|
|
|
|
{loading ? (
|
|
<div className="flex items-center justify-center py-20">
|
|
<Spinner size="lg" />
|
|
</div>
|
|
) : !workout ? (
|
|
<div className="text-center py-20">
|
|
<p className="text-zinc-400">Workout not found.</p>
|
|
</div>
|
|
) : (
|
|
<div>
|
|
<div className="mb-6">
|
|
<h1 className="text-2xl font-bold text-zinc-100 mb-2">
|
|
{workout.name}
|
|
</h1>
|
|
{workout.description && (
|
|
<p className="text-sm text-zinc-400 mb-3">
|
|
{workout.description}
|
|
</p>
|
|
)}
|
|
<div className="flex items-center gap-4 text-sm text-zinc-400">
|
|
<span className="flex items-center gap-1.5">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
width="16"
|
|
height="16"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth="2"
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
>
|
|
<circle cx="12" cy="12" r="10" />
|
|
<polyline points="12 6 12 12 16 14" />
|
|
</svg>
|
|
{formatTime(workout.estimated_time)}
|
|
</span>
|
|
<span>
|
|
{workout.supersets.length} superset
|
|
{workout.supersets.length !== 1 ? "s" : ""}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-4">
|
|
{[...workout.supersets]
|
|
.sort((a, b) => a.order - b.order)
|
|
.map((superset, i) => (
|
|
<SupersetCard
|
|
key={superset.id}
|
|
superset={superset}
|
|
defaultOpen={i === 0}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</main>
|
|
</AuthGuard>
|
|
);
|
|
}
|