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
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:
@@ -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">
|
||||
|
||||
@@ -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 && (
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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 && (
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user