'use client' import { useSession } from 'next-auth/react' import { trpc } from '@/lib/trpc/client' import { Badge } from '@/components/ui/badge' 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, } 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', } 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, openStages } = data const isDraft = !project.submittedAt return (
{/* Header */}

Documents

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

{/* Per-stage upload sections */} {openStages.length > 0 && (
{openStages.map((stage) => { const now = new Date() const hasDeadline = !!stage.windowCloseAt const deadlinePassed = hasDeadline && now > new Date(stage.windowCloseAt!) const isLate = deadlinePassed return (
{stage.name} Upload documents for this stage
{isLate && ( Late submission )} {hasDeadline && !deadlinePassed && ( Due {new Date(stage.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; stageId?: string | null } return (

{file.fileName}

{fileRecord.isLate && ( Late )}

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

) })}
)}
{/* No open stages message */} {openStages.length === 0 && project.files.length === 0 && (

No stages are currently open for document submissions.

)}
) }