'use client' import { trpc } from '@/lib/trpc/client' import Link from 'next/link' import type { Route } from 'next' import { Card, CardContent, CardHeader, CardTitle, } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { Upload, Users, MessageSquare, ArrowRight, FileText, Clock, CheckCircle2, XCircle, Layers, } from 'lucide-react' import { StageTimeline } from '@/components/shared/stage-timeline' import { StageWindowBadge } from '@/components/shared/stage-window-badge' import { cn } from '@/lib/utils' const stateLabels: Record = { PENDING: 'Pending', IN_PROGRESS: 'In Progress', PASSED: 'Passed', REJECTED: 'Not Selected', COMPLETED: 'Completed', WAITING: 'Waiting', } const stateVariants: Record = { PENDING: 'secondary', IN_PROGRESS: 'info', PASSED: 'success', REJECTED: 'destructive', COMPLETED: 'success', WAITING: 'warning', } export default function ApplicantPipelinePage() { // Get applicant's project via dashboard endpoint const { data: dashboard } = trpc.applicant.getMyDashboard.useQuery() const project = dashboard?.project const projectId = project?.id ?? '' const programId = project?.program?.id ?? '' const { data: pipelineView, isLoading: pipelineLoading } = trpc.pipeline.getApplicantView.useQuery( { programId, projectId }, { enabled: !!programId && !!projectId } ) const { data: timeline, isLoading: timelineLoading } = trpc.stage.getApplicantTimeline.useQuery( { projectId, pipelineId: pipelineView?.pipelineId ?? '' }, { enabled: !!projectId && !!pipelineView?.pipelineId } ) const isLoading = pipelineLoading || timelineLoading if (!project && !isLoading) { return (

Pipeline Progress

Track your project through the selection pipeline

No project found

You don't have a project in the current edition yet.

) } if (isLoading) { return (

Pipeline Progress

Track your project through the selection pipeline

) } // Build timeline items for StageTimeline const timelineItems = timeline?.map((item) => ({ id: item.stageId, name: item.stageName, stageType: item.stageType, isCurrent: item.isCurrent, state: item.state, enteredAt: item.enteredAt, })) ?? [] // Find current stage const currentStage = timeline?.find((item) => item.isCurrent) return (

Pipeline Progress

Track your project through the selection pipeline

{/* Project title + status */}

{project?.title}

{(project as { teamName?: string } | undefined)?.teamName}

{currentStage && ( {stateLabels[currentStage.state] ?? currentStage.state} )}
{/* Stage Timeline visualization */} {timelineItems.length > 0 && ( Pipeline Progress )} {/* Current stage details */} {currentStage && (
Current Stage

{currentStage.stageName}

{currentStage.stageType.toLowerCase().replace(/_/g, ' ')}

{currentStage.enteredAt && (

Entered {new Date(currentStage.enteredAt).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric', })}

)}
)} {/* Decision history */} {timeline && timeline.length > 0 && ( Stage History
{timeline.map((item) => (

{item.stageName}

{item.enteredAt && (

{new Date(item.enteredAt).toLocaleDateString()}

)}
{stateLabels[item.state] ?? item.state}
))}
)} {/* Quick actions */}
{currentStage && (

Upload Documents

Submit required files

)}

View Team

Team members

Contact Mentor

Send a message

) }