'use client'; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/components/ui/card"; import { Button } from "~/components/ui/button"; import { Users, BookOpen, Settings2 } from "lucide-react"; import { useToast } from "~/hooks/use-toast"; interface DashboardStats { studyCount: number; participantCount: number; activeInvitationCount: number; } export default function Dashboard() { const [stats, setStats] = useState({ studyCount: 0, participantCount: 0, activeInvitationCount: 0, }); const [loading, setLoading] = useState(true); const router = useRouter(); const { toast } = useToast(); useEffect(() => { fetchDashboardStats(); }, []); const fetchDashboardStats = async () => { try { const studiesRes = await fetch('/api/studies'); const studies = await studiesRes.json(); // For now, just show study count setStats({ studyCount: studies.length, participantCount: 0, activeInvitationCount: 0, }); } catch (error) { console.error('Error fetching dashboard stats:', error); toast({ title: "Error", description: "Failed to load dashboard statistics", variant: "destructive", }); } finally { setLoading(false); } }; if (loading) { return (
); } return (

Dashboard

Overview of your research studies

Total Studies
{stats.studyCount ? stats.studyCount : 0}

Active research studies

Total Participants
{stats.participantCount}

Across all studies

Pending Invitations
{stats.activeInvitationCount}

Awaiting acceptance

Quick Actions Common tasks and actions Getting Started Tips for using HRIStudio

• Create a new study from the Studies page

• Invite collaborators using study settings

• Add participants to begin collecting data

); }