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, serializeAnalysis } from "@/lib/models/analysis"; import { listRunningActivities } from "@/lib/models/running"; import { listStrengthWorkouts } from "@/lib/models/strength"; import { getCurrentUserId } from "@/lib/session"; export const dynamic = "force-dynamic"; export default async function Home() { const userId = await getCurrentUserId(); const [runs, strengthWorkouts, dashboardAnalysis] = await Promise.all([ listRunningActivities(userId), listStrengthWorkouts(userId), getDashboardAnalysis(userId), ]); 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 (