import { Suspense } from 'react' import Link from 'next/link' import { auth } from '@/lib/auth' import { prisma } from '@/lib/prisma' export const dynamic = 'force-dynamic' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { CheckCircle2, Clock, FileText, ExternalLink, AlertCircle, } from 'lucide-react' import { formatDate, truncate } from '@/lib/utils' async function AssignmentsContent({ roundId, }: { roundId?: string }) { const session = await auth() const userId = session?.user?.id if (!userId) { return null } // Get assignments, optionally filtered by round const assignments = await prisma.assignment.findMany({ where: { userId, ...(roundId ? { roundId } : {}), }, include: { project: { select: { id: true, title: true, teamName: true, description: true, status: true, files: { select: { id: true, fileType: true, }, }, }, }, round: { select: { id: true, name: true, status: true, votingStartAt: true, votingEndAt: true, program: { select: { name: true, }, }, }, }, evaluation: { select: { id: true, status: true, submittedAt: true, updatedAt: true, }, }, }, orderBy: [ { round: { votingEndAt: 'asc' } }, { createdAt: 'asc' }, ], }) if (assignments.length === 0) { return (

No assignments found

{roundId ? 'No projects assigned to you for this round' : "You don't have any project assignments yet"}

) } const now = new Date() return (
{/* Desktop table view */} Project Round Deadline Status Action {assignments.map((assignment) => { const evaluation = assignment.evaluation const isCompleted = evaluation?.status === 'SUBMITTED' const isDraft = evaluation?.status === 'DRAFT' const isVotingOpen = assignment.round.status === 'ACTIVE' && assignment.round.votingStartAt && assignment.round.votingEndAt && new Date(assignment.round.votingStartAt) <= now && new Date(assignment.round.votingEndAt) >= now return (

{truncate(assignment.project.title, 40)}

{assignment.project.teamName}

{assignment.round.name}

{assignment.round.program.name}

{assignment.round.votingEndAt ? ( {formatDate(assignment.round.votingEndAt)} ) : ( No deadline )} {isCompleted ? ( Completed ) : isDraft ? ( In Progress ) : ( Pending )} {isCompleted ? ( ) : isVotingOpen ? ( ) : ( )}
) })}
{/* Mobile card view */}
{assignments.map((assignment) => { const evaluation = assignment.evaluation const isCompleted = evaluation?.status === 'SUBMITTED' const isDraft = evaluation?.status === 'DRAFT' const isVotingOpen = assignment.round.status === 'ACTIVE' && assignment.round.votingStartAt && assignment.round.votingEndAt && new Date(assignment.round.votingStartAt) <= now && new Date(assignment.round.votingEndAt) >= now return (
{assignment.project.title} {assignment.project.teamName}
{isCompleted ? ( Done ) : isDraft ? ( Draft ) : ( Pending )}
Round {assignment.round.name}
{assignment.round.votingEndAt && (
Deadline {formatDate(assignment.round.votingEndAt)}
)}
{isCompleted ? ( ) : isVotingOpen ? ( ) : ( )}
) })}
) } function AssignmentsSkeleton() { return (
{[...Array(5)].map((_, i) => (
))}
) } export default async function JuryAssignmentsPage({ searchParams, }: { searchParams: Promise<{ round?: string }> }) { const params = await searchParams const roundId = params.round return (
{/* Header */}

My Assignments

Projects assigned to you for evaluation

{/* Content */} }>
) }