'use client' import { trpc } from '@/lib/trpc/client' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Skeleton } from '@/components/ui/skeleton' import { Badge } from '@/components/ui/badge' import { AnimatedCard } from '@/components/shared/animated-container' import { Radio, Users, Trophy, Eye, EyeOff } from 'lucide-react' import { cn } from '@/lib/utils' const SESSION_STATUS_CONFIG: Record = { NOT_STARTED: { label: 'Not Started', color: 'text-slate-500', bg: 'bg-slate-100' }, IN_PROGRESS: { label: 'In Progress', color: 'text-emerald-600', bg: 'bg-emerald-50', pulse: true }, PAUSED: { label: 'Paused', color: 'text-amber-600', bg: 'bg-amber-50' }, COMPLETED: { label: 'Completed', color: 'text-blue-600', bg: 'bg-blue-50' }, } export function LiveFinalPanel({ roundId }: { roundId: string }) { const { data: liveDash, isLoading } = trpc.analytics.getLiveFinalDashboard.useQuery( { roundId }, { refetchInterval: 10_000 }, ) const { data: roundStats } = trpc.analytics.getRoundTypeStats.useQuery( { roundId }, { refetchInterval: 30_000 }, ) const stats = roundStats?.stats as { sessionStatus: string voteCount: number } | undefined const sessionStatus = liveDash?.sessionStatus ?? stats?.sessionStatus ?? 'NOT_STARTED' const statusConfig = SESSION_STATUS_CONFIG[sessionStatus] ?? SESSION_STATUS_CONFIG.NOT_STARTED const jurors = liveDash?.jurors ?? [] const votedCount = jurors.filter((j: any) => j.hasVoted).length const standings = liveDash?.standings ?? [] const visibility = liveDash?.observerScoreVisibility ?? 'after_completion' const scoresVisible = visibility === 'realtime' || (visibility === 'after_completion' && sessionStatus === 'COMPLETED') return (
{/* Session Status Card */} {isLoading ? ( ) : (
{statusConfig.pulse && ( )}

{statusConfig.label}

{liveDash?.voteCount ?? stats?.voteCount ?? 0} votes cast

)} {/* Vote Count */}

{liveDash?.voteCount ?? stats?.voteCount ?? 0}

Total Votes

{votedCount}/{jurors.length}

Jurors Voted

{/* Juror Participation */} {jurors.length > 0 && ( Juror Participation
{jurors.map((j: any) => (
{j.name} {j.hasVoted ? 'Voted' : 'Pending'}
))}
)} {/* Standings / Score Visibility */} Standings {scoresVisible ? ( ) : ( )} {scoresVisible && standings.length > 0 ? (
{standings.map((s: any, i: number) => (
{i + 1}. {s.projectTitle}
{typeof s.score === 'number' ? s.score.toFixed(1) : s.score}
))}
) : (

{sessionStatus === 'COMPLETED' ? 'Scores are hidden by admin configuration.' : 'Scores will be revealed when voting completes.'}

)}
) }