Jury evaluation UX overhaul + admin review features
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m53s

- Fix project documents not displaying on jury project page (rewrote MultiWindowDocViewer to use file.listByProject)
- Add working download/preview for project files via presigned URLs
- Display project tags on jury project detail page
- Add autosave for evaluation drafts (debounced 3s + save on unmount/beforeunload)
- Support mixed criterion types: numeric scores, yes/no booleans, text responses, section headers
- Replace inline criteria editor with rich EvaluationFormBuilder on admin round page
- Remove COI dialog from evaluation page
- Update AI summary service to handle boolean/text criteria (yes/no counts, text synthesis)
- Update EvaluationSummaryCard to show boolean criteria bars and text responses
- Add evaluation detail sheet on admin project page (click juror row to view full scores + feedback)
- Add Recent Evaluations dashboard widget showing latest jury reviews

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-18 12:43:28 +01:00
parent 73759eaddd
commit 9ce56f13fd
12 changed files with 1137 additions and 385 deletions

View File

@@ -42,10 +42,21 @@ interface EvaluationSummaryCardProps {
roundId: string
}
interface BooleanStats {
yesCount: number
noCount: number
total: number
yesPercent: number
trueLabel: string
falseLabel: string
}
interface ScoringPatterns {
averageGlobalScore: number | null
consensus: number
criterionAverages: Record<string, number>
booleanCriteria?: Record<string, BooleanStats>
textResponses?: Record<string, string[]>
evaluatorCount: number
}
@@ -296,10 +307,10 @@ export function EvaluationSummaryCard({
</div>
)}
{/* Criterion Averages */}
{/* Criterion Averages (Numeric) */}
{Object.keys(patterns.criterionAverages).length > 0 && (
<div>
<p className="text-sm font-medium mb-2">Criterion Averages</p>
<p className="text-sm font-medium mb-2">Score Averages</p>
<div className="space-y-2">
{Object.entries(patterns.criterionAverages).map(([label, avg]) => (
<div key={label} className="flex items-center gap-3">
@@ -323,6 +334,69 @@ export function EvaluationSummaryCard({
</div>
)}
{/* Boolean Criteria (Yes/No) */}
{patterns.booleanCriteria && Object.keys(patterns.booleanCriteria).length > 0 && (
<div>
<p className="text-sm font-medium mb-2">Yes/No Decisions</p>
<div className="space-y-3">
{Object.entries(patterns.booleanCriteria).map(([label, stats]) => (
<div key={label} className="space-y-1">
<div className="flex items-center justify-between">
<span className="text-sm text-muted-foreground truncate">
{label}
</span>
<span className="text-xs text-muted-foreground flex-shrink-0 ml-2">
{stats.yesCount} {stats.trueLabel} / {stats.noCount} {stats.falseLabel}
</span>
</div>
<div className="flex h-2 rounded-full overflow-hidden bg-muted">
{stats.yesCount > 0 && (
<div
className="h-full bg-emerald-500 transition-all"
style={{ width: `${stats.yesPercent}%` }}
/>
)}
{stats.noCount > 0 && (
<div
className="h-full bg-red-400 transition-all"
style={{ width: `${100 - stats.yesPercent}%` }}
/>
)}
</div>
<div className="flex justify-between text-xs">
<span className="text-emerald-600">{stats.yesPercent}% {stats.trueLabel}</span>
<span className="text-red-500">{100 - stats.yesPercent}% {stats.falseLabel}</span>
</div>
</div>
))}
</div>
</div>
)}
{/* Text Responses */}
{patterns.textResponses && Object.keys(patterns.textResponses).length > 0 && (
<div>
<p className="text-sm font-medium mb-2">Text Responses</p>
<div className="space-y-3">
{Object.entries(patterns.textResponses).map(([label, responses]) => (
<div key={label} className="space-y-1.5">
<p className="text-sm text-muted-foreground">{label}</p>
<div className="space-y-1.5">
{responses.map((text, i) => (
<div
key={i}
className="text-sm p-2 rounded border bg-muted/50 whitespace-pre-wrap"
>
{text}
</div>
))}
</div>
</div>
))}
</div>
</div>
)}
{/* Recommendation */}
{summaryData.recommendation && (
<div className="p-3 rounded-lg bg-blue-500/10 border border-blue-200">

View File

@@ -0,0 +1,114 @@
'use client'
import Link from 'next/link'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { ClipboardCheck, ThumbsUp, ThumbsDown, ExternalLink } from 'lucide-react'
import { formatDistanceToNow } from 'date-fns'
type RecentEvaluation = {
id: string
globalScore: number | null
binaryDecision: boolean | null
submittedAt: Date | string | null
feedbackText: string | null
assignment: {
project: { id: string; title: string }
round: { id: string; name: string }
user: { id: string; name: string | null; email: string }
}
}
export function RecentEvaluations({ evaluations }: { evaluations: RecentEvaluation[] }) {
if (!evaluations || evaluations.length === 0) {
return (
<Card>
<CardHeader className="pb-3">
<CardTitle className="flex items-center gap-2 text-base">
<ClipboardCheck className="h-4 w-4" />
Recent Evaluations
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground text-center py-4">
No evaluations submitted yet
</p>
</CardContent>
</Card>
)
}
return (
<Card>
<CardHeader className="pb-3">
<CardTitle className="flex items-center gap-2 text-base">
<ClipboardCheck className="h-4 w-4" />
Recent Evaluations
</CardTitle>
<CardDescription>Latest jury reviews as they come in</CardDescription>
</CardHeader>
<CardContent className="space-y-3">
{evaluations.map((ev) => (
<Link
key={ev.id}
href={`/admin/projects/${ev.assignment.project.id}`}
className="block group"
>
<div className="flex items-start gap-3 p-2.5 rounded-lg border hover:bg-muted/50 transition-colors">
{/* Score indicator */}
<div className="flex flex-col items-center gap-0.5 shrink-0 pt-0.5">
{ev.globalScore !== null ? (
<span className="text-lg font-bold tabular-nums leading-none">
{ev.globalScore}
</span>
) : (
<span className="text-lg font-bold text-muted-foreground leading-none">-</span>
)}
<span className="text-[10px] text-muted-foreground">/10</span>
</div>
{/* Details */}
<div className="flex-1 min-w-0 space-y-1">
<div className="flex items-center gap-2">
<p className="text-sm font-medium truncate flex-1">
{ev.assignment.project.title}
</p>
<ExternalLink className="h-3 w-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0" />
</div>
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<span className="truncate">{ev.assignment.user.name || ev.assignment.user.email}</span>
<span className="shrink-0">
{ev.submittedAt
? formatDistanceToNow(new Date(ev.submittedAt), { addSuffix: true })
: ''}
</span>
</div>
<div className="flex items-center gap-2">
<Badge variant="outline" className="text-[10px] h-5">
{ev.assignment.round.name}
</Badge>
{ev.binaryDecision !== null && (
ev.binaryDecision ? (
<span className="flex items-center gap-0.5 text-xs text-emerald-600">
<ThumbsUp className="h-3 w-3" /> Yes
</span>
) : (
<span className="flex items-center gap-0.5 text-xs text-red-500">
<ThumbsDown className="h-3 w-3" /> No
</span>
)
)}
</div>
{ev.feedbackText && (
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
{ev.feedbackText}
</p>
)}
</div>
</div>
</Link>
))}
</CardContent>
</Card>
)
}

View File

@@ -1,12 +1,12 @@
'use client'
import { useState } from 'react'
import { trpc } from '@/lib/trpc/client'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Skeleton } from '@/components/ui/skeleton'
import { FileText, Download, ExternalLink } from 'lucide-react'
import { FileText, Download, ExternalLink, Loader2 } from 'lucide-react'
import { toast } from 'sonner'
interface MultiWindowDocViewerProps {
@@ -32,10 +32,110 @@ function getFileIcon(mimeType: string) {
return '📎'
}
function canPreviewInBrowser(mimeType: string): boolean {
return (
mimeType === 'application/pdf' ||
mimeType.startsWith('image/') ||
mimeType.startsWith('video/') ||
mimeType.startsWith('text/')
)
}
function FileCard({ file }: { file: { id: string; fileName: string; mimeType: string; size: number; bucket: string; objectKey: string } }) {
const [loadingAction, setLoadingAction] = useState<'download' | 'preview' | null>(null)
const downloadUrlQuery = trpc.file.getDownloadUrl.useQuery(
{ bucket: file.bucket, objectKey: file.objectKey },
{ enabled: false } // manual trigger
)
const handleAction = async (action: 'download' | 'preview') => {
setLoadingAction(action)
try {
const result = await downloadUrlQuery.refetch()
if (result.data?.url) {
if (action === 'preview' && canPreviewInBrowser(file.mimeType)) {
window.open(result.data.url, '_blank')
} else {
// Download: create temp link and click
const a = document.createElement('a')
a.href = result.data.url
a.download = file.fileName
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
}
} catch {
toast.error('Failed to get file URL')
} finally {
setLoadingAction(null)
}
}
return (
<Card className="overflow-hidden">
<CardContent className="p-4">
<div className="flex items-start gap-3">
<div className="text-2xl">{getFileIcon(file.mimeType || '')}</div>
<div className="flex-1 min-w-0">
<p className="font-medium text-sm truncate" title={file.fileName}>
{file.fileName}
</p>
<div className="flex items-center gap-2 mt-1">
<Badge variant="outline" className="text-xs">
{file.mimeType?.split('/')[1]?.toUpperCase() || 'FILE'}
</Badge>
{file.size > 0 && (
<span className="text-xs text-muted-foreground">
{formatFileSize(file.size)}
</span>
)}
</div>
<div className="flex gap-2 mt-3">
<Button
size="sm"
variant="outline"
className="h-7 text-xs"
onClick={() => handleAction('download')}
disabled={loadingAction !== null}
>
{loadingAction === 'download' ? (
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
) : (
<Download className="mr-1 h-3 w-3" />
)}
Download
</Button>
{canPreviewInBrowser(file.mimeType) && (
<Button
size="sm"
variant="ghost"
className="h-7 text-xs"
onClick={() => handleAction('preview')}
disabled={loadingAction !== null}
>
{loadingAction === 'preview' ? (
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
) : (
<ExternalLink className="mr-1 h-3 w-3" />
)}
Preview
</Button>
)}
</div>
</div>
</div>
</CardContent>
</Card>
)
}
export function MultiWindowDocViewer({ roundId, projectId }: MultiWindowDocViewerProps) {
const { data: windows, isLoading } = trpc.round.getVisibleWindows.useQuery(
{ roundId },
{ enabled: !!roundId }
const { data: files, isLoading } = trpc.file.listByProject.useQuery(
{ projectId },
{ enabled: !!projectId }
)
if (isLoading) {
@@ -51,94 +151,67 @@ export function MultiWindowDocViewer({ roundId, projectId }: MultiWindowDocViewe
)
}
if (!windows || windows.length === 0) {
if (!files || files.length === 0) {
return (
<Card>
<CardHeader>
<CardTitle>Documents</CardTitle>
<CardDescription>Submission windows and uploaded files</CardDescription>
<CardDescription>Project files and submissions</CardDescription>
</CardHeader>
<CardContent className="text-center py-8">
<FileText className="h-12 w-12 text-muted-foreground/50 mx-auto mb-3" />
<p className="text-sm text-muted-foreground">No submission windows available</p>
<p className="text-sm text-muted-foreground">No files uploaded</p>
</CardContent>
</Card>
)
}
// Group files by round name or "General"
const grouped: Record<string, typeof files> = {}
for (const file of files) {
const groupName = file.requirement?.round?.name ?? 'General'
if (!grouped[groupName]) grouped[groupName] = []
grouped[groupName].push(file)
}
const groupNames = Object.keys(grouped)
return (
<Card>
<CardHeader>
<CardTitle>Documents</CardTitle>
<CardDescription>Files submitted across all windows</CardDescription>
<CardDescription>
{files.length} file{files.length !== 1 ? 's' : ''} submitted
</CardDescription>
</CardHeader>
<CardContent>
<Tabs defaultValue={windows[0]?.id || ''} className="w-full">
<TabsList className="w-full flex-wrap justify-start h-auto gap-1 bg-transparent p-0 mb-4">
{windows.map((window: any) => (
<TabsTrigger
key={window.id}
value={window.id}
className="data-[state=active]:bg-brand-blue data-[state=active]:text-white px-4 py-2 rounded-md text-sm"
>
{window.name}
{window.files && window.files.length > 0 && (
<Badge variant="secondary" className="ml-2 text-xs">
{window.files.length}
</Badge>
)}
</TabsTrigger>
{groupNames.length === 1 ? (
// Single group — no need for headers
<div className="grid gap-3 sm:grid-cols-2">
{grouped[groupNames[0]].map((file) => (
<FileCard key={file.id} file={file} />
))}
</TabsList>
{windows.map((window: any) => (
<TabsContent key={window.id} value={window.id} className="mt-0">
{!window.files || window.files.length === 0 ? (
<div className="text-center py-8 border border-dashed rounded-lg">
<FileText className="h-10 w-10 text-muted-foreground/50 mx-auto mb-2" />
<p className="text-sm text-muted-foreground">No files uploaded</p>
</div>
) : (
</div>
) : (
// Multiple groups — show headers
<div className="space-y-6">
{groupNames.map((groupName) => (
<div key={groupName}>
<h4 className="font-medium text-sm text-muted-foreground mb-3">
{groupName}
<Badge variant="secondary" className="ml-2 text-xs">
{grouped[groupName].length}
</Badge>
</h4>
<div className="grid gap-3 sm:grid-cols-2">
{window.files.map((file: any) => (
<Card key={file.id} className="overflow-hidden">
<CardContent className="p-4">
<div className="flex items-start gap-3">
<div className="text-2xl">{getFileIcon(file.mimeType || '')}</div>
<div className="flex-1 min-w-0">
<p className="font-medium text-sm truncate" title={file.filename}>
{file.filename}
</p>
<div className="flex items-center gap-2 mt-1">
<Badge variant="outline" className="text-xs">
{file.mimeType?.split('/')[1]?.toUpperCase() || 'FILE'}
</Badge>
{file.size && (
<span className="text-xs text-muted-foreground">
{formatFileSize(file.size)}
</span>
)}
</div>
<div className="flex gap-2 mt-3">
<Button size="sm" variant="outline" className="h-7 text-xs">
<Download className="mr-1 h-3 w-3" />
Download
</Button>
<Button size="sm" variant="ghost" className="h-7 text-xs">
<ExternalLink className="mr-1 h-3 w-3" />
Preview
</Button>
</div>
</div>
</div>
</CardContent>
</Card>
{grouped[groupName].map((file) => (
<FileCard key={file.id} file={file} />
))}
</div>
)}
</TabsContent>
))}
</Tabs>
</div>
))}
</div>
)}
</CardContent>
</Card>
)