'use client' import { useParams } from 'next/navigation' import Link from 'next/link' import { trpc } from '@/lib/trpc/client' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { Skeleton } from '@/components/ui/skeleton' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' import { ArrowLeft, Plus, UserMinus } from 'lucide-react' import { toast } from 'sonner' export default function ProjectAssignmentsPage() { const params = useParams() const id = params.id as string const { data: project, isLoading: projectLoading } = trpc.project.get.useQuery({ id }) const { data: assignments = [], isLoading: assignmentsLoading } = trpc.assignment.listByProject.useQuery({ projectId: id }) const utils = trpc.useUtils() const removeAssignment = trpc.assignment.delete.useMutation({ onSuccess: () => { toast.success('Assignment removed') utils.assignment.listByProject.invalidate({ projectId: id }) }, onError: (error) => { toast.error(error.message || 'Failed to remove assignment') }, }) // Remove handled via AlertDialog in JSX const isLoading = projectLoading || assignmentsLoading if (isLoading) { return (
) } return (

Jury Assignments

{project?.title}

Assigned Jury Members {assignments.length} jury member{assignments.length !== 1 ? 's' : ''} assigned to evaluate this project {assignments.length === 0 ? (
No jury members assigned yet.
) : ( Jury Member Status Actions {assignments.map((assignment) => (

{assignment.user.name}

{assignment.user.email}

{assignment.evaluation?.status || 'Pending'} Remove Assignment Remove this jury member from the project? Their evaluation data will also be deleted. Cancel removeAssignment.mutate({ id: assignment.id })}> Remove
))}
)}
) }