'use client' import { useSession } from 'next-auth/react' import { trpc } from '@/lib/trpc/client' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' 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, Eye, } from 'lucide-react' const fileTypeIcons: Record = { EXEC_SUMMARY: FileText, BUSINESS_PLAN: FileText, PRESENTATION: FileText, VIDEO_PITCH: Video, VIDEO: Video, OTHER: File, SUPPORTING_DOC: File, } const fileTypeLabels: Record = { EXEC_SUMMARY: 'Executive Summary', BUSINESS_PLAN: 'Business Plan', PRESENTATION: 'Presentation', VIDEO_PITCH: 'Video Pitch', VIDEO: 'Video', OTHER: 'Other Document', SUPPORTING_DOC: 'Supporting Document', } function FileActionButtons({ bucket, objectKey, fileName }: { bucket: string; objectKey: string; fileName: string }) { const { data: viewData } = trpc.file.getDownloadUrl.useQuery( { bucket, objectKey, forDownload: false }, { staleTime: 10 * 60 * 1000 } ) const { data: dlData } = trpc.file.getDownloadUrl.useQuery( { bucket, objectKey, forDownload: true, fileName }, { staleTime: 10 * 60 * 1000 } ) const viewUrl = typeof viewData === 'string' ? viewData : viewData?.url const dlUrl = typeof dlData === 'string' ? dlData : dlData?.url return (
) } 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 (
) } if (!data?.project) { return (

Documents

No Project

Submit a project first to upload documents.

) } const { project, openRounds, isRejected } = data const isDraft = !project.submittedAt return (
{/* Header */}

Documents

Upload and manage documents for your project: {project.title}

{/* Rejected banner */} {isRejected && (

Your project was not selected to advance. Documents are view-only.

)} {/* Per-round upload sections */} {!isRejected && openRounds.length > 0 && (
{openRounds.map((round: { id: string; name: string; windowCloseAt?: string | Date | null }) => { const now = new Date() const hasDeadline = !!round.windowCloseAt const deadlinePassed = hasDeadline && now > new Date(round.windowCloseAt!) const isLate = deadlinePassed return (
{round.name} Upload documents for this round
{isLate && ( Late submission )} {hasDeadline && !deadlinePassed && ( Due {new Date(round.windowCloseAt!).toLocaleDateString()} )}
) })}
)} {/* Uploaded files list */} All Uploaded Documents All files associated with your project {project.files.length === 0 ? (

No documents uploaded yet

) : (
{project.files.map((file) => { const Icon = fileTypeIcons[file.fileType] || File const fileRecord = file as typeof file & { isLate?: boolean; roundId?: string | null; bucket?: string; objectKey?: string } return (

{file.fileName}

{fileRecord.isLate && ( Late )}

{fileTypeLabels[file.fileType] || file.fileType} {' - '} {new Date(file.createdAt).toLocaleDateString()}

{fileRecord.bucket && fileRecord.objectKey && ( )}
) })}
)}
{/* No open rounds message */} {openRounds.length === 0 && project.files.length === 0 && (

No rounds are currently open for document submissions.

)}
) }