"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { supabase } from "@/lib/supabase"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Dumbbell, Users, FolderOpen, Flame } from "lucide-react"; interface Stats { workouts: number; trainers: number; collections: number; } export default function DashboardPage() { const [stats, setStats] = useState({ workouts: 0, trainers: 0, collections: 0 }); const [loading, setLoading] = useState(true); useEffect(() => { fetchStats(); }, []); const fetchStats = async () => { try { const [{ count: workouts }, { count: trainers }, { count: collections }] = await Promise.all([ supabase.from("workouts").select("*", { count: "exact", head: true }), supabase.from("trainers").select("*", { count: "exact", head: true }), supabase.from("collections").select("*", { count: "exact", head: true }), ]); setStats({ workouts: workouts || 0, trainers: trainers || 0, collections: collections || 0, }); } catch (error) { console.error("Failed to fetch stats:", error); } finally { setLoading(false); } }; const statCards = [ { title: "Workouts", value: stats.workouts, icon: Dumbbell, href: "/workouts", color: "text-orange-500" }, { title: "Trainers", value: stats.trainers, icon: Users, href: "/trainers", color: "text-blue-500" }, { title: "Collections", value: stats.collections, icon: FolderOpen, href: "/collections", color: "text-green-500" }, ]; return (

Dashboard

Overview of your TabataFit content

{statCards.map((stat) => { const Icon = stat.icon; return ( {stat.title}
{loading ? "-" : stat.value}
); })}
Quick Actions
Manage Workouts
Add, edit, or remove workouts
Manage Trainers
Update trainer profiles and photos
Upload Media
Add videos and thumbnails
Getting Started

Welcome to the TabataFit Admin Dashboard. Here you can manage all your fitness content.

  • Create and edit Tabata workouts
  • Manage trainer profiles
  • Organize workouts into collections
  • Upload workout videos and thumbnails
); }