'use client' import { trpc } from '@/lib/trpc/client' import { formatCategory } from '@/lib/utils' import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { Separator } from '@/components/ui/separator' import { StatusBadge } from '@/components/shared/status-badge' import { CountryDisplay } from '@/components/shared/country-display' import { ExternalLink, MapPin, Waves, Users } from 'lucide-react' import Link from 'next/link' import type { Route } from 'next' import { scoreGradient } from '@/components/charts/chart-theme' interface ProjectPreviewDialogProps { projectId: string | null roundId?: string open: boolean onOpenChange: (open: boolean) => void } function ScorePill({ score }: { score: number }) { const bg = scoreGradient(score) const text = score >= 6 ? '#ffffff' : '#1a1a1a' return ( {score.toFixed(1)} ) } export function ProjectPreviewDialog({ projectId, roundId, open, onOpenChange }: ProjectPreviewDialogProps) { const { data, isLoading } = trpc.analytics.getProjectDetail.useQuery( { id: projectId!, roundId }, { enabled: !!projectId && open }, ) return ( {isLoading || !data ? ( <>
) : ( <> {data.project.title}
{/* Project info row */}
{data.project.teamName && ( {data.project.teamName} )} {data.project.country && ( )} {data.project.competitionCategory && ( {formatCategory(data.project.competitionCategory)} )}
{/* Description */} {data.project.description && (

{data.project.description}

)} {/* Ocean Issue */} {data.project.oceanIssue && ( {data.project.oceanIssue.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, (c: string) => c.toUpperCase())} )} {/* Evaluation summary */} {data.stats && (

Evaluation Summary

{data.stats.averageGlobalScore != null ? ( ) : '—'}

Avg Score

{data.stats.totalEvaluations ?? 0}

Evaluations

{data.assignments?.length ?? 0}

Assignments

{data.stats.yesPercentage != null ? `${Math.round(data.stats.yesPercentage)}%` : '—'}

Recommend

)} {/* Individual evaluations */} {data.assignments?.length > 0 && (

Juror Evaluations

{data.assignments.map((a: { id: string; user: { name: string | null }; evaluation: { status: string; globalScore: unknown } | null }) => { const ev = a.evaluation const score = ev?.status === 'SUBMITTED' && ev.globalScore != null ? Number(ev.globalScore) : null return (
{a.user.name ?? 'Unknown'} {ev?.status === 'SUBMITTED' ? ( Reviewed ) : ev?.status === 'DRAFT' ? ( Draft ) : ( Pending )}
{score !== null && }
) })}
)} {/* View full project button */}
)}
) }