Multi-role members, round detail UI overhaul, dashboard jury progress, and submit bug fix
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
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>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { router, protectedProcedure, adminProcedure } from '../trpc'
|
||||
import { router, protectedProcedure, adminProcedure, userHasRole } from '../trpc'
|
||||
import { getUserAvatarUrl } from '../utils/avatar-url'
|
||||
import {
|
||||
generateAIAssignments,
|
||||
@@ -114,7 +114,7 @@ export async function reassignAfterCOI(params: {
|
||||
? await prisma.user.findMany({
|
||||
where: {
|
||||
id: { in: activeRoundJurorIds },
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
select: { id: true, name: true, email: true, maxAssignments: true },
|
||||
@@ -340,7 +340,7 @@ async function reassignDroppedJurorAssignments(params: {
|
||||
? await prisma.user.findMany({
|
||||
where: {
|
||||
id: { in: activeRoundJurorIds },
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
select: { id: true, name: true, email: true, maxAssignments: true },
|
||||
@@ -627,7 +627,7 @@ async function runAIAssignmentJob(jobId: string, roundId: string, userId: string
|
||||
|
||||
const jurors = await prisma.user.findMany({
|
||||
where: {
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
...(scopedJurorIds ? { id: { in: scopedJurorIds } } : {}),
|
||||
},
|
||||
@@ -899,7 +899,7 @@ export const assignmentRouter = router({
|
||||
|
||||
// Verify access
|
||||
if (
|
||||
ctx.user.role === 'JURY_MEMBER' &&
|
||||
userHasRole(ctx.user, 'JURY_MEMBER') &&
|
||||
assignment.userId !== ctx.user.id
|
||||
) {
|
||||
throw new TRPCError({
|
||||
@@ -1322,7 +1322,7 @@ export const assignmentRouter = router({
|
||||
|
||||
const jurors = await ctx.prisma.user.findMany({
|
||||
where: {
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
...(scopedJurorIds ? { id: { in: scopedJurorIds } } : {}),
|
||||
},
|
||||
@@ -2199,7 +2199,7 @@ export const assignmentRouter = router({
|
||||
const ids = roundJurorIds.map((a) => a.userId).filter((id) => id !== input.jurorId)
|
||||
candidateJurors = ids.length > 0
|
||||
? await ctx.prisma.user.findMany({
|
||||
where: { id: { in: ids }, role: 'JURY_MEMBER', status: 'ACTIVE' },
|
||||
where: { id: { in: ids }, roles: { has: 'JURY_MEMBER' }, status: 'ACTIVE' },
|
||||
select: { id: true, name: true, email: true, maxAssignments: true },
|
||||
})
|
||||
: []
|
||||
@@ -2427,7 +2427,7 @@ export const assignmentRouter = router({
|
||||
? await ctx.prisma.user.findMany({
|
||||
where: {
|
||||
id: { in: activeRoundJurorIds },
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
select: { id: true, name: true, email: true, maxAssignments: true },
|
||||
@@ -2890,7 +2890,7 @@ export const assignmentRouter = router({
|
||||
? await ctx.prisma.user.findMany({
|
||||
where: {
|
||||
id: { in: activeRoundJurorIds },
|
||||
role: 'JURY_MEMBER',
|
||||
roles: { has: 'JURY_MEMBER' },
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
select: { id: true, name: true, email: true, maxAssignments: true },
|
||||
|
||||
Reference in New Issue
Block a user