Admin UI audit round 2: fix 28 display bugs across 23 files
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m51s

HIGH fixes (broken features / wrong data):
- H1: Fix roundAssignments → projectRoundStates in project router (7 occurrences)
- H2: Fix deliberation results panel blank table (wrong field names)
- H3: Fix deliberation participant names blank (wrong data path)
- H4: Fix awards "Evaluated" stat duplicating "Eligible" count
- H5: Fix cross-round comparison enabled at 1 round (backend requires 2)
- H6: Fix setState during render anti-pattern (6 occurrences)
- H7: Fix round detail jury member count always showing 0
- H8: Remove 4 invalid status values from observer dashboard filter
- H9: Fix filtering progress bar always showing 100%

MEDIUM fixes (misleading display):
- M1: Filter special-award rounds from competition timeline
- M2: Exclude special-award rounds from distinct project count
- M3: Fix MENTORING pipeline node hardcoded "0 mentored"
- M4: Fix DELIB_LOCKED badge using red for success state
- M5: Add status label maps to deliberation session detail
- M6: Humanize deliberation category + tie-break method displays
- M8: Rename setStageId → setRoundId, "Select Stage" → "Select Round"
- M9: Add missing INVITED/ACTIVE/SUSPENDED to members status labels
- M10: Add ROUND_DRAFT/ACTIVE/CLOSED/ARCHIVED to StatusBadge
- M11: Fix unsent messages showing "Scheduled" instead of "Draft"
- M12: Rename misleading totalEvaluations → totalAssignments
- M13: Rename "Stage" column to "Program" in projects page

LOW fixes (cosmetic / edge-case):
- L1: Use unfiltered rounds array for active round detection
- L2: Use all rounds length for new round sort order
- L3: Filter special-award rounds from header count
- L4: Fix single-underscore replace in award status badges
- L5: Fix score bucket boundary gaps (4.99 dropped between buckets)
- L6: Title-case LIVE_FINAL pipeline metric status
- L7: Fix roundType.replace only replacing first underscore
- L8: Remove duplicate severity sort in smart-actions component

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-19 11:11:00 +01:00
parent ae1685179c
commit 51e18870b6
23 changed files with 170 additions and 111 deletions

View File

