feat: admin evaluation editing, ranking improvements, status transition fix
All checks were successful
Build and Push Docker Image / build (push) Successful in 9m26s

- Add adminEditEvaluation mutation and getJurorEvaluations query
- Create shared EvaluationEditSheet component with inline feedback editing
- Add Evaluations tab to member detail page (grouped by round)
- Make jury group member names clickable (link to member detail)
- Replace inline EvaluationDetailSheet on project page with shared component
- Fix project status transition validation (skip when status unchanged)
- Fix frontend to not send status when unchanged on project edit
- Ranking dashboard improvements and boolean decision converter fixes
- Backfill script updates for binary decisions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 10:46:52 +01:00
parent 49e706f2cf
commit c6ebd169dd
11 changed files with 857 additions and 245 deletions

View File

@@ -289,7 +289,9 @@ export default function JuryGroupDetailPage({ params }: JuryGroupDetailPageProps
{group.members.map((member) => (
<TableRow key={member.id}>
<TableCell className="font-medium">
{member.user.name || 'Unnamed'}
<Link href={`/admin/members/${member.user.id}` as Route} className="hover:underline text-primary">
{member.user.name || 'Unnamed'}
</Link>
</TableCell>
<TableCell className="text-sm text-muted-foreground">
{member.user.email}

View File

@@ -33,8 +33,10 @@ import {
TableRow,
} from '@/components/ui/table'
import { toast } from 'sonner'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { TagInput } from '@/components/shared/tag-input'
import { UserActivityLog } from '@/components/shared/user-activity-log'
import { EvaluationEditSheet } from '@/components/admin/evaluation-edit-sheet'
import {
AlertDialog,
AlertDialogAction,
@@ -53,6 +55,10 @@ import {
Shield,
Loader2,
AlertCircle,
ClipboardList,
Eye,
ThumbsUp,
ThumbsDown,
} from 'lucide-react'
export default function MemberDetailPage() {
@@ -73,6 +79,16 @@ export default function MemberDetailPage() {
{ enabled: user?.role === 'MENTOR' }
)
// Juror evaluations (only fetched for jury members)
const isJuror = user?.role === 'JURY_MEMBER' || user?.roles?.includes('JURY_MEMBER')
const { data: jurorEvaluations } = trpc.evaluation.getJurorEvaluations.useQuery(
{ userId },
{ enabled: !!user && !!isJuror }
)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [selectedEvaluation, setSelectedEvaluation] = useState<any>(null)
const [name, setName] = useState('')
const [email, setEmail] = useState('')
const [role, setRole] = useState<string>('JURY_MEMBER')
@@ -207,6 +223,26 @@ export default function MemberDetailPage() {
)}
</div>
<Tabs defaultValue="profile" className="space-y-6">
<TabsList>
<TabsTrigger value="profile">
<User className="h-4 w-4 mr-1" />
Profile
</TabsTrigger>
{isJuror && (
<TabsTrigger value="evaluations">
<ClipboardList className="h-4 w-4 mr-1" />
Evaluations
{jurorEvaluations && jurorEvaluations.length > 0 && (
<Badge variant="secondary" className="ml-1.5 text-xs px-1.5 py-0">
{jurorEvaluations.length}
</Badge>
)}
</TabsTrigger>
)}
</TabsList>
<TabsContent value="profile" className="space-y-6">
<div className="grid gap-6 md:grid-cols-2">
{/* Basic Info */}
<Card>
@@ -430,6 +466,121 @@ export default function MemberDetailPage() {
Save Changes
</Button>
</div>
</TabsContent>
{/* Evaluations Tab */}
{isJuror && (
<TabsContent value="evaluations" className="space-y-4">
{!jurorEvaluations || jurorEvaluations.length === 0 ? (
<Card>
<CardContent className="flex flex-col items-center justify-center py-12 text-center">
<ClipboardList className="h-12 w-12 text-muted-foreground/30" />
<p className="mt-2 text-muted-foreground">No evaluations submitted yet</p>
</CardContent>
</Card>
) : (
(() => {
// Group evaluations by round
const byRound = new Map<string, typeof jurorEvaluations>()
for (const ev of jurorEvaluations) {
const key = ev.roundName
if (!byRound.has(key)) byRound.set(key, [])
byRound.get(key)!.push(ev)
}
return Array.from(byRound.entries()).map(([roundName, evals]) => (
<Card key={roundName}>
<CardHeader>
<CardTitle className="text-base">{roundName}</CardTitle>
<CardDescription>{evals.length} evaluation{evals.length !== 1 ? 's' : ''}</CardDescription>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Project</TableHead>
<TableHead>Score</TableHead>
<TableHead>Decision</TableHead>
<TableHead>Status</TableHead>
<TableHead>Submitted</TableHead>
<TableHead className="w-10"></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{evals.map((ev) => (
<TableRow key={ev.assignmentId}>
<TableCell className="font-medium">
<Link
href={`/admin/projects/${ev.projectId}`}
className="hover:underline text-primary"
>
{ev.projectTitle}
</Link>
</TableCell>
<TableCell>
{ev.evaluation.globalScore !== null && ev.evaluation.globalScore !== undefined
? <span className="font-medium">{ev.evaluation.globalScore}/10</span>
: <span className="text-muted-foreground">-</span>}
</TableCell>
<TableCell>
{ev.evaluation.binaryDecision !== null && ev.evaluation.binaryDecision !== undefined ? (
ev.evaluation.binaryDecision ? (
<div className="flex items-center gap-1 text-green-600">
<ThumbsUp className="h-4 w-4" />
<span className="text-sm">Yes</span>
</div>
) : (
<div className="flex items-center gap-1 text-red-600">
<ThumbsDown className="h-4 w-4" />
<span className="text-sm">No</span>
</div>
)
) : (
<span className="text-muted-foreground">-</span>
)}
</TableCell>
<TableCell>
<Badge variant={ev.evaluation.status === 'SUBMITTED' ? 'default' : 'secondary'}>
{ev.evaluation.status.replace('_', ' ')}
</Badge>
</TableCell>
<TableCell className="text-sm text-muted-foreground">
{ev.evaluation.submittedAt
? new Date(ev.evaluation.submittedAt).toLocaleDateString()
: '-'}
</TableCell>
<TableCell>
<Button
variant="ghost"
size="sm"
onClick={() => setSelectedEvaluation({
...ev,
user: user,
evaluation: ev.evaluation,
})}
>
<Eye className="h-4 w-4" />
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</CardContent>
</Card>
))
})()
)}
<EvaluationEditSheet
assignment={selectedEvaluation}
open={!!selectedEvaluation}
onOpenChange={(open) => { if (!open) setSelectedEvaluation(null) }}
onSaved={() => utils.evaluation.getJurorEvaluations.invalidate({ userId })}
/>
</TabsContent>
)}
</Tabs>
{/* Super Admin Confirmation Dialog */}
<AlertDialog open={showSuperAdminConfirm} onOpenChange={setShowSuperAdminConfirm}>

View File

@@ -267,12 +267,13 @@ function EditProjectContent({ projectId }: { projectId: string }) {
return
}
const statusChanged = data.status !== previousStatus
await updateProject.mutateAsync({
id: projectId,
title: data.title,
teamName: data.teamName || null,
description: data.description || null,
status: data.status,
...(statusChanged && { status: data.status }),
tags: data.tags,
competitionCategory: (data.competitionCategory || null) as 'STARTUP' | 'BUSINESS_CONCEPT' | null,
oceanIssue: (data.oceanIssue || null) as 'POLLUTION_REDUCTION' | 'CLIMATE_MITIGATION' | 'TECHNOLOGY_INNOVATION' | 'SUSTAINABLE_SHIPPING' | 'BLUE_CARBON' | 'HABITAT_RESTORATION' | 'COMMUNITY_CAPACITY' | 'SUSTAINABLE_FISHING' | 'CONSUMER_AWARENESS' | 'OCEAN_ACIDIFICATION' | 'OTHER' | null,

View File

@@ -28,13 +28,7 @@ import { FileUpload } from '@/components/shared/file-upload'
import { ProjectLogoWithUrl } from '@/components/shared/project-logo-with-url'
import { UserAvatar } from '@/components/shared/user-avatar'
import { EvaluationSummaryCard } from '@/components/admin/evaluation-summary-card'
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
} from '@/components/ui/sheet'
import { EvaluationEditSheet } from '@/components/admin/evaluation-edit-sheet'
import { AnimatedCard } from '@/components/shared/animated-container'
import {
ArrowLeft,
@@ -56,7 +50,6 @@ import {
Loader2,
ScanSearch,
Eye,
MessageSquare,
} from 'lucide-react'
import { toast } from 'sonner'
import { formatDate, formatDateOnly } from '@/lib/utils'
@@ -742,10 +735,11 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
)}
{/* Evaluation Detail Sheet */}
<EvaluationDetailSheet
<EvaluationEditSheet
assignment={selectedEvalAssignment}
open={!!selectedEvalAssignment}
onOpenChange={(open) => { if (!open) setSelectedEvalAssignment(null) }}
onSaved={() => utils.project.getFullDetail.invalidate({ id: projectId })}
/>
{/* AI Evaluation Summary */}
@@ -830,173 +824,6 @@ function AnalyzeDocumentsButton({ projectId, onComplete }: { projectId: string;
)
}
function EvaluationDetailSheet({
assignment,
open,
onOpenChange,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assignment: any
open: boolean
onOpenChange: (open: boolean) => void
}) {
if (!assignment?.evaluation) return null
const ev = assignment.evaluation
const criterionScores = (ev.criterionScoresJson || {}) as Record<string, number | boolean | string>
const hasScores = Object.keys(criterionScores).length > 0
// Try to get the evaluation form for labels
const roundId = assignment.roundId as string | undefined
const { data: activeForm } = trpc.evaluation.getStageForm.useQuery(
{ roundId: roundId ?? '' },
{ enabled: !!roundId }
)
// Build label lookup from form criteria
const criteriaMap = new Map<string, { label: string; type: string; trueLabel?: string; falseLabel?: string }>()
if (activeForm?.criteriaJson) {
for (const c of activeForm.criteriaJson as Array<{ id: string; label: string; type?: string; trueLabel?: string; falseLabel?: string }>) {
criteriaMap.set(c.id, {
label: c.label,
type: c.type || 'numeric',
trueLabel: c.trueLabel,
falseLabel: c.falseLabel,
})
}
}
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent className="sm:max-w-lg overflow-y-auto">
<SheetHeader>
<SheetTitle className="flex items-center gap-2">
<UserAvatar user={assignment.user} avatarUrl={assignment.user.avatarUrl} size="sm" />
{assignment.user.name || assignment.user.email}
</SheetTitle>
<SheetDescription>
{ev.submittedAt
? `Submitted ${formatDate(ev.submittedAt)}`
: 'Evaluation details'}
</SheetDescription>
</SheetHeader>
<div className="space-y-6 mt-6">
{/* Global stats */}
<div className="grid grid-cols-2 gap-3">
<div className="p-3 rounded-lg bg-muted">
<p className="text-xs text-muted-foreground">Score</p>
<p className="text-2xl font-bold">
{ev.globalScore !== null ? `${ev.globalScore}/10` : '-'}
</p>
</div>
<div className="p-3 rounded-lg bg-muted">
<p className="text-xs text-muted-foreground">Decision</p>
<div className="mt-1">
{ev.binaryDecision !== null ? (
ev.binaryDecision ? (
<div className="flex items-center gap-1.5 text-emerald-600">
<ThumbsUp className="h-5 w-5" />
<span className="font-semibold">Yes</span>
</div>
) : (
<div className="flex items-center gap-1.5 text-red-600">
<ThumbsDown className="h-5 w-5" />
<span className="font-semibold">No</span>
</div>
)
) : (
<span className="text-2xl font-bold">-</span>
)}
</div>
</div>
</div>
{/* Criterion Scores */}
{hasScores && (
<div>
<h4 className="text-sm font-medium mb-3 flex items-center gap-2">
<BarChart3 className="h-4 w-4" />
Criterion Scores
</h4>
<div className="space-y-2.5">
{Object.entries(criterionScores).map(([key, value]) => {
const meta = criteriaMap.get(key)
const label = meta?.label || key
const type = meta?.type || (typeof value === 'boolean' ? 'boolean' : typeof value === 'string' ? 'text' : 'numeric')
if (type === 'section_header') return null
if (type === 'boolean' || type === 'advance') {
return (
<div key={key} className="flex items-center justify-between p-2.5 rounded-lg border">
<span className="text-sm">{label}</span>
{value === true ? (
<Badge className="bg-emerald-100 text-emerald-700 border-emerald-200" variant="outline">
<ThumbsUp className="mr-1 h-3 w-3" />
{meta?.trueLabel || 'Yes'}
</Badge>
) : (
<Badge className="bg-red-100 text-red-700 border-red-200" variant="outline">
<ThumbsDown className="mr-1 h-3 w-3" />
{meta?.falseLabel || 'No'}
</Badge>
)}
</div>
)
}
if (type === 'text') {
return (
<div key={key} className="space-y-1">
<span className="text-sm font-medium">{label}</span>
<div className="text-sm text-muted-foreground p-2.5 rounded-lg border bg-muted/50 whitespace-pre-wrap">
{typeof value === 'string' ? value : String(value)}
</div>
</div>
)
}
// Numeric
return (
<div key={key} className="flex items-center gap-3 p-2.5 rounded-lg border">
<span className="text-sm flex-1 truncate">{label}</span>
<div className="flex items-center gap-2 shrink-0">
<div className="w-20 h-2 rounded-full bg-muted overflow-hidden">
<div
className="h-full rounded-full bg-primary"
style={{ width: `${(Number(value) / 10) * 100}%` }}
/>
</div>
<span className="text-sm font-bold tabular-nums w-8 text-right">
{typeof value === 'number' ? value : '-'}
</span>
</div>
</div>
)
})}
</div>
</div>
)}
{/* Feedback Text */}
{ev.feedbackText && (
<div>
<h4 className="text-sm font-medium mb-2 flex items-center gap-2">
<MessageSquare className="h-4 w-4" />
Feedback
</h4>
<div className="text-sm text-muted-foreground p-3 rounded-lg border bg-muted/30 whitespace-pre-wrap leading-relaxed">
{ev.feedbackText}
</div>
</div>
)}
</div>
</SheetContent>
</Sheet>
)
}
export default function ProjectDetailPage({ params }: PageProps) {
const { id } = use(params)