"use client" import { useState } from "react" import { useCompetition } from "@/contexts/competition-context" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Textarea } from "@/components/ui/textarea" import { Badge } from "@/components/ui/badge" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Slider } from "@/components/ui/slider" import { Alert, AlertDescription } from "@/components/ui/alert" import { Star, User, Award, MessageSquare, CheckCircle } from "lucide-react" interface JudgeScoringDialogProps { open: boolean onOpenChange: (open: boolean) => void appId: string appName: string judgeId: string } export function JudgeScoringDialog({ open, onOpenChange, appId, appName, judgeId }: JudgeScoringDialogProps) { const { judges, submitJudgeScore, getAppJudgeScores } = useCompetition() const judge = judges.find((j) => j.id === judgeId) const existingScore = getAppJudgeScores(appId).find((s) => s.judgeId === judgeId) const [scores, setScores] = useState({ innovation: existingScore?.scores.innovation || 8, technical: existingScore?.scores.technical || 8, usability: existingScore?.scores.usability || 8, presentation: existingScore?.scores.presentation || 8, impact: existingScore?.scores.impact || 8, }) const [comments, setComments] = useState(existingScore?.comments || "") const [isSubmitting, setIsSubmitting] = useState(false) const [isSubmitted, setIsSubmitted] = useState(false) if (!judge) return null const handleScoreChange = (category: keyof typeof scores, value: number[]) => { setScores((prev) => ({ ...prev, [category]: value[0], })) } const handleSubmit = async () => { if (!comments.trim()) { return } setIsSubmitting(true) // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)) submitJudgeScore({ judgeId, appId, scores, comments: comments.trim(), }) setIsSubmitting(false) setIsSubmitted(true) // Auto close after success setTimeout(() => { setIsSubmitted(false) onOpenChange(false) }, 2000) } const totalScore = Object.values(scores).reduce((sum, score) => sum + score, 0) const averageScore = (totalScore / 5).toFixed(1) const scoreCategories = [ { key: "innovation" as const, name: "創新性", description: "技術創新程度和獨特性", icon: "💡", }, { key: "technical" as const, name: "技術性", description: "技術實現難度和完成度", icon: "⚙️", }, { key: "usability" as const, name: "實用性", description: "實際應用價值和用戶體驗", icon: "🎯", }, { key: "presentation" as const, name: "展示效果", description: "介面設計和展示完整性", icon: "🎨", }, { key: "impact" as const, name: "影響力", description: "對業務和用戶的潛在影響", icon: "🚀", }, ] if (isSubmitted) { return (

評分提交成功!

您對「{appName}」的評分已成功提交

) } return ( 評審評分 為「{appName}」進行專業評分
{/* Judge Info */}
{judge.name[0]}

{judge.name}

{judge.title}

{judge.expertise.map((skill) => ( {skill} ))}
{/* Scoring Categories */} 評分項目
{averageScore}
平均分數
請根據各項目標準進行評分(1-10分)
{scoreCategories.map((category) => (
{category.icon}

{category.name}

{category.description}

{scores[category.key]}
{[...Array(scores[category.key])].map((_, i) => ( ))}
handleScoreChange(category.key, value)} max={10} min={1} step={1} className="w-full" />
1分 (差) 5分 (普通) 10分 (優秀)
))}
{/* Comments */} 評審意見 請提供詳細的評審意見和建議