import type { Metadata } from 'next' import { Suspense } from 'react' import { auth } from '@/lib/auth' import { prisma } from '@/lib/prisma' export const metadata: Metadata = { title: 'Observer Dashboard' } export const dynamic = 'force-dynamic' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Progress } from '@/components/ui/progress' import { Skeleton } from '@/components/ui/skeleton' import { FolderKanban, ClipboardList, Users, CheckCircle2, Eye, } from 'lucide-react' import { formatDateOnly } from '@/lib/utils' async function ObserverDashboardContent() { const [ programCount, activeRoundCount, projectCount, jurorCount, evaluationStats, recentRounds, ] = await Promise.all([ prisma.program.count(), prisma.round.count({ where: { status: 'ACTIVE' } }), prisma.project.count(), prisma.user.count({ where: { role: 'JURY_MEMBER', status: 'ACTIVE' } }), prisma.evaluation.groupBy({ by: ['status'], _count: true, }), prisma.round.findMany({ orderBy: { createdAt: 'desc' }, take: 5, include: { program: { select: { name: true, year: true } }, _count: { select: { roundProjects: true, assignments: true, }, }, }, }), ]) const submittedCount = evaluationStats.find((e) => e.status === 'SUBMITTED')?._count || 0 const draftCount = evaluationStats.find((e) => e.status === 'DRAFT')?._count || 0 const totalEvaluations = submittedCount + draftCount const completionRate = totalEvaluations > 0 ? (submittedCount / totalEvaluations) * 100 : 0 return ( <> {/* Observer Notice */}

Observer Mode

You have read-only access to view platform statistics and reports.

{/* Stats Grid */}
Programs
{programCount}

{activeRoundCount} active round{activeRoundCount !== 1 ? 's' : ''}

Projects
{projectCount}

Across all rounds

Jury Members
{jurorCount}

Active members

Evaluations
{submittedCount}

{completionRate.toFixed(0)}% completion rate

{/* Recent Rounds */} Recent Rounds Overview of the latest voting rounds {recentRounds.length === 0 ? (

No rounds created yet

) : (
{recentRounds.map((round) => (

{round.name}

{round.status}

{round.program.year} Edition

{round._count.roundProjects} projects

{round._count.assignments} assignments

))}
)}
) } function DashboardSkeleton() { return ( <>
{[...Array(4)].map((_, i) => ( ))}
{[...Array(3)].map((_, i) => ( ))}
) } export default async function ObserverDashboardPage() { const session = await auth() return (
{/* Header */}

Dashboard

Welcome, {session?.user?.name || 'Observer'}

{/* Content */} }>
) }