'use client' import { useState } from 'react' import { useParams, useSearchParams } from 'next/navigation' import Link from 'next/link' import { trpc } from '@/lib/trpc/client' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Textarea } from '@/components/ui/textarea' import { Badge } from '@/components/ui/badge' import { Skeleton } from '@/components/ui/skeleton' import { ArrowLeft, BarChart3, MessageSquare, Send, Loader2, Lock, User, } from 'lucide-react' import { toast } from 'sonner' import { formatDate, cn, getInitials } from '@/lib/utils' export default function DiscussionPage() { const params = useParams() const searchParams = useSearchParams() const projectId = params.id as string const roundId = searchParams.get('roundId') || '' const [commentText, setCommentText] = useState('') const utils = trpc.useUtils() // Fetch peer summary const { data: peerSummary, isLoading: loadingSummary } = trpc.evaluation.getPeerSummary.useQuery( { projectId, roundId }, { enabled: !!roundId } ) // Fetch discussion thread const { data: discussion, isLoading: loadingDiscussion } = trpc.evaluation.getDiscussion.useQuery( { projectId, roundId }, { enabled: !!roundId } ) // Add comment mutation const addCommentMutation = trpc.evaluation.addComment.useMutation({ onSuccess: () => { utils.evaluation.getDiscussion.invalidate({ projectId, roundId }) toast.success('Comment added') setCommentText('') }, onError: (e) => toast.error(e.message), }) const handleSubmitComment = () => { if (!commentText.trim()) { toast.error('Please enter a comment') return } addCommentMutation.mutate({ projectId, roundId, content: commentText.trim(), }) } const isLoading = loadingSummary || loadingDiscussion if (!roundId) { return (
No round specified
Please access the discussion from your assignments page.
Peer review discussion and anonymized score summary
{averageScore.toFixed(1)}
Average Score
{scoreRange ? `${scoreRange.min.toFixed(1)} - ${scoreRange.max.toFixed(1)}` : '--'}
Score Range
{evaluationCount}
Evaluations
Anonymized Individual Scores
{comment.content}
No comments yet. Be the first to start the discussion.
This discussion is closed and no longer accepts new comments.