"use client" import { useState } from "react" import { useAuth } from "@/contexts/auth-context" import { useCompetition } from "@/contexts/competition-context" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Separator } from "@/components/ui/separator" import { Target, Users, Lightbulb, Star, Heart, Eye, Trophy, Crown, UserCheck, Building, Mail, Clock, CheckCircle, AlertCircle, MessageSquare, ImageIcon, Mic, TrendingUp, Brain, Zap, Play, } from "lucide-react" // AI applications data - empty for production const aiApps: any[] = [] interface CompetitionDetailDialogProps { open: boolean onOpenChange: (open: boolean) => void ranking: any competitionType: "individual" | "team" | "proposal" } export function CompetitionDetailDialog({ open, onOpenChange, ranking, competitionType, }: CompetitionDetailDialogProps) { const { user, getAppLikes, getViewCount, getAppRating, incrementViewCount, addToRecentApps } = useAuth() const { judges, getAppJudgeScores, getProposalJudgeScores, getTeamById, getProposalById, currentCompetition } = useCompetition() const [activeTab, setActiveTab] = useState("overview") const handleTryApp = (appId: string) => { incrementViewCount(appId) addToRecentApps(appId) console.log(`Opening app ${appId}`) } const getTypeColor = (type: string) => { const colors = { 文字處理: "bg-blue-100 text-blue-800 border-blue-200", 圖像生成: "bg-purple-100 text-purple-800 border-purple-200", 語音辨識: "bg-green-100 text-green-800 border-green-200", 推薦系統: "bg-orange-100 text-orange-800 border-orange-200", } return colors[type as keyof typeof colors] || "bg-gray-100 text-gray-800 border-gray-200" } const renderIndividualDetail = () => { const app = aiApps.find((a) => a.id === ranking.appId) const judgeScores = getAppJudgeScores(ranking.appId!) const likes = getAppLikes(ranking.appId!) const views = getViewCount(ranking.appId!) const rating = getAppRating(ranking.appId!) if (!app) return null const IconComponent = app.icon return ( 應用概覽 評審評分 立即體驗
{app.name} by {app.creator}
{app.type} {app.department}
第 {ranking.rank} 名

{app.description}

{ranking.totalScore.toFixed(1)}
總評分
{likes}
收藏數
{views}
瀏覽數
{rating.toFixed(1)}
用戶評分
{[ { key: "innovation", name: "創新性", icon: "💡", color: "text-yellow-600" }, { key: "technical", name: "技術性", icon: "⚙️", color: "text-blue-600" }, { key: "usability", name: "實用性", icon: "🎯", color: "text-green-600" }, { key: "presentation", name: "展示效果", icon: "🎨", color: "text-purple-600" }, { key: "impact", name: "影響力", icon: "🚀", color: "text-red-600" }, ].map((category) => (
{category.icon}
{ranking.scores[category.key as keyof typeof ranking.scores].toFixed(1)}
{category.name}
))}
評審評分詳情 各位評審的詳細評分和評語
{judgeScores.map((score) => { const judge = judges.find((j) => j.id === score.judgeId) if (!judge) return null const totalScore = Object.values(score.scores).reduce((sum, s) => sum + s, 0) / 5 return (
{judge.name[0]}

{judge.name}

{judge.title}

{judge.expertise.map((skill) => ( {skill} ))}
{totalScore.toFixed(1)}
總分
{[ { key: "innovation", name: "創新性", icon: "💡" }, { key: "technical", name: "技術性", icon: "⚙️" }, { key: "usability", name: "實用性", icon: "🎯" }, { key: "presentation", name: "展示效果", icon: "🎨" }, { key: "impact", name: "影響力", icon: "🚀" }, ].map((category) => (
{category.icon}
{score.scores[category.key as keyof typeof score.scores]}
{category.name}
))}
評審意見

{score.comments}

) })}
立即體驗應用 體驗這個獲獎的 AI 應用

{app.name}