@@ -438,7 +438,7 @@ export default function AwardDetailPage({
</h1>
<div className="flex items-center gap-2 mt-1">
<Badge variant={STATUS_COLORS[award.status] || 'secondary'}>
{award.status.replace('_', ' ')}
{award.status.replace(/_/g, ' ')}
</Badge>
<span className="text-muted-foreground">
{award.program.year} Edition
@@ -594,7 +594,7 @@ export default function AwardDetailPage({
<div className="flex items-center justify-between">
<div>
<p className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Evaluated</p>
<p className="text-2xl font-bold tabular-nums">{award._count.eligibilities}</p>
<p className="text-2xl font-bold tabular-nums">{(award as any).totalAssessed ?? award._count.eligibilities}</p>
</div>
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-950/40">
<ListChecks className="h-5 w-5 text-blue-600 dark:text-blue-400" />
@@ -657,7 +657,7 @@ export default function AwardDetailPage({
<TabsContent value="eligibility" className="space-y-4">
<div className="flex flex-col gap-3 sm:flex-row sm:justify-between sm:items-center">
<p className="text-sm text-muted-foreground">
{award.eligibleCount} of {award._count.eligibilities} projects
{award.eligibleCount} of {(award as any).totalAssessed ?? award._count.eligibilities} projects
eligible
</p>
<div className="flex items-center gap-4">

View File

@@ -171,7 +171,7 @@ export default function AwardsListPage() {
{award.name}
</CardTitle>
<Badge variant={STATUS_COLORS[award.status] || 'secondary'}>
{award.status.replace('_', ' ')}
{award.status.replace(/_/g, ' ')}
</Badge>
</div>
{award.description && (

View File

@@ -12,6 +12,30 @@ import { toast } from 'sonner';
import { ResultsPanel } from '@/components/admin/deliberation/results-panel';
import type { Route } from 'next';
const STATUS_LABELS: Record<string, string> = {
DELIB_OPEN: 'Open',
VOTING: 'Voting',
TALLYING: 'Tallying',
RUNOFF: 'Runoff',
DELIB_LOCKED: 'Locked',
};
const STATUS_VARIANTS: Record<string, 'default' | 'secondary' | 'destructive' | 'outline'> = {
DELIB_OPEN: 'outline',
VOTING: 'default',
TALLYING: 'secondary',
RUNOFF: 'secondary',
DELIB_LOCKED: 'secondary',
};
const CATEGORY_LABELS: Record<string, string> = {
STARTUP: 'Startup',
BUSINESS_CONCEPT: 'Business Concept',
};
const TIE_BREAK_LABELS: Record<string, string> = {
TIE_RUNOFF: 'Runoff Vote',
TIE_ADMIN_DECIDES: 'Admin Decides',
SCORE_FALLBACK: 'Score Fallback',
};
export default function DeliberationSessionPage({
params: paramsPromise
}: {
@@ -97,10 +121,10 @@ export default function DeliberationSessionPage({
<div className="flex-1">
<div className="flex items-center gap-3">
<h1 className="text-3xl font-bold">Deliberation Session</h1>
<Badge>{session.status}</Badge>
<Badge variant={STATUS_VARIANTS[session.status] ?? 'outline'}>{STATUS_LABELS[session.status] ?? session.status}</Badge>
</div>
<p className="text-muted-foreground">
{session.round?.name} - {session.category}
{session.round?.name} - {CATEGORY_LABELS[session.category] ?? session.category}
</p>
</div>
</div>
@@ -128,7 +152,7 @@ export default function DeliberationSessionPage({
</div>
<div>
<p className="text-sm font-medium text-muted-foreground">Tie Break Method</p>
<p className="mt-1">{session.tieBreakMethod}</p>
<p className="mt-1">{TIE_BREAK_LABELS[session.tieBreakMethod] ?? session.tieBreakMethod}</p>
</div>
<div>
<p className="text-sm font-medium text-muted-foreground">
@@ -156,8 +180,8 @@ export default function DeliberationSessionPage({
className="flex items-center justify-between rounded-lg border p-3"
>
<div>
<p className="font-medium">{participant.user?.name}</p>
<p className="text-sm text-muted-foreground">{participant.user?.email}</p>
<p className="font-medium">{participant.user?.user?.name ?? 'Unknown'}</p>
<p className="text-sm text-muted-foreground">{participant.user?.user?.email}</p>
</div>
<Badge variant={voterUserIds.has(participant.user?.user?.id) ? 'default' : 'outline'}>
{voterUserIds.has(participant.user?.user?.id) ? 'Voted' : 'Pending'}
@@ -211,7 +235,7 @@ export default function DeliberationSessionPage({
key={participant.id}
className="flex items-center justify-between rounded-lg border p-3"
>
<span>{participant.user?.name}</span>
<span>{participant.user?.user?.name ?? 'Unknown'}</span>
<Badge variant={voterUserIds.has(participant.user?.user?.id) ? 'default' : 'secondary'}>
{voterUserIds.has(participant.user?.user?.id) ? 'Submitted' : 'Not Voted'}
</Badge>

View File

@@ -109,7 +109,7 @@ export default function DeliberationListPage({
VOTING: 'default',
TALLYING: 'secondary',
RUNOFF: 'secondary',
DELIB_LOCKED: 'destructive',
DELIB_LOCKED: 'secondary',
};
const labels: Record<string, string> = {
DELIB_OPEN: 'Open',
@@ -173,7 +173,7 @@ export default function DeliberationListPage({
<div className="flex items-start justify-between">
<div>
<CardTitle>
{session.round?.name} - {session.category}
{session.round?.name} - {session.category === 'BUSINESS_CONCEPT' ? 'Business Concept' : session.category === 'STARTUP' ? 'Startup' : session.category}
</CardTitle>
<CardDescription className="mt-1">
{session.mode === 'SINGLE_WINNER_VOTE' ? 'Single Winner Vote' : 'Full Ranking'}
@@ -186,7 +186,7 @@ export default function DeliberationListPage({
<div className="flex flex-wrap gap-2 text-sm text-muted-foreground">
<span>{session.participants?.length || 0} participants</span>
<span></span>
<span>Tie break: {session.tieBreakMethod}</span>
<span>Tie break: {session.tieBreakMethod === 'TIE_RUNOFF' ? 'Runoff Vote' : session.tieBreakMethod === 'TIE_ADMIN_DECIDES' ? 'Admin Decides' : session.tieBreakMethod === 'SCORE_FALLBACK' ? 'Score Fallback' : session.tieBreakMethod}</span>
</div>
</CardContent>
</Card>

View File

@@ -332,7 +332,7 @@ export default function CompetitionDetailPage() {
<TabsContent value="overview" className="space-y-6">
<CompetitionTimeline
competitionId={competitionId}
rounds={competition.rounds}
rounds={competition.rounds.filter((r: any) => !r.specialAwardId)}
/>
</TabsContent>
@@ -386,7 +386,7 @@ export default function CompetitionDetailPage() {
roundTypeColors[round.roundType] ?? 'bg-gray-100 text-gray-700'
)}
>
{round.roundType.replace('_', ' ')}
{round.roundType.replace(/_/g, ' ')}
</Badge>
<Badge
variant="outline"

View File

@@ -79,7 +79,7 @@ const ROLES = ['JURY_MEMBER', 'MENTOR', 'OBSERVER', 'APPLICANT', 'PROGRAM_ADMIN'
export default function MessagesPage() {
const [recipientType, setRecipientType] = useState<RecipientType>('ALL')
const [selectedRole, setSelectedRole] = useState('')
const [roundId, setStageId] = useState('')
const [roundId, setRoundId] = useState('')
const [selectedProgramId, setSelectedProgramId] = useState('')
const [selectedUserId, setSelectedUserId] = useState('')
const [subject, setSubject] = useState('')
@@ -125,7 +125,7 @@ export default function MessagesPage() {
setBody('')
setSelectedTemplateId('')
setSelectedRole('')
setStageId('')
setRoundId('')
setSelectedProgramId('')
setSelectedUserId('')
setIsScheduled(false)
@@ -219,7 +219,7 @@ export default function MessagesPage() {
return
}
if (recipientType === 'ROUND_JURY' && !roundId) {
toast.error('Please select a stage')
toast.error('Please select a round')
return
}
if (recipientType === 'PROGRAM_TEAM' && !selectedProgramId) {
@@ -296,7 +296,7 @@ export default function MessagesPage() {
onValueChange={(v) => {
setRecipientType(v as RecipientType)
setSelectedRole('')
setStageId('')
setRoundId('')
setSelectedProgramId('')
setSelectedUserId('')
}}
@@ -335,10 +335,10 @@ export default function MessagesPage() {
{recipientType === 'ROUND_JURY' && (
<div className="space-y-2">
<Label>Select Stage</Label>
<Select value={roundId} onValueChange={setStageId}>
<Label>Select Round</Label>
<Select value={roundId} onValueChange={setRoundId}>
<SelectTrigger>
<SelectValue placeholder="Choose a stage..." />
<SelectValue placeholder="Choose a round..." />
</SelectTrigger>
<SelectContent>
{rounds?.map((round) => (
@@ -616,11 +616,15 @@ export default function MessagesPage() {
<CheckCircle2 className="mr-1 h-3 w-3" />
Sent
</Badge>
) : (
) : msg.scheduledAt ? (
<Badge variant="default" className="text-xs">
<Clock className="mr-1 h-3 w-3" />
Scheduled
</Badge>
) : (
<Badge variant="outline" className="text-xs">
Draft
</Badge>
)}
</TableCell>
<TableCell className="text-right text-sm text-muted-foreground">

View File

@@ -864,7 +864,7 @@ export default function ProjectsPage() {
</TableHead>
<TableHead className="min-w-[280px]">Project</TableHead>
<TableHead>Category</TableHead>
<TableHead>Stage</TableHead>
<TableHead>Program</TableHead>
<TableHead>Tags</TableHead>
<TableHead>Assignments</TableHead>
<TableHead>Status</TableHead>
@@ -1065,7 +1065,7 @@ export default function ProjectsPage() {
</CardHeader>
<CardContent className="space-y-3">
<div className="flex items-center justify-between text-sm">
<span className="text-muted-foreground">Stage</span>
<span className="text-muted-foreground">Program</span>
<span>{project.program?.name ?? 'Unassigned'}</span>
</div>
{project.competitionCategory && (

View File

@@ -1,6 +1,6 @@
'use client'
import { useState } from 'react'
import { useState, useEffect } from 'react'
import Link from 'next/link'
import { trpc } from '@/lib/trpc/client'
import {
@@ -71,9 +71,11 @@ function ReportsOverview() {
// Project reporting scope (default: latest program, all rounds)
const [selectedValue, setSelectedValue] = useState<string | null>(null)
if (programs?.length && !selectedValue) {
setSelectedValue(`all:${programs[0].id}`)
}
useEffect(() => {
if (programs?.length && !selectedValue) {
setSelectedValue(`all:${programs[0].id}`)
}
}, [programs, selectedValue])
const scopeInput = parseSelection(selectedValue)
const hasScope = !!scopeInput.roundId || !!scopeInput.programId
@@ -109,7 +111,7 @@ function ReportsOverview() {
const activeRounds = dashStats?.activeRoundCount ?? rounds.filter((r: { status: string }) => r.status === 'ROUND_ACTIVE').length
const jurorCount = dashStats?.jurorCount ?? 0
const submittedEvaluations = dashStats?.submittedEvaluations ?? 0
const totalEvaluations = dashStats?.totalEvaluations ?? 0
const totalAssignments = dashStats?.totalAssignments ?? 0
const completionRate = dashStats?.completionRate ?? 0
return (
@@ -177,7 +179,7 @@ function ReportsOverview() {
<p className="text-sm font-medium text-muted-foreground">Evaluations</p>
<p className="text-2xl font-bold mt-1">{submittedEvaluations}</p>
<p className="text-xs text-muted-foreground mt-1">
{totalEvaluations > 0
{totalAssignments > 0
? `${completionRate}% completion rate`
: 'No assignments yet'}
</p>
@@ -417,9 +419,11 @@ function StageAnalytics() {
) || []
// Set default selected stage
if (rounds.length && !selectedValue) {
setSelectedValue(rounds[0].id)
}
useEffect(() => {
if (rounds.length && !selectedValue) {
setSelectedValue(rounds[0].id)
}
}, [rounds.length, selectedValue])
const queryInput = parseSelection(selectedValue)
const hasSelection = !!queryInput.roundId || !!queryInput.programId
@@ -701,9 +705,11 @@ function JurorConsistencyTab() {
((p.stages ?? []) as Array<{ id: string; name: string }>).map((s: { id: string; name: string }) => ({ id: s.id, name: s.name, programId: p.id, programName: `${p.year} Edition` }))
) || []
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
useEffect(() => {
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
}, [stages.length, selectedValue])
const queryInput = parseSelection(selectedValue)
const hasSelection = !!queryInput.roundId || !!queryInput.programId
@@ -773,9 +779,11 @@ function DiversityTab() {
((p.stages ?? []) as Array<{ id: string; name: string }>).map((s: { id: string; name: string }) => ({ id: s.id, name: s.name, programId: p.id, programName: `${p.year} Edition` }))
) || []
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
useEffect(() => {
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
}, [stages.length, selectedValue])
const queryInput = parseSelection(selectedValue)
const hasSelection = !!queryInput.roundId || !!queryInput.programId
@@ -846,7 +854,7 @@ function RoundPipelineTab() {
const { data: comparison, isLoading: comparisonLoading } =
trpc.analytics.getCrossRoundComparison.useQuery(
{ roundIds },
{ enabled: roundIds.length >= 1 }
{ enabled: roundIds.length >= 2 }
)
if (isLoading || comparisonLoading) {
@@ -929,9 +937,11 @@ export default function ReportsPage() {
((p.stages ?? []) as Array<{ id: string; name: string }>).map((s: { id: string; name: string }) => ({ id: s.id, name: s.name, programName: `${p.year} Edition` }))
) || []
if (pdfStages.length && !pdfStageId) {
setPdfStageId(pdfStages[0].id)
}
useEffect(() => {
if (pdfStages.length && !pdfStageId) {
setPdfStageId(pdfStages[0].id)
}
}, [pdfStages.length, pdfStageId])
const selectedPdfStage = pdfStages.find((r) => r.id === pdfStageId)

View File

@@ -450,7 +450,7 @@ export default function RoundDetailPage() {
[projectStates])
const passedCount = stateCounts['PASSED'] ?? 0
const juryGroup = round?.juryGroup
const juryMemberCount = juryGroup?.members?.length ?? 0
const juryMemberCount = juryGroupDetail?.members?.length ?? 0
const isFiltering = round?.roundType === 'FILTERING'
const isEvaluation = round?.roundType === 'EVALUATION'

View File

@@ -95,6 +95,7 @@ type RoundWithStats = {
sortOrder: number
windowOpenAt: string | null
windowCloseAt: string | null
specialAwardId: string | null
juryGroup: { id: string; name: string } | null
_count: { projectRoundStates: number; assignments: number }
}
@@ -193,7 +194,7 @@ export default function RoundsPage() {
return
}
const slug = roundForm.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
const nextOrder = rounds.length
const nextOrder = (compDetail?.rounds ?? []).length
createRoundMutation.mutate({
competitionId: comp.id,
name: roundForm.name.trim(),
@@ -286,7 +287,7 @@ export default function RoundsPage() {
const totalProjects = (compDetail as any)?.distinctProjectCount ?? 0
const allRounds = (compDetail?.rounds ?? []) as RoundWithStats[]
const totalAssignments = allRounds.reduce((s, r) => s + r._count.assignments, 0)
const activeRound = rounds.find((r) => r.status === 'ROUND_ACTIVE')
const activeRound = allRounds.find((r) => r.status === 'ROUND_ACTIVE')
return (
<TooltipProvider delayDuration={200}>
@@ -327,7 +328,7 @@ export default function RoundsPage() {
</Tooltip>
</div>
<div className="flex items-center gap-4 mt-1 text-sm text-muted-foreground">
<span>{allRounds.length} rounds</span>
<span>{allRounds.filter((r) => !r.specialAwardId).length} rounds</span>
<span className="text-muted-foreground/30">|</span>
<span>{totalProjects} projects</span>
<span className="text-muted-foreground/30">|</span>

View File

@@ -1,6 +1,6 @@
'use client'
import { useState } from 'react'
import { useState, useEffect } from 'react'
import { trpc } from '@/lib/trpc/client'
import {
Card,
@@ -591,9 +591,11 @@ export default function ObserverReportsPage() {
) || []
// Set default selected stage
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
useEffect(() => {
if (stages.length && !selectedValue) {
setSelectedValue(stages[0].id)
}
}, [stages.length, selectedValue])
const hasSelection = !!selectedValue
const selectedRound = stages.find((s) => s.id === selectedValue)

View File

@@ -24,7 +24,10 @@ export function ResultsPanel({ sessionId }: ResultsPanelProps) {
);
const { data: aggregatedResults } = trpc.deliberation.aggregate.useQuery(
{ sessionId },
{ refetchInterval: 10_000 }
{
refetchInterval: 10_000,
enabled: session?.status === 'TALLYING' || session?.status === 'RUNOFF' || session?.status === 'DELIB_LOCKED',
}
);
const initRunoffMutation = trpc.deliberation.initRunoff.useMutation({
@@ -52,34 +55,32 @@ export function ResultsPanel({ sessionId }: ResultsPanelProps) {
return (
<Card>
<CardContent className="p-12 text-center">
<p className="text-muted-foreground">No voting results yet</p>
<p className="text-muted-foreground">
{session?.status === 'DELIB_OPEN' || session?.status === 'VOTING'
? 'Voting has not been tallied yet'
: 'No voting results yet'}
</p>
</CardContent>
</Card>
);
}
// Detect ties: check if two or more top-ranked candidates share the same totalScore
const hasTie = (() => {
const rankings = aggregatedResults.rankings as Array<{ totalScore?: number; projectId: string }> | undefined;
// Detect ties using the backend-computed flag, with client-side fallback
const hasTie = aggregatedResults.hasTies ?? (() => {
const rankings = aggregatedResults.rankings as Array<{ score?: number; projectId: string }> | undefined;
if (!rankings || rankings.length < 2) return false;
// Group projects by totalScore
const scoreGroups = new Map<number, string[]>();
for (const r of rankings) {
const score = r.totalScore ?? 0;
const score = r.score ?? 0;
const group = scoreGroups.get(score) || [];
group.push(r.projectId);
scoreGroups.set(score, group);
}
// A tie exists if the highest score is shared by 2+ projects
const topScore = Math.max(...scoreGroups.keys());
const topGroup = scoreGroups.get(topScore);
return (topGroup?.length ?? 0) >= 2;
})();
const tiedProjectIds = hasTie
? (aggregatedResults.rankings as Array<{ totalScore?: number; projectId: string }>)
.filter((r) => r.totalScore === (aggregatedResults.rankings as Array<{ totalScore?: number }>)[0]?.totalScore)
.map((r) => r.projectId)
: [];
const tiedProjectIds = aggregatedResults.tiedProjectIds ?? [];
const canFinalize = session?.status === 'TALLYING' && !hasTie;
return (
@@ -101,17 +102,17 @@ export function ResultsPanel({ sessionId }: ResultsPanelProps) {
>
<div className="flex items-center gap-4">
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 font-bold">
#{index + 1}
#{result.rank ?? index + 1}
</div>
<div>
<p className="font-medium">{result.projectTitle}</p>
<p className="font-medium">{result.projectTitle ?? result.projectId}</p>
<p className="text-sm text-muted-foreground">
{result.votes} votes {result.averageRank?.toFixed(2)} avg rank
{result.voteCount} votes
</p>
</div>
</div>
<Badge variant="outline" className="text-lg">
{result.totalScore?.toFixed(1) || 0}
{result.score?.toFixed?.(1) ?? 0}
</Badge>
</div>
))}

View File

@@ -53,6 +53,9 @@ const statusColors: Record<string, 'default' | 'success' | 'secondary' | 'destru
const statusLabels: Record<string, string> = {
NONE: 'Not Invited',
INVITED: 'Invited',
ACTIVE: 'Active',
SUSPENDED: 'Suspended',
}
const roleColors: Record<string, 'default' | 'outline' | 'secondary'> = {

View File

@@ -169,7 +169,7 @@ function RoundTypeContent({ round }: { round: PipelineRound }) {
case 'FILTERING': {
const processed = round.filteringPassed + round.filteringRejected + round.filteringFlagged
const total = round.filteringTotal
const total = round.projectStates.total || round.filteringTotal
const pct = total > 0 ? Math.round((processed / total) * 100) : 0
return (

View File

@@ -133,9 +133,11 @@ function getMetric(round: PipelineRound): string {
case 'SUBMISSION':
return `${projectStates.COMPLETED} submitted`
case 'MENTORING':
return '0 mentored'
case 'LIVE_FINAL':
return liveSessionStatus || `${projectStates.total} finalists`
return `${projectStates.COMPLETED ?? 0} mentored`
case 'LIVE_FINAL': {
const status = liveSessionStatus
return status ? status.charAt(0) + status.slice(1).toLowerCase() : `${projectStates.total} finalists`
}
case 'DELIBERATION':
return deliberationCount > 0
? `${deliberationCount} sessions`

View File

@@ -29,12 +29,6 @@ type SmartActionsProps = {
actions: DashboardAction[]
}
const severityOrder: Record<DashboardAction['severity'], number> = {
critical: 0,
warning: 1,
info: 2,
}
const severityConfig = {
critical: {
icon: AlertTriangle,
@@ -57,10 +51,6 @@ const severityConfig = {
}
export function SmartActions({ actions }: SmartActionsProps) {
const sorted = [...actions].sort(
(a, b) => severityOrder[a.severity] - severityOrder[b.severity]
)
return (
<Card>
<CardHeader className="flex flex-row items-center gap-3 space-y-0 pb-4">
@@ -73,7 +63,7 @@ export function SmartActions({ actions }: SmartActionsProps) {
)}
</CardHeader>
<CardContent>
{sorted.length === 0 ? (
{actions.length === 0 ? (
<div className="flex flex-col items-center justify-center py-8 text-center">
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-emerald-100 dark:bg-emerald-900/40">
<CheckCircle2 className="h-6 w-6 text-emerald-600 dark:text-emerald-400" />
@@ -84,7 +74,7 @@ export function SmartActions({ actions }: SmartActionsProps) {
</div>
) : (
<div className="space-y-2">
{sorted.map((action) => {
{actions.map((action) => {
const config = severityConfig[action.severity]
const Icon = config.icon

View File

@@ -290,13 +290,9 @@ export function ObserverDashboardContent({ userName }: { userName?: string }) {
<SelectItem value="SUBMITTED">Submitted</SelectItem>
<SelectItem value="ELIGIBLE">Eligible</SelectItem>
<SelectItem value="ASSIGNED">Assigned</SelectItem>
<SelectItem value="UNDER_REVIEW">Under Review</SelectItem>
<SelectItem value="SHORTLISTED">Shortlisted</SelectItem>
<SelectItem value="SEMIFINALIST">Semi-finalist</SelectItem>
<SelectItem value="FINALIST">Finalist</SelectItem>
<SelectItem value="WINNER">Winner</SelectItem>
<SelectItem value="REJECTED">Rejected</SelectItem>
<SelectItem value="WITHDRAWN">Withdrawn</SelectItem>
</SelectContent>
</Select>
<Select value={String(perPage)} onValueChange={(v) => { setPerPage(Number(v)); setPage(1) }}>

View File

@@ -7,6 +7,10 @@ const STATUS_STYLES: Record<string, { variant: BadgeProps['variant']; className?
ACTIVE: { variant: 'default', className: 'bg-blue-500/10 text-blue-700 border-blue-200 dark:text-blue-400' },
EVALUATION: { variant: 'default', className: 'bg-violet-500/10 text-violet-700 border-violet-200 dark:text-violet-400' },
CLOSED: { variant: 'secondary', className: 'bg-slate-500/10 text-slate-600 border-slate-200' },
ROUND_DRAFT: { variant: 'secondary' },
ROUND_ACTIVE: { variant: 'default', className: 'bg-blue-500/10 text-blue-700 border-blue-200 dark:text-blue-400' },
ROUND_CLOSED: { variant: 'secondary', className: 'bg-slate-500/10 text-slate-600 border-slate-200' },
ROUND_ARCHIVED: { variant: 'secondary', className: 'bg-slate-400/10 text-slate-400 border-slate-200' },
// Project statuses
SUBMITTED: { variant: 'secondary', className: 'bg-indigo-500/10 text-indigo-700 border-indigo-200 dark:text-indigo-400' },

View File

@@ -754,14 +754,14 @@ export const analyticsRouter = router({
const scores = evaluationScores.map((e) => e.globalScore!).filter((s) => s != null)
const scoreDistribution = [
{ label: '9-10', min: 9, max: 10 },
{ label: '7-8', min: 7, max: 8.99 },
{ label: '5-6', min: 5, max: 6.99 },
{ label: '3-4', min: 3, max: 4.99 },
{ label: '1-2', min: 1, max: 2.99 },
{ label: '9-10', min: 9, max: Infinity },
{ label: '7-8', min: 7, max: 9 },
{ label: '5-6', min: 5, max: 7 },
{ label: '3-4', min: 3, max: 5 },
{ label: '1-2', min: 1, max: 3 },
].map((b) => ({
label: b.label,
count: scores.filter((s) => s >= b.min && s <= b.max).length,
count: scores.filter((s) => s >= b.min && s < b.max).length,
}))
return {
@@ -770,7 +770,7 @@ export const analyticsRouter = router({
projectCount,
jurorCount,
submittedEvaluations,
totalEvaluations: totalAssignments,
totalAssignments,
completionRate,
scoreDistribution,
}

View File

@@ -123,7 +123,7 @@ export const competitionRouter = router({
}
// Count distinct projects across all rounds (not sum of per-round states)
const roundIds = competition.rounds.map((r) => r.id)
const roundIds = competition.rounds.filter((r) => !r.specialAwardId).map((r) => r.id)
const distinctProjectCount = roundIds.length > 0
? await ctx.prisma.projectRoundState.findMany({
where: { roundId: { in: roundIds } },

View File

@@ -146,7 +146,24 @@ export const deliberationRouter = router({
aggregate: adminProcedure
.input(z.object({ sessionId: z.string() }))
.query(async ({ ctx, input }) => {
return aggregateVotes(input.sessionId, ctx.prisma)
const result = await aggregateVotes(input.sessionId, ctx.prisma)
// Enrich rankings with project titles
const projectIds = result.rankings.map((r) => r.projectId)
const projects = projectIds.length > 0
? await ctx.prisma.project.findMany({
where: { id: { in: projectIds } },
select: { id: true, title: true, teamName: true },
})
: []
const projectMap = new Map(projects.map((p) => [p.id, p]))
return {
...result,
rankings: result.rankings.map((r) => ({
...r,
projectTitle: projectMap.get(r.projectId)?.title ?? 'Unknown Project',
teamName: projectMap.get(r.projectId)?.teamName ?? '',
})),
}
}),
/**

View File

@@ -89,19 +89,19 @@ export const projectRouter = router({
// Filter by program
if (programId) where.programId = programId
// Filter by round (via RoundAssignment join)
// Filter by round (via ProjectRoundState)
if (roundId) {
where.roundAssignments = { some: { roundId } }
where.projectRoundStates = { some: { roundId } }
}
// Exclude projects already in a specific round
if (excludeInRoundId) {
where.roundAssignments = { none: { roundId: excludeInRoundId } }
where.projectRoundStates = { none: { roundId: excludeInRoundId } }
}
// Filter by unassigned (not in any round)
if (unassignedOnly) {
where.roundAssignments = { none: {} }
where.projectRoundStates = { none: {} }
}
// Status filter
@@ -223,13 +223,13 @@ export const projectRouter = router({
if (programId) where.programId = programId
if (roundId) {
where.roundAssignments = { some: { roundId } }
where.projectRoundStates = { some: { roundId } }
}
if (excludeInRoundId) {
where.roundAssignments = { none: { roundId: excludeInRoundId } }
where.projectRoundStates = { none: { roundId: excludeInRoundId } }
}
if (unassignedOnly) {
where.roundAssignments = { none: {} }
where.projectRoundStates = { none: {} }
}
if (statuses?.length) where.status = { in: statuses }
if (tags && tags.length > 0) where.tags = { hasSome: tags }
@@ -1102,7 +1102,7 @@ export const projectRouter = router({
const where: Record<string, unknown> = {
programId,
roundAssignments: { none: {} }, // Projects not assigned to any round
projectRoundStates: { none: {} }, // Projects not assigned to any round
}
if (search) {

View File

@@ -102,12 +102,17 @@ export const specialAwardRouter = router({
}
}
// Count eligible projects
const eligibleCount = await ctx.prisma.awardEligibility.count({
where: { awardId: input.id, eligible: true },
})
// Count eligible projects and total assessed
const [eligibleCount, totalAssessed] = await Promise.all([
ctx.prisma.awardEligibility.count({
where: { awardId: input.id, eligible: true },
}),
ctx.prisma.awardEligibility.count({
where: { awardId: input.id },
}),
])
return { ...award, competition, eligibleCount }
return { ...award, competition, eligibleCount, totalAssessed }
}),
// ─── Admin Mutations ────────────────────────────────────────────────────