2026-02-14 15:26:42 +01:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { useSession } from 'next-auth/react'
|
|
|
|
|
import { trpc } from '@/lib/trpc/client'
|
|
|
|
|
import { Badge } from '@/components/ui/badge'
|
2026-03-04 13:29:39 +01:00
|
|
|
import { Button } from '@/components/ui/button'
|
2026-02-14 15:26:42 +01:00
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
|
|
|
|
} from '@/components/ui/card'
|
|
|
|
|
import { Skeleton } from '@/components/ui/skeleton'
|
|
|
|
|
import { RequirementUploadList } from '@/components/shared/requirement-upload-slot'
|
|
|
|
|
import {
|
|
|
|
|
FileText,
|
|
|
|
|
Upload,
|
|
|
|
|
AlertTriangle,
|
|
|
|
|
Clock,
|
|
|
|
|
Video,
|
|
|
|
|
File,
|
|
|
|
|
Download,
|
2026-03-04 13:29:39 +01:00
|
|
|
Eye,
|
2026-02-14 15:26:42 +01:00
|
|
|
} from 'lucide-react'
|
|
|
|
|
|
|
|
|
|
const fileTypeIcons: Record<string, typeof FileText> = {
|
|
|
|
|
EXEC_SUMMARY: FileText,
|
|
|
|
|
BUSINESS_PLAN: FileText,
|
|
|
|
|
PRESENTATION: FileText,
|
|
|
|
|
VIDEO_PITCH: Video,
|
|
|
|
|
VIDEO: Video,
|
|
|
|
|
OTHER: File,
|
|
|
|
|
SUPPORTING_DOC: File,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fileTypeLabels: Record<string, string> = {
|
|
|
|
|
EXEC_SUMMARY: 'Executive Summary',
|
|
|
|
|
BUSINESS_PLAN: 'Business Plan',
|
|
|
|
|
PRESENTATION: 'Presentation',
|
|
|
|
|
VIDEO_PITCH: 'Video Pitch',
|
|
|
|
|
VIDEO: 'Video',
|
|
|
|
|
OTHER: 'Other Document',
|
|
|
|
|
SUPPORTING_DOC: 'Supporting Document',
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 13:29:39 +01:00
|
|
|
function FileActionButtons({ bucket, objectKey, fileName }: { bucket: string; objectKey: string; fileName: string }) {
|
|
|
|
|
const { data: viewData } = trpc.file.getDownloadUrl.useQuery(
|
2026-03-04 18:18:28 +01:00
|
|
|
{ bucket, objectKey, forDownload: false, purpose: 'open' as const },
|
2026-03-04 13:29:39 +01:00
|
|
|
{ staleTime: 10 * 60 * 1000 }
|
|
|
|
|
)
|
|
|
|
|
const { data: dlData } = trpc.file.getDownloadUrl.useQuery(
|
2026-03-04 18:18:28 +01:00
|
|
|
{ bucket, objectKey, forDownload: true, fileName, purpose: 'download' as const },
|
2026-03-04 13:29:39 +01:00
|
|
|
{ staleTime: 10 * 60 * 1000 }
|
|
|
|
|
)
|
|
|
|
|
const viewUrl = typeof viewData === 'string' ? viewData : viewData?.url
|
|
|
|
|
const dlUrl = typeof dlData === 'string' ? dlData : dlData?.url
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-1 shrink-0">
|
|
|
|
|
<Button variant="ghost" size="sm" className="h-7 px-2 text-xs gap-1" asChild disabled={!viewUrl}>
|
|
|
|
|
<a href={viewUrl || '#'} target="_blank" rel="noopener noreferrer">
|
|
|
|
|
<Eye className="h-3 w-3" /> View
|
|
|
|
|
</a>
|
|
|
|
|
</Button>
|
|
|
|
|
<Button variant="ghost" size="sm" className="h-7 px-2 text-xs gap-1" asChild disabled={!dlUrl}>
|
|
|
|
|
<a href={dlUrl || '#'} download={fileName}>
|
|
|
|
|
<Download className="h-3 w-3" /> Download
|
|
|
|
|
</a>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 15:26:42 +01:00
|
|
|
export default function ApplicantDocumentsPage() {
|
|
|
|
|
const { status: sessionStatus } = useSession()
|
|
|
|
|
const isAuthenticated = sessionStatus === 'authenticated'
|
|
|
|
|
|
|
|
|
|
const { data, isLoading } = trpc.applicant.getMyDashboard.useQuery(undefined, {
|
|
|
|
|
enabled: isAuthenticated,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<Skeleton className="h-8 w-48" />
|
|
|
|
|
<Skeleton className="h-4 w-64" />
|
|
|
|
|
</div>
|
|
|
|
|
<Skeleton className="h-64 w-full" />
|
|
|
|
|
<Skeleton className="h-48 w-full" />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data?.project) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="text-2xl font-semibold tracking-tight">Documents</h1>
|
|
|
|
|
</div>
|
|
|
|
|
<Card>
|
|
|
|
|
<CardContent className="flex flex-col items-center justify-center py-12">
|
|
|
|
|
<FileText className="h-12 w-12 text-muted-foreground/50 mb-4" />
|
|
|
|
|
<h2 className="text-xl font-semibold mb-2">No Project</h2>
|
|
|
|
|
<p className="text-muted-foreground text-center">
|
|
|
|
|
Submit a project first to upload documents.
|
|
|
|
|
</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 13:29:39 +01:00
|
|
|
const { project, openRounds, isRejected } = data
|
2026-02-14 15:26:42 +01:00
|
|
|
const isDraft = !project.submittedAt
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
{/* Header */}
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="text-2xl font-semibold tracking-tight flex items-center gap-2">
|
|
|
|
|
<Upload className="h-6 w-6" />
|
|
|
|
|
Documents
|
|
|
|
|
</h1>
|
|
|
|
|
<p className="text-muted-foreground">
|
|
|
|
|
Upload and manage documents for your project: {project.title}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-04 13:29:39 +01:00
|
|
|
{/* Rejected banner */}
|
|
|
|
|
{isRejected && (
|
|
|
|
|
<Card className="border-destructive/50 bg-destructive/5">
|
|
|
|
|
<CardContent className="flex items-center gap-3 py-4">
|
|
|
|
|
<AlertTriangle className="h-5 w-5 text-destructive shrink-0" />
|
|
|
|
|
<p className="text-sm text-destructive">
|
|
|
|
|
Your project was not selected to advance. Documents are view-only.
|
|
|
|
|
</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
{/* Per-round upload sections */}
|
2026-03-04 13:29:39 +01:00
|
|
|
{!isRejected && openRounds.length > 0 && (
|
2026-02-14 15:26:42 +01:00
|
|
|
<div className="space-y-6">
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
{openRounds.map((round: { id: string; name: string; windowCloseAt?: string | Date | null }) => {
|
2026-02-14 15:26:42 +01:00
|
|
|
const now = new Date()
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
const hasDeadline = !!round.windowCloseAt
|
|
|
|
|
const deadlinePassed = hasDeadline && now > new Date(round.windowCloseAt!)
|
2026-02-14 15:26:42 +01:00
|
|
|
const isLate = deadlinePassed
|
|
|
|
|
|
|
|
|
|
return (
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
<Card key={round.id}>
|
2026-02-14 15:26:42 +01:00
|
|
|
<CardHeader>
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div>
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
<CardTitle className="text-lg">{round.name}</CardTitle>
|
2026-02-14 15:26:42 +01:00
|
|
|
<CardDescription>
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
Upload documents for this round
|
2026-02-14 15:26:42 +01:00
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
{isLate && (
|
|
|
|
|
<Badge variant="warning" className="gap-1">
|
|
|
|
|
<AlertTriangle className="h-3 w-3" />
|
|
|
|
|
Late submission
|
|
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
{hasDeadline && !deadlinePassed && (
|
|
|
|
|
<Badge variant="outline" className="gap-1">
|
|
|
|
|
<Clock className="h-3 w-3" />
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
Due {new Date(round.windowCloseAt!).toLocaleDateString()}
|
2026-02-14 15:26:42 +01:00
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<RequirementUploadList
|
|
|
|
|
projectId={project.id}
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
roundId={round.id}
|
2026-02-14 15:26:42 +01:00
|
|
|
disabled={false}
|
|
|
|
|
/>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Uploaded files list */}
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>All Uploaded Documents</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
All files associated with your project
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
{project.files.length === 0 ? (
|
|
|
|
|
<p className="text-muted-foreground text-center py-4">
|
|
|
|
|
No documents uploaded yet
|
|
|
|
|
</p>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{project.files.map((file) => {
|
|
|
|
|
const Icon = fileTypeIcons[file.fileType] || File
|
2026-03-04 13:29:39 +01:00
|
|
|
const fileRecord = file as typeof file & { isLate?: boolean; roundId?: string | null; bucket?: string; objectKey?: string }
|
2026-02-14 15:26:42 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={file.id}
|
|
|
|
|
className="flex items-center justify-between p-3 rounded-lg border"
|
|
|
|
|
>
|
2026-03-04 13:29:39 +01:00
|
|
|
<div className="flex items-center gap-3 min-w-0">
|
|
|
|
|
<Icon className="h-5 w-5 text-muted-foreground shrink-0" />
|
|
|
|
|
<div className="min-w-0">
|
2026-02-14 15:26:42 +01:00
|
|
|
<div className="flex items-center gap-2">
|
2026-03-04 13:29:39 +01:00
|
|
|
<p className="font-medium text-sm truncate">{file.fileName}</p>
|
2026-02-14 15:26:42 +01:00
|
|
|
{fileRecord.isLate && (
|
|
|
|
|
<Badge variant="warning" className="text-xs gap-1">
|
|
|
|
|
<AlertTriangle className="h-3 w-3" />
|
|
|
|
|
Late
|
|
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
|
{fileTypeLabels[file.fileType] || file.fileType}
|
|
|
|
|
{' - '}
|
|
|
|
|
{new Date(file.createdAt).toLocaleDateString()}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-04 13:29:39 +01:00
|
|
|
{fileRecord.bucket && fileRecord.objectKey && (
|
|
|
|
|
<FileActionButtons
|
|
|
|
|
bucket={fileRecord.bucket}
|
|
|
|
|
objectKey={fileRecord.objectKey}
|
|
|
|
|
fileName={file.fileName}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2026-02-14 15:26:42 +01:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
{/* No open rounds message */}
|
|
|
|
|
{openRounds.length === 0 && project.files.length === 0 && (
|
2026-02-14 15:26:42 +01:00
|
|
|
<Card className="bg-muted/50">
|
|
|
|
|
<CardContent className="p-6 text-center">
|
|
|
|
|
<Clock className="h-10 w-10 mx-auto text-muted-foreground/50 mb-3" />
|
|
|
|
|
<p className="text-muted-foreground">
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
No rounds are currently open for document submissions.
|
2026-02-14 15:26:42 +01:00
|
|
|
</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|