import Link from "next/link"; import { startOfWeek } from "date-fns"; import { Activity, Dumbbell } from "lucide-react"; import { DashboardAnalysisCard } from "@/components/dashboard-analysis-card"; import { EmptyState } from "@/components/empty-state"; import { StatCard } from "@/components/stat-card"; import { formatDateShort, formatDistance, formatDuration, formatPace } from "@/lib/format"; import { getDashboardAnalysis } from "@/lib/models/analysis"; import { listRunningActivities } from "@/lib/models/running"; import { listStrengthWorkouts } from "@/lib/models/strength"; export const dynamic = "force-dynamic"; export default async function Home() { const [runs, strengthWorkouts, dashboardAnalysis] = await Promise.all([ listRunningActivities(), listStrengthWorkouts(), getDashboardAnalysis(), ]); const weekStart = startOfWeek(new Date(), { weekStartsOn: 1 }); const weeklyKm = runs .filter((run) => run.startTime >= weekStart) .reduce((sum, run) => sum + run.distanceM, 0) / 1000; const weeklyStrengthSessions = strengthWorkouts.filter((workout) => workout.date >= weekStart).length; const latestRun = runs[0]; const latestStrength = strengthWorkouts[0]; return (

Ostatni bieg

{latestRun ? (
{latestRun.name}
{formatDateShort(latestRun.startTime)}
{formatDistance(latestRun.distanceM)} · {formatDuration(latestRun.durationSec)} ·{" "} {formatPace(latestRun.avgPaceSecPerKm)}
) : ( } title="Brak danych o bieganiu" description="Zsynchronizuj aktywności z Garmin Connect, aby zobaczyć tutaj swoje biegi." action={{ href: "/running", label: "Przejdź do biegania" }} /> )}

Ostatni trening siłowy

{latestStrength ? (
{latestStrength.name}
{formatDateShort(latestStrength.date)}
{latestStrength.exercises.length}{" "} {latestStrength.exercises.length === 1 ? "ćwiczenie" : "ćwiczeń"}
) : ( } title="Brak treningów siłowych" description="Zaimportuj trening wklejając tekst wygenerowany przez aplikację Strong." action={{ href: "/strength/import", label: "Zaimportuj trening" }} /> )}
); }