Simplify project detail: back button, cleaner files, fix round inference
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

- Replace breadcrumb with "Back to Projects" button on observer detail
- Remove submission links from observer project info
- Simplify files tab: remove redundant requirements checklist, show only
  FileViewer (observer + admin)
- Fix round history: infer earlier rounds as PASSED when later round is
  active (e.g. R2 shows Passed when project is active in R3)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 23:45:31 +01:00
parent d717040f03
commit a6b6763fa4
2 changed files with 98 additions and 347 deletions

View File

@@ -43,9 +43,6 @@ import {
Users, Users,
FileText, FileText,
Calendar, Calendar,
CheckCircle2,
XCircle,
Circle,
Clock, Clock,
BarChart3, BarChart3,
ThumbsUp, ThumbsUp,
@@ -562,105 +559,9 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
</div> </div>
</CardHeader> </CardHeader>
<CardContent className="space-y-6"> <CardContent className="space-y-6">
{/* Requirements organized by round */} {/* File upload */}
{competitionRounds.length > 0 && allRequirements.length > 0 ? (
<>
{competitionRounds.map((round: { id: string; name: string }) => {
const roundRequirements = allRequirements.filter((req: any) => req.roundId === round.id)
if (roundRequirements.length === 0) return null
return (
<div key={round.id} className="space-y-3">
<div className="flex items-center gap-2">
<h3 className="text-sm font-semibold">{round.name}</h3>
<Badge variant="outline" className="text-xs">
{roundRequirements.length} requirement{roundRequirements.length !== 1 ? 's' : ''}
</Badge>
</div>
<div className="grid gap-2">
{roundRequirements.map((req: any) => {
// Find file that fulfills this requirement
const fulfilledFile = files?.find((f: any) => f.requirementId === req.id)
const isFulfilled = !!fulfilledFile
return (
<div
key={req.id}
className={`flex items-center justify-between rounded-lg border p-3 ${
isFulfilled
? 'border-green-200 bg-green-50/50 dark:border-green-900 dark:bg-green-950/20'
: 'border-muted'
}`}
>
<div className="flex items-center gap-3 min-w-0">
{isFulfilled ? (
<CheckCircle2 className="h-5 w-5 shrink-0 text-green-600" />
) : (
<Circle className="h-5 w-5 shrink-0 text-muted-foreground" />
)}
<div className="min-w-0">
<div className="flex items-center gap-2">
<p className="text-sm font-medium truncate">{req.name}</p>
{req.isRequired && (
<Badge variant="destructive" className="text-xs shrink-0">
Required
</Badge>
)}
</div>
{req.description && (
<p className="text-xs text-muted-foreground truncate">
{req.description}
</p>
)}
<div className="flex items-center gap-2 text-xs text-muted-foreground mt-0.5">
{req.acceptedMimeTypes?.length > 0 && (
<span>
{req.acceptedMimeTypes.map((mime: string) => {
if (mime === 'application/pdf') return 'PDF'
if (mime === 'image/*') return 'Images'
if (mime === 'video/*') return 'Video'
if (mime.includes('wordprocessing')) return 'Word'
if (mime.includes('spreadsheet')) return 'Excel'
if (mime.includes('presentation')) return 'PowerPoint'
return mime.split('/')[1] || mime
}).join(', ')}
</span>
)}
{req.maxSizeMB && (
<span className="shrink-0"> Max {req.maxSizeMB}MB</span>
)}
</div>
{isFulfilled && fulfilledFile && (
<p className="text-xs text-green-700 dark:text-green-400 mt-1 font-medium">
{fulfilledFile.fileName}
</p>
)}
</div>
</div>
{!isFulfilled && (
<span className="text-xs text-amber-600 dark:text-amber-400 shrink-0 ml-2 font-medium">
Missing
</span>
)}
</div>
)
})}
</div>
</div>
)
})}
<Separator />
</>
) : null}
{/* General file upload section */}
<div> <div>
<p className="text-sm font-semibold mb-3"> <p className="text-sm font-semibold mb-3">Upload Files</p>
{allRequirements.length > 0 ? 'Additional Documents' : 'Upload Files'}
</p>
<p className="text-xs text-muted-foreground mb-3">
Upload files not tied to specific requirements
</p>
<FileUpload <FileUpload
projectId={projectId} projectId={projectId}
availableRounds={competitionRounds?.map((r: any) => ({ id: r.id, name: r.name }))} availableRounds={competitionRounds?.map((r: any) => ({ id: r.id, name: r.name }))}
@@ -674,33 +575,30 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
{files && files.length > 0 && ( {files && files.length > 0 && (
<> <>
<Separator /> <Separator />
<div> <FileViewer
<p className="text-sm font-semibold mb-3">All Uploaded Files</p> projectId={projectId}
<FileViewer files={files.map((f) => ({
projectId={projectId} id: f.id,
files={files.map((f) => ({ fileName: f.fileName,
id: f.id, fileType: f.fileType,
fileName: f.fileName, mimeType: f.mimeType,
fileType: f.fileType, size: f.size,
mimeType: f.mimeType, bucket: f.bucket,
size: f.size, objectKey: f.objectKey,
bucket: f.bucket, pageCount: f.pageCount,
objectKey: f.objectKey, textPreview: f.textPreview,
pageCount: f.pageCount, detectedLang: f.detectedLang,
textPreview: f.textPreview, langConfidence: f.langConfidence,
detectedLang: f.detectedLang, analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null,
langConfidence: f.langConfidence, requirementId: f.requirementId,
analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null, requirement: f.requirement ? {
requirementId: f.requirementId, id: f.requirement.id,
requirement: f.requirement ? { name: f.requirement.name,
id: f.requirement.id, description: f.requirement.description,
name: f.requirement.name, isRequired: f.requirement.isRequired,
description: f.requirement.description, } : null,
isRequired: f.requirement.isRequired, }))}
} : null, />
}))}
/>
</div>
</> </>
)} )}
</CardContent> </CardContent>

View File

@@ -38,6 +38,7 @@ import {
Heart, Heart,
Clock, Clock,
MessageSquare, MessageSquare,
ArrowLeft,
} from 'lucide-react' } from 'lucide-react'
import { cn, formatDate, formatDateOnly } from '@/lib/utils' import { cn, formatDate, formatDateOnly } from '@/lib/utils'
@@ -85,7 +86,7 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
) )
} }
const { project, assignments, stats, competitionRounds, projectRoundStates, allRequirements, filteringResult } = const { project, assignments, stats, competitionRounds, projectRoundStates, filteringResult } =
data data
const roundStateMap = new Map( const roundStateMap = new Map(
@@ -149,23 +150,13 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
return ( return (
<div className="space-y-6"> <div className="space-y-6">
{/* Breadcrumb */} {/* Back button */}
<nav className="flex items-center gap-1 text-sm text-muted-foreground"> <Button variant="ghost" size="sm" className="gap-1.5 -ml-2 text-muted-foreground" asChild>
<Link href={'/observer' as Route} className="hover:text-foreground"> <Link href={'/observer/projects' as Route}>
Observer <ArrowLeft className="h-3.5 w-3.5" />
Back to Projects
</Link> </Link>
<span>/</span> </Button>
<Link
href={'/observer/projects' as Route}
className="hover:text-foreground"
>
Projects
</Link>
<span>/</span>
<span className="max-w-[200px] truncate font-medium text-foreground">
{project.title}
</span>
</nav>
{/* Project Header */} {/* Project Header */}
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"> <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
@@ -416,29 +407,6 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
)} )}
</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 */} {/* AI-Assigned Expertise Tags */}
{project.projectTags && project.projectTags.length > 0 && ( {project.projectTags && project.projectTags.length > 0 && (
<div> <div>
@@ -518,10 +486,16 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
{/* Round History */} {/* Round History */}
{competitionRounds.length > 0 && (() => { {competitionRounds.length > 0 && (() => {
const passedCount = competitionRounds.filter((r) => { // Find the furthest round index where the project is active or beyond
const s = roundStateMap.get(r.id) // Any round before this must have been passed
return s && (s.state === 'PASSED' || s.state === 'COMPLETED') let furthestActiveIdx = -1
}).length for (let i = competitionRounds.length - 1; i >= 0; i--) {
const s = roundStateMap.get(competitionRounds[i].id)
if (s && (s.state === 'IN_PROGRESS' || s.state === 'PASSED' || s.state === 'COMPLETED')) {
furthestActiveIdx = i
break
}
}
// Find the rejection round — either explicit REJECTED state or inferred // Find the rejection round — either explicit REJECTED state or inferred
const isProjectRejected = project.status === 'REJECTED' const isProjectRejected = project.status === 'REJECTED'
@@ -534,17 +508,14 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
// infer the rejection round as the furthest round the project reached // infer the rejection round as the furthest round the project reached
let inferredRejectionRoundId: string | null = null let inferredRejectionRoundId: string | null = null
if (isProjectRejected && !explicitRejectedRound) { 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--) { for (let i = competitionRounds.length - 1; i >= 0; i--) {
const s = roundStateMap.get(competitionRounds[i].id) const s = roundStateMap.get(competitionRounds[i].id)
if (s) { if (s) {
// If it's PASSED/COMPLETED, rejection happened at the next round
if (s.state === 'PASSED' || s.state === 'COMPLETED') { if (s.state === 'PASSED' || s.state === 'COMPLETED') {
if (i + 1 < competitionRounds.length) { if (i + 1 < competitionRounds.length) {
inferredRejectionRoundId = competitionRounds[i + 1].id inferredRejectionRoundId = competitionRounds[i + 1].id
} }
} else { } else {
// PENDING/IN_PROGRESS in this round means rejected here
inferredRejectionRoundId = competitionRounds[i].id inferredRejectionRoundId = competitionRounds[i].id
} }
break break
@@ -557,11 +528,28 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
? competitionRounds.find((r) => r.id === inferredRejectionRoundId) ? competitionRounds.find((r) => r.id === inferredRejectionRoundId)
: null) : null)
// Determine which rounds are "not reached" (after rejection point)
const rejectedRoundIdx = rejectedRound const rejectedRoundIdx = rejectedRound
? competitionRounds.findIndex((r) => r.id === rejectedRound.id) ? competitionRounds.findIndex((r) => r.id === rejectedRound.id)
: -1 : -1
// Compute effective states for all rounds
const effectiveStates = competitionRounds.map((round, idx) => {
const rawState = roundStateMap.get(round.id)?.state
const isRejectionRound = round.id === rejectedRound?.id
const isNotReached = rejectedRoundIdx >= 0 && idx > rejectedRoundIdx
if (isRejectionRound && !explicitRejectedRound) return 'REJECTED'
if (isNotReached) return 'NOT_REACHED'
// If this round is before the furthest active round and not already PASSED/COMPLETED,
// the project must have passed it to reach the later round
if (furthestActiveIdx > idx && (!rawState || rawState === 'PENDING')) return 'PASSED'
return rawState
})
const passedCount = effectiveStates.filter(
(s) => s === 'PASSED' || s === 'COMPLETED',
).length
return ( return (
<AnimatedCard index={3}> <AnimatedCard index={3}>
<Card> <Card>
@@ -581,17 +569,7 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
<CardContent> <CardContent>
<ol className="space-y-4"> <ol className="space-y-4">
{competitionRounds.map((round, idx) => { {competitionRounds.map((round, idx) => {
const roundState = roundStateMap.get(round.id) const effectiveState = effectiveStates[idx]
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( const roundAssignments = assignments.filter(
(a) => a.roundId === round.id, (a) => a.roundId === round.id,
@@ -884,169 +862,44 @@ export function ObserverProjectDetail({ projectId }: { projectId: string }) {
<div className="rounded-lg bg-rose-500/10 p-1.5"> <div className="rounded-lg bg-rose-500/10 p-1.5">
<FileText className="h-4 w-4 text-rose-500" /> <FileText className="h-4 w-4 text-rose-500" />
</div> </div>
Files Project Files
</CardTitle> </CardTitle>
<CardDescription>
Project documents organized by competition round
</CardDescription>
</CardHeader> </CardHeader>
<CardContent className="space-y-6"> <CardContent>
{competitionRounds.length > 0 && allRequirements.length > 0 ? (
<>
{competitionRounds.map((round) => {
const roundRequirements = allRequirements.filter(
(req) => req.roundId === round.id,
)
if (roundRequirements.length === 0) return null
return (
<div key={round.id} className="space-y-3">
<div className="flex items-center gap-2">
<h3 className="text-sm font-semibold">
{round.name}
</h3>
<Badge variant="outline" className="text-xs">
{roundRequirements.length} requirement
{roundRequirements.length !== 1 ? 's' : ''}
</Badge>
</div>
<div className="grid gap-2">
{roundRequirements.map((req) => {
const fulfilledFile = project.files?.find(
(f) => f.requirementId === req.id,
)
const isFulfilled = !!fulfilledFile
return (
<div
key={req.id}
className={`flex items-center justify-between rounded-lg border p-3 ${
isFulfilled
? 'border-green-200 bg-green-50/50 dark:border-green-900 dark:bg-green-950/20'
: 'border-muted'
}`}
>
<div className="flex min-w-0 items-center gap-3">
{isFulfilled ? (
<CheckCircle2 className="h-5 w-5 shrink-0 text-green-600" />
) : (
<Circle className="h-5 w-5 shrink-0 text-muted-foreground" />
)}
<div className="min-w-0">
<div className="flex items-center gap-2">
<p className="truncate text-sm font-medium">
{req.name}
</p>
{req.isRequired && (
<Badge
variant="destructive"
className="shrink-0 text-xs"
>
Required
</Badge>
)}
</div>
{req.description && (
<p className="truncate text-xs text-muted-foreground">
{req.description}
</p>
)}
<div className="mt-0.5 flex items-center gap-2 text-xs text-muted-foreground">
{req.acceptedMimeTypes?.length > 0 && (
<span>
{req.acceptedMimeTypes
.map((mime) => {
if (mime === 'application/pdf')
return 'PDF'
if (mime === 'image/*')
return 'Images'
if (mime === 'video/*')
return 'Video'
if (
mime.includes('wordprocessing')
)
return 'Word'
if (mime.includes('spreadsheet'))
return 'Excel'
if (
mime.includes('presentation')
)
return 'PowerPoint'
return mime.split('/')[1] || mime
})
.join(', ')}
</span>
)}
{req.maxSizeMB && (
<span className="shrink-0">
Max {req.maxSizeMB}MB
</span>
)}
</div>
{isFulfilled && fulfilledFile && (
<p className="mt-1 text-xs font-medium text-green-700 dark:text-green-400">
{fulfilledFile.fileName}
</p>
)}
</div>
</div>
{!isFulfilled && (
<span className="ml-2 shrink-0 text-xs font-medium text-amber-600 dark:text-amber-400">
Missing
</span>
)}
</div>
)
})}
</div>
</div>
)
})}
<Separator />
</>
) : null}
{project.files && project.files.length > 0 ? ( {project.files && project.files.length > 0 ? (
<div> <FileViewer
<p className="mb-3 text-sm font-semibold"> projectId={projectId}
{allRequirements.length > 0 files={project.files.map((f) => ({
? 'All Uploaded Files' id: f.id,
: 'Uploaded Files'} fileName: f.fileName,
</p> fileType: f.fileType as
<FileViewer | 'EXEC_SUMMARY'
projectId={projectId} | 'PRESENTATION'
files={project.files.map((f) => ({ | 'VIDEO'
id: f.id, | 'OTHER'
fileName: f.fileName, | 'BUSINESS_PLAN'
fileType: f.fileType as | 'VIDEO_PITCH'
| 'EXEC_SUMMARY' | 'SUPPORTING_DOC',
| 'PRESENTATION' mimeType: f.mimeType,
| 'VIDEO' size: f.size,
| 'OTHER' bucket: f.bucket,
| 'BUSINESS_PLAN' objectKey: f.objectKey,
| 'VIDEO_PITCH' pageCount: f.pageCount,
| 'SUPPORTING_DOC', textPreview: f.textPreview,
mimeType: f.mimeType, detectedLang: f.detectedLang,
size: f.size, langConfidence: f.langConfidence,
bucket: f.bucket, analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null,
objectKey: f.objectKey, requirementId: f.requirementId,
pageCount: f.pageCount, requirement: f.requirement
textPreview: f.textPreview, ? {
detectedLang: f.detectedLang, id: f.requirement.id,
langConfidence: f.langConfidence, name: f.requirement.name,
analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null, description: f.requirement.description,
requirementId: f.requirementId, isRequired: f.requirement.isRequired,
requirement: f.requirement }
? { : null,
id: f.requirement.id, }))}
name: f.requirement.name, />
description: f.requirement.description,
isRequired: f.requirement.isRequired,
}
: null,
}))}
/>
</div>
) : ( ) : (
<div className="flex flex-col items-center justify-center py-8 text-center"> <div className="flex flex-col items-center justify-center py-8 text-center">
<FileText className="h-12 w-12 text-muted-foreground/50" /> <FileText className="h-12 w-12 text-muted-foreground/50" />