Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
- Add roles UserRole[] to User model with migration + backfill from existing role column - Update auth JWT/session to propagate roles array with [role] fallback for stale tokens - Update tRPC hasRole() middleware and add userHasRole() helper for inline role checks - Update ~15 router inline checks and ~13 DB queries to use roles array - Add updateRoles admin mutation with SUPER_ADMIN guard and priority-based primary role - Add role switcher UI in admin sidebar and role-nav for multi-role users - Remove redundant stats cards from round detail, add window dates to header banner - Merge Members section into JuryProgressTable with inline cap editor and remove buttons - Reorder round detail assignments tab: Progress > Score Dist > Assignments > Coverage > Jury Group - Make score distribution fill full vertical height, reassignment history always open - Add per-juror progress bars to admin dashboard ActiveRoundPanel for EVALUATION rounds - Fix evaluation submit bug: use isSubmitting state instead of startMutation.isPending Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
102 lines
4.2 KiB
TypeScript
102 lines
4.2 KiB
TypeScript
'use client'
|
|
|
|
import { trpc } from '@/lib/trpc/client'
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { Skeleton } from '@/components/ui/skeleton'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { History } from 'lucide-react'
|
|
|
|
export type ReassignmentHistoryProps = {
|
|
roundId: string
|
|
}
|
|
|
|
export function ReassignmentHistory({ roundId }: ReassignmentHistoryProps) {
|
|
const { data: events, isLoading } = trpc.assignment.getReassignmentHistory.useQuery(
|
|
{ roundId },
|
|
)
|
|
|
|
return (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-base flex items-center gap-2">
|
|
<History className="h-4 w-4" />
|
|
Reassignment History
|
|
</CardTitle>
|
|
<CardDescription>Juror dropout, COI, transfer, and cap redistribution audit trail</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
{isLoading ? (
|
|
<div className="space-y-3">
|
|
{[1, 2].map((i) => <Skeleton key={i} className="h-16 w-full" />)}
|
|
</div>
|
|
) : !events || events.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground text-center py-6">
|
|
No reassignment events for this round
|
|
</p>
|
|
) : (
|
|
<div className="space-y-4 max-h-[500px] overflow-y-auto">
|
|
{events.map((event) => (
|
|
<div key={event.id} className="border rounded-lg p-3 space-y-2">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-2">
|
|
<Badge variant={event.type === 'DROPOUT' ? 'destructive' : 'secondary'}>
|
|
{event.type === 'DROPOUT' ? 'Juror Dropout' : event.type === 'COI' ? 'COI Reassignment' : event.type === 'TRANSFER' ? 'Assignment Transfer' : 'Cap Redistribution'}
|
|
</Badge>
|
|
<span className="text-sm font-medium">
|
|
{event.droppedJuror.name}
|
|
</span>
|
|
</div>
|
|
<span className="text-xs text-muted-foreground">
|
|
{new Date(event.timestamp).toLocaleString()}
|
|
</span>
|
|
</div>
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
By {event.performedBy.name || event.performedBy.email} — {event.movedCount} project(s) reassigned
|
|
{event.failedCount > 0 && `, ${event.failedCount} failed`}
|
|
</p>
|
|
|
|
{event.moves.length > 0 && (
|
|
<div className="mt-2">
|
|
<table className="w-full text-xs">
|
|
<thead>
|
|
<tr className="text-muted-foreground border-b">
|
|
<th className="text-left py-1 font-medium">Project</th>
|
|
<th className="text-left py-1 font-medium">Reassigned To</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{event.moves.map((move, i) => (
|
|
<tr key={i} className="border-b last:border-0">
|
|
<td className="py-1.5 pr-2 max-w-[250px] truncate">
|
|
{move.projectTitle}
|
|
</td>
|
|
<td className="py-1.5 font-medium">
|
|
{move.newJurorName}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)}
|
|
|
|
{event.failedProjects.length > 0 && (
|
|
<div className="mt-1">
|
|
<p className="text-xs font-medium text-destructive">Could not reassign:</p>
|
|
<ul className="text-xs text-muted-foreground list-disc list-inside">
|
|
{event.failedProjects.map((p, i) => (
|
|
<li key={i}>{p}</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)}
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|