import { useEffect, useState } from "react"; import { api } from "../api/client"; import { ProgressionChart } from "../components/charts/ProgressionChart"; import type { ProgressionMetric, ProgressionPoint, WorkoutKind } from "../types/api"; const METRICS: { key: ProgressionMetric; label: string }[] = [ { key: "pace", label: "Pace" }, { key: "hr", label: "Heart Rate" }, { key: "vo2max", label: "VO2max" }, { key: "aerobic_te", label: "Aerobic Training Effect" }, { key: "anaerobic_te", label: "Anaerobic Training Effect" }, { key: "efficiency_factor", label: "Efficiency Factor" }, ]; export function Analysis() { const [kinds, setKinds] = useState([]); const [selectedKindId, setSelectedKindId] = useState(null); const [metric, setMetric] = useState("pace"); const [points, setPoints] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { api .listWorkoutKinds() .then((k) => { setKinds(k); if (k.length > 0) setSelectedKindId(k[0].ID); }) .catch((e) => setError(String(e))); }, []); useEffect(() => { if (selectedKindId == null) return; setLoading(true); setError(null); api .progression(selectedKindId, metric) .then(setPoints) .catch((e) => setError(String(e))) .finally(() => setLoading(false)); }, [selectedKindId, metric]); return (
{kinds.length === 0 ? (

No training types defined yet. See the Training types card on the Profile page to start seeing progression here.

) : ( <>
{error &&

{error}

} {loading ?

Loading...

: } )}
); }