{app.description}

) } const renderTeamDetail = () => { const team = getTeamById(ranking.teamId!) if (!team) return null return ( 團隊概覽 團隊成員 團隊應用
{team.name} 隊長:{team.members.find((m) => m.id === team.leader)?.name}
團隊賽 {team.department}
第 {ranking.rank} 名
{ranking.totalScore.toFixed(1)}
團隊評分
{team.apps.length}
提交應用
{team.totalLikes}
總按讚數
{team.members.length}
團隊成員
{team.department}
{team.contactEmail}
人氣指數: {Math.round((team.totalLikes / team.apps.length) * 10) / 10}
團隊成員 團隊所有成員的詳細資訊
{team.members.map((member) => (
{member.name[0]}

{member.name}

{member.id === team.leader && ( 隊長 )}

{member.role}

{member.department}
))}
團隊應用 團隊提交的所有應用
{team.apps.map((appId) => { const app = aiApps.find((a) => a.id === appId) if (!app) return null const IconComponent = app.icon const likes = getAppLikes(appId) const views = getViewCount(appId) const rating = getAppRating(appId) return (
{app.name} by {app.creator}

{app.description}

{likes}
{views}
{rating.toFixed(1)}
) })}
) } const renderProposalDetail = () => { const proposal = getProposalById(ranking.proposalId!) const team = ranking.team const judgeScores = getProposalJudgeScores(ranking.proposalId!) if (!proposal) return null return ( 提案概覽 評審評分 提案團隊
{proposal.title} 提案團隊:{team?.name}
提案賽
第 {ranking.rank} 名
{ranking.totalScore.toFixed(1)}
總評分
痛點描述

{proposal.problemStatement}

解決方案

{proposal.solution}

預期影響

{proposal.expectedImpact}

{[ { key: "problemIdentification", name: "問題識別", icon: "🔍", color: "text-red-600" }, { key: "solutionFeasibility", name: "方案可行性", icon: "⚙️", color: "text-blue-600" }, { key: "innovation", name: "創新性", icon: "💡", color: "text-yellow-600" }, { key: "impact", name: "預期影響", icon: "🚀", color: "text-green-600" }, { key: "presentation", name: "展示效果", icon: "🎨", color: "text-purple-600" }, ].map((category) => (
{category.icon}
{ranking.scores[category.key as keyof typeof ranking.scores].toFixed(1)}
{category.name}
))}
評審評分詳情 各位評審對提案的詳細評分和評語
{judgeScores.map((score) => { const judge = judges.find((j) => j.id === score.judgeId) if (!judge) return null const totalScore = Object.values(score.scores).reduce((sum, s) => sum + s, 0) / 5 return (
{judge.name[0]}

{judge.name}

{judge.title}

{judge.expertise.map((skill) => ( {skill} ))}
{totalScore.toFixed(1)}
總分
{[ { key: "problemIdentification", name: "問題識別", icon: "🔍" }, { key: "solutionFeasibility", name: "方案可行性", icon: "⚙️" }, { key: "innovation", name: "創新性", icon: "💡" }, { key: "impact", name: "預期影響", icon: "🚀" }, { key: "presentation", name: "展示效果", icon: "🎨" }, ].map((category) => (
{category.icon}
{score.scores[category.key as keyof typeof score.scores]}
{category.name}
))}
評審意見

{score.comments}

) })}
{team && ( 提案團隊 提案團隊的詳細資訊

{team.name}

{team.department}
{team.contactEmail}
提交於 {new Date(proposal.submittedAt).toLocaleDateString()}
{team.members.map((member) => (
{member.name[0]}

{member.name}

{member.id === team.leader && ( 隊長 )}

{member.role}

{member.department}
))}
)}
) } return ( {competitionType === "individual" && "個人賽詳情"} {competitionType === "team" && "團隊賽詳情"} {competitionType === "proposal" && "提案賽詳情"} {currentCompetition?.name} - 第 {ranking.rank} 名
{competitionType === "individual" && renderIndividualDetail()} {competitionType === "team" && renderTeamDetail()} {competitionType === "proposal" && renderProposalDetail()}
) }