"use client"
import { useState } from "react"
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 { Progress } from "@/components/ui/progress"
import {
Target,
Users,
Lightbulb,
Trophy,
Crown,
Award,
Camera,
ImageIcon,
ChevronLeft,
ChevronRight,
X,
Star,
MessageSquare,
BarChart3,
ExternalLink,
Eye,
Link,
FileText,
} from "lucide-react"
import type { Award as AwardType } from "@/types/competition"
interface AwardDetailDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
award: AwardType
}
// Judge scoring data - empty for production
const getJudgeScores = (awardId: string) => {
return []
}
// App links and reports data - empty for production
const getAppData = (awardId: string) => {
return {
appUrl: "",
demoUrl: "",
githubUrl: "",
reports: [],
}
}
export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDialogProps) {
const { competitions, judges, getTeamById, getProposalById } = useCompetition()
const [activeTab, setActiveTab] = useState("overview")
const [showPhotoGallery, setShowPhotoGallery] = useState(false)
const [currentPhotoIndex, setCurrentPhotoIndex] = useState(0)
const competition = competitions.find((c) => c.id === award.competitionId)
const judgeScores = getJudgeScores(award.id)
const appData = getAppData(award.id)
// Competition photos - empty for production
const getCompetitionPhotos = () => {
return []
}
const competitionPhotos = getCompetitionPhotos()
const getCompetitionTypeIcon = (type: string) => {
switch (type) {
case "individual":
return
case "team":
return
case "proposal":
return
default:
return
}
}
const getCompetitionTypeText = (type: string) => {
switch (type) {
case "individual":
return "個人賽"
case "team":
return "團隊賽"
case "proposal":
return "提案賽"
default:
return "競賽"
}
}
const getCompetitionTypeColor = (type: string) => {
switch (type) {
case "individual":
return "bg-blue-100 text-blue-800 border-blue-200"
case "team":
return "bg-green-100 text-green-800 border-green-200"
case "proposal":
return "bg-purple-100 text-purple-800 border-purple-200"
default:
return "bg-gray-100 text-gray-800 border-gray-200"
}
}
const getFileIcon = (type: string) => {
switch (type.toLowerCase()) {
case "pdf":
return
case "pptx":
case "ppt":
return
case "docx":
case "doc":
return
default:
return
}
}
const nextPhoto = () => {
setCurrentPhotoIndex((prev) => (prev + 1) % competitionPhotos.length)
}
const prevPhoto = () => {
setCurrentPhotoIndex((prev) => (prev - 1 + competitionPhotos.length) % competitionPhotos.length)
}
const handlePreview = (report: any) => {
// Open preview in new window
window.open(report.previewUrl, "_blank")
}
const renderAwardOverview = () => (
{award.icon}
{award.awardName}
{award.appName || award.proposalTitle || award.teamName}
{getCompetitionTypeIcon(award.competitionType)}
{getCompetitionTypeText(award.competitionType)}
{award.awardName}
{award.awardType === "popular" && award.competitionType === "team"
? `${award.score}`
: award.awardType === "popular"
? `${award.score}`
: award.score}
{award.competitionType === "proposal"
? "評審評分"
: award.awardType === "popular"
? award.competitionType === "team"
? "人氣指數"
: "收藏數"
: "評審評分"}
{award.year}年{award.month}月
獲獎時間
{award.creator}
{award.competitionType === "team"
? "團隊"
: award.competitionType === "proposal"
? "提案團隊"
: "創作者"}
{competition && (
競賽資訊
競賽名稱:
{competition.name}
競賽描述:
{competition.description}
競賽期間:
{competition.startDate} ~ {competition.endDate}
)}
{/* App Links Section */}
應用連結
相關應用和資源連結
{appData.appUrl && (
)}
{appData.demoUrl && (
)}
{appData.githubUrl && (
)}
{/* Reports Section */}
相關報告
技術文檔和報告資料(僅供預覽)
{appData.reports.map((report) => (
{getFileIcon(report.type)}
{report.name}
{report.description}
大小:{report.size}
上傳:{report.uploadDate}
{report.type}
))}
)
const renderCompetitionPhotos = () => (
競賽照片
競賽當天的精彩瞬間
{competitionPhotos.map((photo, index) => (
{
setCurrentPhotoIndex(index)
setShowPhotoGallery(true)
}}
>
))}
)
const renderJudgePanel = () => {
if (!competition) return null
return (
評審團
本次競賽的專業評審團隊
{competition.judges.map((judgeId) => {
const judge = judges.find((j) => j.id === judgeId)
if (!judge) return null
return (
{judge.name[0]}
{judge.name}
{judge.title}
{judge.expertise.slice(0, 2).map((skill) => (
{skill}
))}
)
})}
)
}
const renderJudgeScores = () => (
{/* Overall Statistics */}
評分統計
評審團整體評分概況
{(judgeScores.reduce((sum, score) => sum + score.overallScore, 0) / judgeScores.length).toFixed(1)}
平均分數
{Math.max(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
最高分數
{Math.min(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
最低分數
{judgeScores.length}
評審人數
{/* Individual Judge Scores */}
{judgeScores.map((judgeScore, index) => (
{judgeScore.judgeName[0]}
{judgeScore.judgeName}
{judgeScore.judgeTitle}
{judgeScore.overallScore}
/5.0
評分時間:{judgeScore.submittedAt}
{/* Criteria Scores */}
評分細項
{judgeScore.criteria.map((criterion, criterionIndex) => (
{criterion.name}
{criterion.score}/{criterion.maxScore}
))}
{/* Judge Comment */}
))}
)
return (
<>
{/* Photo Gallery Modal */}
>
)
}