'use client' import { useSession } from 'next-auth/react' import Link from 'next/link' import type { Route } from 'next' import { trpc } from '@/lib/trpc/client' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle, } from '@/components/ui/card' import { Skeleton } from '@/components/ui/skeleton' import { StatusTracker } from '@/components/shared/status-tracker' import { CompetitionTimelineSidebar } from '@/components/applicant/competition-timeline' import { WithdrawButton } from '@/components/applicant/withdraw-button' import { MentoringRequestCard } from '@/components/applicant/mentoring-request-card' import { AnimatedCard } from '@/components/shared/animated-container' import { FileText, Calendar, CheckCircle, Users, Crown, MessageSquare, Upload, ArrowRight, Star, AlertCircle, } from 'lucide-react' const statusColors: Record = { DRAFT: 'secondary', SUBMITTED: 'default', UNDER_REVIEW: 'default', ELIGIBLE: 'default', SEMIFINALIST: 'success', FINALIST: 'success', WINNER: 'success', REJECTED: 'destructive', } export default function ApplicantDashboardPage() { const { data: session, status: sessionStatus } = useSession() const isAuthenticated = sessionStatus === 'authenticated' const { data, isLoading } = trpc.applicant.getMyDashboard.useQuery(undefined, { enabled: isAuthenticated, }) const { data: deadlines } = trpc.applicant.getUpcomingDeadlines.useQuery(undefined, { enabled: isAuthenticated, }) const { data: docCompleteness } = trpc.applicant.getDocumentCompleteness.useQuery(undefined, { enabled: isAuthenticated, }) const { data: evaluations } = trpc.applicant.getMyEvaluations.useQuery(undefined, { enabled: isAuthenticated, }) if (sessionStatus === 'loading' || isLoading) { return (
) } // No project yet if (!data?.project) { return (

My Project

Your applicant dashboard

No Project Yet

You haven't submitted a project yet. Check for open application rounds on the MOPC website.

) } const { project, timeline, currentStatus, openRounds, hasPassedIntake, isRejected } = data const programYear = project.program?.year const programName = project.program?.name const totalEvaluations = evaluations?.reduce((sum, r) => sum + r.evaluationCount, 0) ?? 0 return (
{/* Header */}
{/* Project logo */}
{data.logoUrl ? ( {project.title} ) : ( )}

{project.title}

{currentStatus && ( {currentStatus.replace('_', ' ')} )}

{programYear ? `${programYear} Edition` : ''}{programName ? ` - ${programName}` : ''}

{project.isTeamLead && currentStatus !== 'REJECTED' && (currentStatus as string) !== 'WINNER' && ( )}
{/* Main content */}
{/* Project details */} Project Details {project.teamName && (

Team/Organization

{project.teamName}

)} {project.description && (

Description

{project.description}

)} {project.tags && project.tags.length > 0 && (

Tags

{project.tags.map((tag) => ( {tag} ))}
)} {/* Metadata */} {project.metadataJson && Object.keys(project.metadataJson as Record).length > 0 && (

Additional Information

{Object.entries(project.metadataJson as Record).map(([key, value]) => (
{key.replace(/_/g, ' ')}
{String(value)}
))}
)} {/* Meta info row */}
Created {new Date(project.createdAt).toLocaleDateString()}
{project.submittedAt && (
Submitted {new Date(project.submittedAt).toLocaleDateString()}
)}
{project.files.length} file(s)
{/* Rejected banner */} {isRejected && (

Your project was not selected to advance. Your project space is now read-only.

)} {/* Quick actions */} {!isRejected && (

Documents

{openRounds.length > 0 ? `${openRounds.length} round(s) open` : 'View uploads'}

Team

{project.teamMembers.length} member(s)

{project.mentorAssignment && (

Mentor

{project.mentorAssignment.mentor?.name || 'Assigned'}

)}
)} {/* Document Completeness */} {docCompleteness && docCompleteness.length > 0 && ( Document Progress {docCompleteness.map((dc) => (
{dc.roundName} {dc.uploaded}/{dc.required} files
0 ? Math.round((dc.uploaded / dc.required) * 100) : 0}%` }} />
))} )}
{/* Sidebar */}
{/* Competition timeline or status tracker */} Status Timeline {/* Mentoring Request Card — show when there's an active MENTORING round */} {project.isTeamLead && openRounds.filter((r) => r.roundType === 'MENTORING').map((mentoringRound) => ( ))} {/* Jury Feedback Card */} {totalEvaluations > 0 && (
Jury Feedback

{totalEvaluations} evaluation{totalEvaluations !== 1 ? 's' : ''} available from{' '} {evaluations?.length ?? 0} round{(evaluations?.length ?? 0) !== 1 ? 's' : ''}.

)} {/* Team overview */}
Team
{project.teamMembers.length > 0 ? ( project.teamMembers.slice(0, 5).map((member) => (
{member.role === 'LEAD' ? ( ) : ( {member.user.name?.charAt(0).toUpperCase() || '?'} )}

{member.user.name || member.user.email}

{member.role === 'LEAD' ? 'Team Lead' : member.role === 'ADVISOR' ? 'Advisor' : 'Member'}

)) ) : (

No team members yet

)} {project.teamMembers.length > 5 && (

+{project.teamMembers.length - 5} more

)}
{/* Upcoming Deadlines */} {deadlines && deadlines.length > 0 && ( Upcoming Deadlines {deadlines.map((dl, i) => (
{dl.roundName} {new Date(dl.windowCloseAt).toLocaleDateString()}
))}
)} {/* Key dates */} Key Dates
Created {new Date(project.createdAt).toLocaleDateString()}
{project.submittedAt && (
Submitted {new Date(project.submittedAt).toLocaleDateString()}
)}
Last Updated {new Date(project.updatedAt).toLocaleDateString()}
) }