- 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>
120 lines
3.3 KiB
TypeScript
120 lines
3.3 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState, useCallback } 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 { WeeklyPlanGrid } from "@/components/plans/WeeklyPlanGrid";
|
|
import { Badge } from "@/components/ui/Badge";
|
|
import { Button } from "@/components/ui/Button";
|
|
import { Spinner } from "@/components/ui/Spinner";
|
|
import { api } from "@/lib/api";
|
|
import type { GeneratedWeeklyPlan } from "@/lib/types";
|
|
|
|
function formatDate(dateStr: string): string {
|
|
const date = new Date(dateStr + "T00:00:00");
|
|
return date.toLocaleDateString("en-US", {
|
|
month: "short",
|
|
day: "numeric",
|
|
year: "numeric",
|
|
});
|
|
}
|
|
|
|
function getStatusVariant(
|
|
status: string
|
|
): "success" | "warning" | "error" | "default" {
|
|
switch (status) {
|
|
case "completed":
|
|
return "success";
|
|
case "pending":
|
|
return "warning";
|
|
case "failed":
|
|
return "error";
|
|
default:
|
|
return "default";
|
|
}
|
|
}
|
|
|
|
export default function PlanDetailPage({
|
|
params,
|
|
}: {
|
|
params: { planId: string };
|
|
}) {
|
|
const { planId } = params;
|
|
const [plan, setPlan] = useState<GeneratedWeeklyPlan | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
const fetchPlan = useCallback(async () => {
|
|
try {
|
|
const data = await api.getPlan(Number(planId));
|
|
setPlan(data);
|
|
} catch (err) {
|
|
console.error("Failed to fetch plan:", err);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, [planId]);
|
|
|
|
useEffect(() => {
|
|
fetchPlan();
|
|
}, [fetchPlan]);
|
|
|
|
return (
|
|
<AuthGuard>
|
|
<Navbar />
|
|
<BottomNav />
|
|
<main className="pt-20 pb-20 px-4 max-w-5xl mx-auto">
|
|
<Link
|
|
href="/plans"
|
|
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 to Plans
|
|
</Link>
|
|
|
|
{loading ? (
|
|
<div className="flex items-center justify-center py-20">
|
|
<Spinner size="lg" />
|
|
</div>
|
|
) : !plan ? (
|
|
<div className="text-center py-20">
|
|
<p className="text-zinc-400">Plan not found.</p>
|
|
</div>
|
|
) : (
|
|
<div>
|
|
<div className="flex items-center justify-between mb-6">
|
|
<div>
|
|
<h1 className="text-2xl font-bold text-zinc-100 mb-1">
|
|
{formatDate(plan.week_start_date)} –{" "}
|
|
{formatDate(plan.week_end_date)}
|
|
</h1>
|
|
<Badge variant={getStatusVariant(plan.status)}>
|
|
{plan.status}
|
|
</Badge>
|
|
</div>
|
|
<Button variant="secondary" size="sm" onClick={fetchPlan}>
|
|
Refresh
|
|
</Button>
|
|
</div>
|
|
|
|
<WeeklyPlanGrid plan={plan} onUpdate={fetchPlan} />
|
|
</div>
|
|
)}
|
|
</main>
|
|
</AuthGuard>
|
|
);
|
|
}
|