Observer: fix round history, match admin project info, add AI rejection reason
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m30s

- Round history infers rejection round when ProjectRoundState lacks explicit
  REJECTED state; shows red XCircle + badge, dims unreached rounds
- Project info section now matches admin: description, location, founded,
  submission links, expertise tags, internal notes, created/updated dates
- Fetch FilteringResult for rejected projects; display AI reasoning + confidence
- Remove cross-round comparison from reports, replace with scoring/criteria insights
- Remove unused AI synthesis placeholder

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 23:30:14 +01:00
parent 9f7b76b3cb
commit d717040f03
3 changed files with 443 additions and 159 deletions

View File

@@ -11,7 +11,6 @@ import {
CardTitle,
} from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Toggle } from '@/components/ui/toggle'
import { Progress } from '@/components/ui/progress'
import { Skeleton } from '@/components/ui/skeleton'
import {
@@ -36,7 +35,6 @@ import {
BarChart3,
Users,
TrendingUp,
GitCompare,
Download,
Clock,
} from 'lucide-react'
@@ -46,7 +44,6 @@ import {
EvaluationTimelineChart,
StatusBreakdownChart,
CriteriaScoresChart,
CrossStageComparisonChart,
} from '@/components/charts'
import { CsvExportDialog } from '@/components/shared/csv-export-dialog'
import { ExportPdfButton } from '@/components/shared/export-pdf-button'
@@ -621,29 +618,8 @@ function ScoresTab({ selectedValue }: { selectedValue: string }) {
const { data: criteriaScores, isLoading: criteriaLoading } =
trpc.analytics.getCriteriaScores.useQuery(queryInput, { enabled: hasSelection })
const { data: programs, isLoading: programsLoading } = trpc.program.list.useQuery({ includeStages: true })
const crossStageRounds = programs?.flatMap(p =>
((p.stages || []) as Array<{ id: string; name: string }>).map(s => ({
id: s.id,
name: s.name,
programName: `${p.year} Edition`,
}))
) ?? []
const [selectedRoundIds, setSelectedRoundIds] = useState<string[]>([])
const { data: comparison, isLoading: comparisonLoading } =
trpc.analytics.getCrossRoundComparison.useQuery(
{ roundIds: selectedRoundIds },
{ enabled: selectedRoundIds.length >= 2 }
)
const toggleRound = (roundId: string) => {
setSelectedRoundIds((prev) =>
prev.includes(roundId) ? prev.filter((id) => id !== roundId) : [...prev, roundId]
)
}
const { data: overviewStats } =
trpc.analytics.getOverviewStats.useQuery(queryInput, { enabled: hasSelection })
const [csvOpen, setCsvOpen] = useState(false)
const [csvData, setCsvData] = useState<{ data: Record<string, unknown>[]; columns: string[] } | undefined>()
@@ -665,12 +641,63 @@ function ScoresTab({ selectedValue }: { selectedValue: string }) {
return result
}, [criteriaScores])
// Derived scoring insights
const scoringInsights = (() => {
if (!scoreDistribution?.distribution?.length) return null
const dist = scoreDistribution.distribution
const totalScores = dist.reduce((sum, d) => sum + d.count, 0)
if (totalScores === 0) return null
// Find score with highest count
const peakBucket = dist.reduce((a, b) => (b.count > a.count ? b : a), dist[0])
// Find highest and lowest scores that have counts
const scoredBuckets = dist.filter(d => d.count > 0)
const highScore = scoredBuckets.length > 0 ? Math.max(...scoredBuckets.map(d => d.score)) : 0
const lowScore = scoredBuckets.length > 0 ? Math.min(...scoredBuckets.map(d => d.score)) : 0
// Median: walk through distribution to find the middle
let cumulative = 0
let median = 0
for (const d of dist) {
cumulative += d.count
if (cumulative >= totalScores / 2) {
median = d.score
break
}
}
// Scores ≥ 7 count
const highScoreCount = dist.filter(d => d.score >= 7).reduce((sum, d) => sum + d.count, 0)
const highScorePct = Math.round((highScoreCount / totalScores) * 100)
return { peakScore: peakBucket.score, highScore, lowScore, median, totalScores, highScorePct }
})()
// Criteria insights
const criteriaInsights = (() => {
if (!criteriaScores?.length) return null
const sorted = [...criteriaScores].sort((a, b) => b.averageScore - a.averageScore)
return {
strongest: sorted[0],
weakest: sorted[sorted.length - 1],
spread: sorted[0].averageScore - sorted[sorted.length - 1].averageScore,
}
})()
// Status insights
const statusInsights = (() => {
if (!statusBreakdown?.length) return null
const total = statusBreakdown.reduce((sum, s) => sum + s.count, 0)
const reviewed = statusBreakdown
.filter(s => !['SUBMITTED', 'ELIGIBLE', 'DRAFT'].includes(s.status))
.reduce((sum, s) => sum + s.count, 0)
return { total, reviewed, reviewedPct: total > 0 ? Math.round((reviewed / total) * 100) : 0 }
})()
return (
<div className="space-y-6">
<div className="flex items-center justify-between flex-wrap gap-3">
<div>
<h2 className="text-base font-semibold">Scores & Analytics</h2>
<p className="text-sm text-muted-foreground">Score distributions, criteria breakdown and cross-round comparison</p>
<p className="text-sm text-muted-foreground">Score distributions, criteria breakdown and insights</p>
</div>
<Button
variant="outline"
@@ -692,6 +719,48 @@ function ScoresTab({ selectedValue }: { selectedValue: string }) {
onRequestData={handleRequestCsvData}
/>
{/* Scoring Insight Tiles */}
{hasSelection && scoringInsights && (
<div className="grid gap-4 grid-cols-2 lg:grid-cols-4">
<AnimatedCard index={0}>
<Card className="transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Median Score</p>
<p className="text-2xl font-bold mt-1 tabular-nums">{scoringInsights.median}</p>
<p className="text-xs text-muted-foreground mt-0.5">of 10</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={1}>
<Card className="transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Score Range</p>
<p className="text-2xl font-bold mt-1 tabular-nums">{scoringInsights.lowScore}{scoringInsights.highScore}</p>
<p className="text-xs text-muted-foreground mt-0.5">lowest to highest</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={2}>
<Card className="transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Most Common</p>
<p className="text-2xl font-bold mt-1 tabular-nums">{scoringInsights.peakScore}</p>
<p className="text-xs text-muted-foreground mt-0.5">peak score</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={3}>
<Card className="transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">High Scores (7+)</p>
<p className="text-2xl font-bold mt-1 tabular-nums">{scoringInsights.highScorePct}%</p>
<p className="text-xs text-muted-foreground mt-0.5">of {scoringInsights.totalScores} scores</p>
</CardContent>
</Card>
</AnimatedCard>
</div>
)}
{/* Score Distribution & Status Breakdown */}
<div className="grid gap-6 lg:grid-cols-2">
{scoreLoading ? (
@@ -736,54 +805,84 @@ function ScoresTab({ selectedValue }: { selectedValue: string }) {
</Card>
) : null}
{/* Cross-Round Comparison */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<GitCompare className="h-4 w-4" />
Cross-Round Comparison
</CardTitle>
<CardDescription>Select at least 2 rounds to compare metrics</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
{programsLoading ? (
<Skeleton className="h-10" />
) : (
<div className="flex flex-wrap gap-2" role="group" aria-label="Select rounds to compare">
{crossStageRounds.map((stage) => (
<Toggle
key={stage.id}
variant="outline"
size="sm"
pressed={selectedRoundIds.includes(stage.id)}
onPressedChange={() => toggleRound(stage.id)}
aria-label={stage.name}
>
{stage.name}
</Toggle>
))}
</div>
{/* Criteria & Coverage Insights */}
{hasSelection && (criteriaInsights || statusInsights || overviewStats) && (
<div className="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
{criteriaInsights && (
<>
<AnimatedCard index={4}>
<Card className="border-l-4 border-l-emerald-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Strongest Criterion</p>
<p className="font-semibold mt-1 leading-tight">{criteriaInsights.strongest.name}</p>
<p className="text-lg font-bold tabular-nums text-emerald-600 mt-1">
{criteriaInsights.strongest.averageScore.toFixed(2)}
</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={5}>
<Card className="border-l-4 border-l-amber-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Weakest Criterion</p>
<p className="font-semibold mt-1 leading-tight">{criteriaInsights.weakest.name}</p>
<p className="text-lg font-bold tabular-nums text-amber-600 mt-1">
{criteriaInsights.weakest.averageScore.toFixed(2)}
</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={6}>
<Card className="border-l-4 border-l-blue-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Criteria Spread</p>
<p className="text-2xl font-bold tabular-nums mt-1">{criteriaInsights.spread.toFixed(2)}</p>
<p className="text-xs text-muted-foreground mt-0.5">points between strongest and weakest</p>
</CardContent>
</Card>
</AnimatedCard>
</>
)}
{selectedRoundIds.length < 2 && (
<p className="text-sm text-muted-foreground">
Select at least 2 rounds to enable comparison
</p>
{overviewStats && (
<>
<AnimatedCard index={7}>
<Card className="border-l-4 border-l-violet-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Total Evaluations</p>
<p className="text-2xl font-bold tabular-nums mt-1">{overviewStats.evaluationCount}</p>
<p className="text-xs text-muted-foreground mt-0.5">
{overviewStats.projectCount > 0
? `~${(overviewStats.evaluationCount / overviewStats.projectCount).toFixed(1)} per project`
: 'submitted'}
</p>
</CardContent>
</Card>
</AnimatedCard>
<AnimatedCard index={8}>
<Card className="border-l-4 border-l-teal-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Completion Rate</p>
<p className="text-2xl font-bold tabular-nums mt-1">{overviewStats.completionRate}%</p>
<Progress value={overviewStats.completionRate} className="mt-2 h-1.5" />
</CardContent>
</Card>
</AnimatedCard>
</>
)}
</CardContent>
</Card>
{comparisonLoading && selectedRoundIds.length >= 2 && <Skeleton className="h-[350px]" />}
{comparison && (
<CrossStageComparisonChart data={comparison as Array<{
roundId: string
roundName: string
projectCount: number
evaluationCount: number
completionRate: number
averageScore: number | null
scoreDistribution: { score: number; count: number }[]
}>} />
{statusInsights && (
<AnimatedCard index={9}>
<Card className="border-l-4 border-l-cyan-500">
<CardContent className="p-4">
<p className="text-xs font-medium text-muted-foreground">Review Progress</p>
<p className="text-2xl font-bold tabular-nums mt-1">{statusInsights.reviewed}/{statusInsights.total}</p>
<p className="text-xs text-muted-foreground mt-0.5">
{statusInsights.reviewedPct}% of projects reviewed
</p>
</CardContent>
</Card>
</AnimatedCard>
)}
</div>
)}
</div>
)

View File

@@ -28,6 +28,7 @@ import {
Calendar,
CheckCircle2,
Circle,
XCircle,
BarChart3,
ThumbsUp,
ThumbsDown,
@@ -36,7 +37,6 @@ import {
GraduationCap,
Heart,
Clock,
Sparkles,
MessageSquare,
} from 'lucide-react'
import { cn, formatDate, formatDateOnly } from '@/lib/utils'
@@ -85,7 +85,7 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
)
}
const { project, assignments, stats, competitionRounds, projectRoundStates, allRequirements } =
const { project, assignments, stats, competitionRounds, projectRoundStates, allRequirements, filteringResult } =
data
const roundStateMap = new Map(
@@ -301,19 +301,50 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
</AnimatedCard>
)}
{/* AI Synthesis placeholder */}
<AnimatedCard index={1}>
<Card className="border-dashed">
<CardContent className="flex flex-col items-center justify-center py-10 text-center">
<Sparkles className="h-8 w-8 text-muted-foreground/40" />
<p className="mt-3 text-sm font-medium text-muted-foreground">
AI synthesis will appear here when available
</p>
</CardContent>
</Card>
</AnimatedCard>
{/* AI Rejection Reason */}
{project.status === 'REJECTED' && filteringResult?.aiScreeningJson && (() => {
const screening = filteringResult.aiScreeningJson as Record<string, Record<string, unknown>>
// Extract reasoning from the first rule's result
const firstRule = Object.values(screening)[0]
const reasoning = firstRule?.reasoning as string | undefined
const confidence = firstRule?.confidence as number | undefined
if (!reasoning) return null
return (
<AnimatedCard index={1}>
<Card className="border-red-200 bg-red-50/50">
<CardHeader className="pb-2">
<CardTitle className="flex items-center gap-2.5 text-lg text-red-700">
<div className="rounded-lg bg-red-100 p-1.5">
<AlertCircle className="h-4 w-4 text-red-600" />
</div>
AI Screening Rejected
{filteringResult.round && (
<span className="text-sm font-normal text-red-500 ml-auto">
at {filteringResult.round.name}
</span>
)}
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-red-800 whitespace-pre-wrap">{reasoning}</p>
{confidence != null && (
<p className="mt-2 text-xs text-red-500">
AI Confidence: {Math.round(confidence * 100)}%
</p>
)}
{filteringResult.overrideReason && (
<div className="mt-3 border-t border-red-200 pt-3">
<p className="text-xs font-medium text-red-600">Override Reason</p>
<p className="text-sm text-red-800">{filteringResult.overrideReason}</p>
</div>
)}
</CardContent>
</Card>
</AnimatedCard>
)
})()}
{/* Project Info */}
{/* Project Info — matches admin layout */}
<AnimatedCard index={2}>
<Card>
<CardHeader>
@@ -324,76 +355,101 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
Project Information
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-2">
<div>
<p className="text-xs text-muted-foreground">Submitted</p>
<p className="text-sm font-medium">
{formatDateOnly(project.createdAt)}
</p>
</div>
<div>
<p className="text-xs text-muted-foreground">Category</p>
<p className="text-sm font-medium">
{project.competitionCategory
? project.competitionCategory === 'STARTUP'
? 'Start-up'
: 'Business Concept'
: '-'}
</p>
</div>
<div>
<p className="text-xs text-muted-foreground">Country</p>
<p className="text-sm font-medium">
{project.country || project.geographicZone || '-'}
</p>
</div>
<div>
<p className="text-xs text-muted-foreground">AI Score</p>
<p className="text-sm font-medium">-</p>
</div>
<div>
<p className="text-xs text-muted-foreground">
Last Updated
</p>
<p className="text-sm font-medium">
{formatDateOnly(project.updatedAt)}
</p>
</div>
</div>
{project.wantsMentorship && (
<div className="mt-4">
<Badge
variant="outline"
className="gap-1 border-pink-200 bg-pink-50 text-pink-600"
>
<CardContent className="space-y-4">
{/* Category & Ocean Issue badges */}
<div className="flex flex-wrap gap-2">
{project.competitionCategory && (
<Badge variant="outline" className="gap-1">
<GraduationCap className="h-3 w-3" />
{project.competitionCategory === 'STARTUP' ? 'Start-up' : 'Business Concept'}
</Badge>
)}
{project.oceanIssue && (
<Badge variant="outline" className="gap-1">
<Waves className="h-3 w-3" />
{project.oceanIssue.replace(/_/g, ' ')}
</Badge>
)}
{project.wantsMentorship && (
<Badge variant="outline" className="gap-1 text-pink-600 border-pink-200 bg-pink-50">
<Heart className="h-3 w-3" />
Wants Mentorship
</Badge>
)}
</div>
{project.description && (
<div>
<p className="text-sm font-medium text-muted-foreground mb-1">Description</p>
<p className="text-sm whitespace-pre-wrap">{project.description}</p>
</div>
)}
{/* Expertise Tags */}
{/* Location, Institution, Founded */}
<div className="grid gap-4 sm:grid-cols-2">
{(project.country || project.geographicZone) && (
<div className="flex items-start gap-2">
<MapPin className="h-4 w-4 text-muted-foreground mt-0.5" />
<div>
<p className="text-sm font-medium text-muted-foreground">Location</p>
<p className="text-sm">{project.geographicZone || project.country}</p>
</div>
</div>
)}
{project.institution && (
<div className="flex items-start gap-2">
<GraduationCap className="h-4 w-4 text-muted-foreground mt-0.5" />
<div>
<p className="text-sm font-medium text-muted-foreground">Institution</p>
<p className="text-sm">{project.institution}</p>
</div>
</div>
)}
{project.foundedAt && (
<div className="flex items-start gap-2">
<Calendar className="h-4 w-4 text-muted-foreground mt-0.5" />
<div>
<p className="text-sm font-medium text-muted-foreground">Founded</p>
<p className="text-sm">{formatDateOnly(project.foundedAt)}</p>
</div>
</div>
)}
</div>
{/* Submission URLs */}
{(project.phase1SubmissionUrl || project.phase2SubmissionUrl) && (
<div className="space-y-2">
<p className="text-sm font-medium text-muted-foreground">Submission Links</p>
<div className="flex flex-wrap gap-2">
{project.phase1SubmissionUrl && (
<Button variant="outline" size="sm" asChild>
<a href={project.phase1SubmissionUrl} target="_blank" rel="noopener noreferrer">
Phase 1 Submission
</a>
</Button>
)}
{project.phase2SubmissionUrl && (
<Button variant="outline" size="sm" asChild>
<a href={project.phase2SubmissionUrl} target="_blank" rel="noopener noreferrer">
Phase 2 Submission
</a>
</Button>
)}
</div>
</div>
)}
{/* AI-Assigned Expertise Tags */}
{project.projectTags && project.projectTags.length > 0 && (
<div className="mt-4">
<p className="mb-2 text-xs text-muted-foreground">
Expertise Tags
</p>
<div>
<p className="text-sm font-medium text-muted-foreground mb-2">Expertise Tags</p>
<div className="flex flex-wrap gap-2">
{project.projectTags.map((pt) => (
<Badge
key={pt.tag.id}
variant="secondary"
className="flex items-center gap-1"
style={
pt.tag.color
? {
backgroundColor: `${pt.tag.color}20`,
borderColor: pt.tag.color,
}
: undefined
}
style={pt.tag.color ? { backgroundColor: `${pt.tag.color}20`, borderColor: pt.tag.color } : undefined}
>
{pt.tag.name}
{pt.confidence < 1 && (
@@ -406,6 +462,56 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
</div>
</div>
)}
{/* Simple Tags (legacy) */}
{project.tags && project.tags.length > 0 && (
<div>
<p className="text-sm font-medium text-muted-foreground mb-2">Tags</p>
<div className="flex flex-wrap gap-2">
{project.tags.map((tag: string) => (
<Badge key={tag} variant="secondary">{tag}</Badge>
))}
</div>
</div>
)}
{/* Internal Info */}
{(project.internalComments || project.applicationStatus || project.referralSource) && (
<div className="border-t pt-4 mt-4">
<p className="text-sm font-medium text-muted-foreground mb-3">Internal Notes</p>
<div className="grid gap-3 sm:grid-cols-2">
{project.applicationStatus && (
<div>
<p className="text-xs text-muted-foreground">Application Status</p>
<p className="text-sm">{project.applicationStatus}</p>
</div>
)}
{project.referralSource && (
<div>
<p className="text-xs text-muted-foreground">Referral Source</p>
<p className="text-sm">{project.referralSource}</p>
</div>
)}
</div>
{project.internalComments && (
<div className="mt-3">
<p className="text-xs text-muted-foreground">Comments</p>
<p className="text-sm whitespace-pre-wrap">{project.internalComments}</p>
</div>
)}
</div>
)}
<div className="flex flex-wrap gap-6 text-sm pt-2">
<div>
<span className="text-muted-foreground">Created:</span>{' '}
{formatDateOnly(project.createdAt)}
</div>
<div>
<span className="text-muted-foreground">Updated:</span>{' '}
{formatDateOnly(project.updatedAt)}
</div>
</div>
</CardContent>
</Card>
</AnimatedCard>
@@ -416,10 +522,46 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
const s = roundStateMap.get(r.id)
return s && (s.state === 'PASSED' || s.state === 'COMPLETED')
}).length
const rejectedRound = competitionRounds.find((r) => {
// Find the rejection round — either explicit REJECTED state or inferred
const isProjectRejected = project.status === 'REJECTED'
const explicitRejectedRound = competitionRounds.find((r) => {
const s = roundStateMap.get(r.id)
return s?.state === 'REJECTED'
})
// If project is globally rejected but no round has explicit REJECTED state,
// infer the rejection round as the furthest round the project reached
let inferredRejectionRoundId: string | null = null
if (isProjectRejected && !explicitRejectedRound) {
// Find the last round that has any state record (furthest the project got)
for (let i = competitionRounds.length - 1; i >= 0; i--) {
const s = roundStateMap.get(competitionRounds[i].id)
if (s) {
// If it's PASSED/COMPLETED, rejection happened at the next round
if (s.state === 'PASSED' || s.state === 'COMPLETED') {
if (i + 1 < competitionRounds.length) {
inferredRejectionRoundId = competitionRounds[i + 1].id
}
} else {
// PENDING/IN_PROGRESS in this round means rejected here
inferredRejectionRoundId = competitionRounds[i].id
}
break
}
}
}
const rejectedRound = explicitRejectedRound
?? (inferredRejectionRoundId
? competitionRounds.find((r) => r.id === inferredRejectionRoundId)
: null)
// Determine which rounds are "not reached" (after rejection point)
const rejectedRoundIdx = rejectedRound
? competitionRounds.findIndex((r) => r.id === rejectedRound.id)
: -1
return (
<AnimatedCard index={3}>
<Card>
@@ -438,9 +580,18 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
</CardHeader>
<CardContent>
<ol className="space-y-4">
{competitionRounds.map((round) => {
{competitionRounds.map((round, idx) => {
const roundState = roundStateMap.get(round.id)
const state = roundState?.state
const rawState = roundState?.state
// Override state for inferred rejection
const isRejectionRound = round.id === rejectedRound?.id
const isNotReached = rejectedRoundIdx >= 0 && idx > rejectedRoundIdx
const effectiveState = isRejectionRound && !explicitRejectedRound
? 'REJECTED'
: isNotReached
? 'NOT_REACHED'
: rawState
const roundAssignments = assignments.filter(
(a) => a.roundId === round.id,
@@ -448,13 +599,16 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
let icon: React.ReactNode
let statusLabel: string | null = null
if (state === 'PASSED' || state === 'COMPLETED') {
let labelClass = 'text-muted-foreground'
if (effectiveState === 'PASSED' || effectiveState === 'COMPLETED') {
icon = <CheckCircle2 className="mt-0.5 h-5 w-5 shrink-0 text-emerald-500" />
statusLabel = 'Passed'
} else if (state === 'REJECTED') {
icon = <AlertCircle className="mt-0.5 h-5 w-5 shrink-0 text-destructive" />
} else if (effectiveState === 'REJECTED') {
icon = <XCircle className="mt-0.5 h-5 w-5 shrink-0 text-red-500" />
statusLabel = 'Rejected at this round'
} else if (state === 'IN_PROGRESS') {
labelClass = 'text-red-600 font-medium'
} else if (effectiveState === 'IN_PROGRESS') {
icon = (
<span className="mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center">
<span className="relative flex h-3 w-3">
@@ -464,7 +618,11 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
</span>
)
statusLabel = 'Active'
} else if (state === 'PENDING') {
} else if (effectiveState === 'NOT_REACHED') {
icon = <Circle className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground/15" />
statusLabel = 'Not reached'
labelClass = 'text-muted-foreground/50 italic'
} else if (effectiveState === 'PENDING') {
icon = <Circle className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground/40" />
statusLabel = 'Pending'
} else {
@@ -472,15 +630,18 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
}
return (
<li key={round.id} className="flex items-start gap-3">
<li key={round.id} className={cn(
'flex items-start gap-3',
effectiveState === 'NOT_REACHED' && 'opacity-50',
)}>
{icon}
<div className="min-w-0 flex-1">
<p className="text-sm font-medium">{round.name}</p>
<p className={cn(
'text-sm font-medium',
effectiveState === 'NOT_REACHED' && 'text-muted-foreground',
)}>{round.name}</p>
{statusLabel && (
<p className={cn(
'text-xs',
state === 'REJECTED' ? 'text-destructive' : 'text-muted-foreground',
)}>
<p className={cn('text-xs', labelClass)}>
{statusLabel}
</p>
)}
@@ -490,7 +651,7 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
</p>
)}
</div>
{state === 'IN_PROGRESS' && (
{effectiveState === 'IN_PROGRESS' && (
<Badge
variant="outline"
className="ml-auto shrink-0 border-blue-200 bg-blue-50 text-blue-600 text-xs"
@@ -498,6 +659,14 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
Active
</Badge>
)}
{effectiveState === 'REJECTED' && (
<Badge
variant="destructive"
className="ml-auto shrink-0 text-xs"
>
Rejected
</Badge>
)}
</li>
)
})}

View File

@@ -1317,6 +1317,21 @@ export const analyticsRouter = router({
select: { roundId: true, state: true, enteredAt: true, exitedAt: true },
})
// Get filtering result (AI screening) for rejected projects
const filteringResult = projectRaw.status === 'REJECTED'
? await ctx.prisma.filteringResult.findFirst({
where: { projectId: input.id },
select: {
outcome: true,
finalOutcome: true,
aiScreeningJson: true,
overrideReason: true,
round: { select: { id: true, name: true } },
},
orderBy: { createdAt: 'desc' },
})
: null
// Get file requirements for all rounds
let allRequirements: { id: string; roundId: string; name: string; description: string | null; isRequired: boolean; acceptedMimeTypes: string[]; maxSizeMB: number | null }[] = []
if (competitionRounds.length > 0) {
@@ -1360,6 +1375,7 @@ export const analyticsRouter = router({
competitionRounds,
projectRoundStates,
allRequirements,
filteringResult,
}
}),