import { redirect } from "next/navigation"; import Link from "next/link"; import { getCurrentUser } from "@/lib/auth"; import { getWeeklyWorkoutCount, getMonthlyWorkoutCount, getYearlyWorkoutCount, getWeeklyVolume, } from "@/lib/db/stats"; import { getRecentWorkouts } from "@/lib/db/workouts"; import { ActivitySquare, Calendar, CalendarDays, History, Plus } from "lucide-react"; export default async function DashboardPage() { const user = await getCurrentUser(); if (!user) { redirect("/auth/login"); } const [weeklyCount, monthlyCount, yearlyCount, _weeklyVolume, recentWorkouts] = await Promise.all([ getWeeklyWorkoutCount(user.id), getMonthlyWorkoutCount(user.id), getYearlyWorkoutCount(user.id), getWeeklyVolume(user.id), getRecentWorkouts(user.id, 5), ]); return (
Keep pushing your limits and achieving your goals.
This Week
{weeklyCount}
workouts
This Month
{monthlyCount}
workouts
This Year
{yearlyCount}
workouts
Start your fitness journey by logging your first workout!
Log First Workout{new Date(workout.date).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric", year: "numeric", })}
{(workout as any).setLogs.length} sets {workout.durationMinutes && ` ยท ${workout.durationMinutes} min`}
{(workout as any).setLogs.length === 1 ? "set" : "sets"}