修正獎勵評審資訊、評分資訊
This commit is contained in:
@@ -149,9 +149,12 @@ export async function GET(request: NextRequest) {
|
||||
competitionId: award.competition_id,
|
||||
competitionName: (award as any).competition_name,
|
||||
competitionType: (award as any).competition_type,
|
||||
competitionDescription: (award as any).competition_description,
|
||||
competitionStartDate: (award as any).competition_start_date,
|
||||
competitionEndDate: (award as any).competition_end_date,
|
||||
awardName: award.award_name,
|
||||
awardType: award.award_type,
|
||||
teamName: award.team_name,
|
||||
teamName: (award as any).team_name_from_teams || award.team_name,
|
||||
appName: award.app_name,
|
||||
applicationLinks: award.application_links ? JSON.parse(award.application_links) : null,
|
||||
documents: award.documents ? JSON.parse(award.documents) : [],
|
||||
|
211
app/api/awards/[id]/scores/route.ts
Normal file
211
app/api/awards/[id]/scores/route.ts
Normal file
@@ -0,0 +1,211 @@
|
||||
// =====================================================
|
||||
// 獲取獎項評分詳情 API
|
||||
// =====================================================
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { db } from '@/lib/database';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const awardId = params.id;
|
||||
|
||||
console.log('🔍 獲取獎項評分詳情:', awardId);
|
||||
|
||||
// 先獲取獎項資訊
|
||||
const awardSql = 'SELECT * FROM awards WHERE id = ?';
|
||||
console.log('🔍 執行 SQL:', awardSql, '參數:', [awardId]);
|
||||
|
||||
const award = await db.queryOne(awardSql, [awardId]);
|
||||
console.log('📊 查詢結果:', award);
|
||||
|
||||
if (!award) {
|
||||
console.log('❌ 找不到獎項:', awardId);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '找不到指定的獎項',
|
||||
data: []
|
||||
});
|
||||
}
|
||||
|
||||
console.log('📊 獎項資訊:', {
|
||||
id: award.id,
|
||||
competitionType: award.competition_type,
|
||||
appId: award.app_id,
|
||||
proposalId: award.proposal_id
|
||||
});
|
||||
|
||||
let scores = [];
|
||||
|
||||
// 根據競賽類型查詢對應的評分表
|
||||
if (award.competition_type === 'individual' && award.app_id) {
|
||||
// 查詢 app_judge_scores
|
||||
const sql = `
|
||||
SELECT
|
||||
ajs.*,
|
||||
j.name as judge_name,
|
||||
j.title as judge_title,
|
||||
j.avatar as judge_avatar,
|
||||
j.department as judge_department
|
||||
FROM app_judge_scores ajs
|
||||
LEFT JOIN judges j ON ajs.judge_id = j.id
|
||||
WHERE ajs.app_id = ?
|
||||
ORDER BY ajs.created_at DESC
|
||||
`;
|
||||
console.log('🔍 執行個人賽 SQL:', sql, '參數:', [award.app_id]);
|
||||
scores = await db.query(sql, [award.app_id]);
|
||||
console.log('📊 從 app_judge_scores 獲取到:', scores.length, '筆');
|
||||
} else if (award.competition_type === 'proposal' && award.proposal_id) {
|
||||
// 查詢 proposal_judge_scores
|
||||
const sql = `
|
||||
SELECT
|
||||
pjs.*,
|
||||
j.name as judge_name,
|
||||
j.title as judge_title,
|
||||
j.avatar as judge_avatar,
|
||||
j.department as judge_department
|
||||
FROM proposal_judge_scores pjs
|
||||
LEFT JOIN judges j ON pjs.judge_id = j.id
|
||||
WHERE pjs.proposal_id = ?
|
||||
ORDER BY pjs.created_at DESC
|
||||
`;
|
||||
console.log('🔍 執行提案賽 SQL:', sql, '參數:', [award.proposal_id]);
|
||||
scores = await db.query(sql, [award.proposal_id]);
|
||||
console.log('📊 從 proposal_judge_scores 獲取到:', scores.length, '筆');
|
||||
} else if (award.competition_type === 'team' && award.app_id) {
|
||||
// 查詢 judge_scores (團隊賽)
|
||||
const sql = `
|
||||
SELECT
|
||||
js.*,
|
||||
j.name as judge_name,
|
||||
j.title as judge_title,
|
||||
j.avatar as judge_avatar,
|
||||
j.department as judge_department
|
||||
FROM judge_scores js
|
||||
LEFT JOIN judges j ON js.judge_id = j.id
|
||||
WHERE js.app_id = ?
|
||||
ORDER BY js.submitted_at DESC
|
||||
`;
|
||||
console.log('🔍 執行團隊賽 SQL:', sql, '參數:', [award.app_id]);
|
||||
scores = await db.query(sql, [award.app_id]);
|
||||
console.log('📊 從 judge_scores 獲取到:', scores.length, '筆');
|
||||
} else {
|
||||
console.log('❌ 無法確定評分表類型:', {
|
||||
competitionType: award.competition_type,
|
||||
hasAppId: !!award.app_id,
|
||||
hasProposalId: !!award.proposal_id,
|
||||
hasTeamId: !!award.team_id
|
||||
});
|
||||
}
|
||||
|
||||
// 處理評分資料
|
||||
const processedScores = scores.map((score: any) => {
|
||||
// 根據不同的評分表處理不同的欄位
|
||||
let overallScore = 0;
|
||||
let criteria: Array<{name: string, score: number, maxScore: number}> = [];
|
||||
|
||||
if (award.competition_type === 'individual') {
|
||||
// app_judge_scores 的處理
|
||||
overallScore = score.total_score || 0;
|
||||
criteria = [
|
||||
{ name: '創新性', score: score.innovation_score, maxScore: 10 },
|
||||
{ name: '技術性', score: score.technical_score, maxScore: 10 },
|
||||
{ name: '可用性', score: score.usability_score, maxScore: 10 },
|
||||
{ name: '展示性', score: score.presentation_score, maxScore: 10 },
|
||||
{ name: '影響力', score: score.impact_score, maxScore: 10 }
|
||||
];
|
||||
} else if (award.competition_type === 'proposal') {
|
||||
// proposal_judge_scores 的處理
|
||||
overallScore = score.total_score || 0;
|
||||
criteria = [
|
||||
{ name: '問題識別', score: score.problem_identification_score, maxScore: 10 },
|
||||
{ name: '解決方案可行性', score: score.solution_feasibility_score, maxScore: 10 },
|
||||
{ name: '創新性', score: score.innovation_score, maxScore: 10 },
|
||||
{ name: '影響力', score: score.impact_score, maxScore: 10 },
|
||||
{ name: '展示性', score: score.presentation_score, maxScore: 10 }
|
||||
];
|
||||
} else if (award.competition_type === 'team') {
|
||||
// judge_scores (團隊賽) 的處理
|
||||
overallScore = score.overall_score || score.total_score || 0;
|
||||
// 嘗試解析 criteria 欄位,如果沒有則使用預設的團隊評分標準
|
||||
if (score.criteria) {
|
||||
try {
|
||||
criteria = typeof score.criteria === 'string'
|
||||
? JSON.parse(score.criteria)
|
||||
: score.criteria;
|
||||
} catch (e) {
|
||||
console.error('解析 criteria 失敗:', e);
|
||||
criteria = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 如果沒有 criteria 或解析失敗,使用預設的團隊評分標準
|
||||
if (!criteria || criteria.length === 0) {
|
||||
criteria = [
|
||||
{ name: '團隊合作', score: score.teamwork_score || 0, maxScore: 10 },
|
||||
{ name: '創新性', score: score.innovation_score || 0, maxScore: 10 },
|
||||
{ name: '技術實作', score: score.technical_score || 0, maxScore: 10 },
|
||||
{ name: '展示能力', score: score.presentation_score || 0, maxScore: 10 },
|
||||
{ name: '整體表現', score: score.overall_performance || 0, maxScore: 10 }
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: score.id,
|
||||
awardId: awardId,
|
||||
judgeId: score.judge_id,
|
||||
judgeName: score.judge_name || '未知評審',
|
||||
judgeTitle: score.judge_title || '評審',
|
||||
judgeAvatar: score.judge_avatar,
|
||||
judgeDepartment: score.judge_department,
|
||||
overallScore: overallScore,
|
||||
submittedAt: score.submitted_at || score.created_at,
|
||||
comment: score.comment || score.comments || '',
|
||||
criteria: criteria,
|
||||
};
|
||||
});
|
||||
|
||||
console.log('✅ 處理後的評分資料:', processedScores.length, '筆');
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '評分詳情獲取成功',
|
||||
data: processedScores
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 獲取評分詳情失敗:', error);
|
||||
console.error('❌ 錯誤詳情:', {
|
||||
message: error instanceof Error ? error.message : '未知錯誤',
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
awardId: params.id
|
||||
});
|
||||
|
||||
// 檢查評分表是否存在
|
||||
try {
|
||||
const tableCheck = await db.query("SHOW TABLES LIKE 'judge_scores'");
|
||||
console.log('🔍 judge_scores 表存在檢查:', tableCheck);
|
||||
|
||||
if (tableCheck.length > 0) {
|
||||
// 檢查表結構
|
||||
const structure = await db.query("DESCRIBE judge_scores");
|
||||
console.log('🔍 judge_scores 表結構:', structure);
|
||||
}
|
||||
} catch (tableError) {
|
||||
console.error('❌ 檢查表存在性失敗:', tableError);
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '獲取評分詳情失敗',
|
||||
error: error instanceof Error ? error.message : '未知錯誤',
|
||||
details: {
|
||||
awardId: params.id,
|
||||
errorType: error instanceof Error ? error.constructor.name : 'Unknown'
|
||||
}
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
@@ -451,7 +451,10 @@ export default function CompetitionPage() {
|
||||
</div>
|
||||
|
||||
<CardTitle className="text-lg line-clamp-2">
|
||||
{award.appName || award.proposalTitle || award.teamName}
|
||||
{award.competitionType === "team"
|
||||
? (award.teamName || "團隊名稱")
|
||||
: (award.appName || award.proposalTitle || "應用名稱")
|
||||
}
|
||||
</CardTitle>
|
||||
<p className="text-sm text-gray-500">by {award.creator}</p>
|
||||
<div className="text-xs text-gray-400">
|
||||
|
37
app/page.tsx
37
app/page.tsx
@@ -148,7 +148,7 @@ export default function AIShowcasePlatform() {
|
||||
canAccessAdmin,
|
||||
} = useAuth()
|
||||
|
||||
const { competitions, awards, getAwardsByYear, getCompetitionRankings } = useCompetition()
|
||||
const { competitions, awards, getAwardsByYear, getCompetitionRankings, loadingAwards, getAvailableYears } = useCompetition()
|
||||
|
||||
const [showLogin, setShowLogin] = useState(false)
|
||||
const [showRegister, setShowRegister] = useState(false)
|
||||
@@ -193,6 +193,17 @@ export default function AIShowcasePlatform() {
|
||||
showAwardDetail
|
||||
});
|
||||
|
||||
// 動態設定初始年份
|
||||
useEffect(() => {
|
||||
if (awards.length > 0 && selectedYear === 2024) {
|
||||
const availableYears = getAvailableYears();
|
||||
if (availableYears.length > 0) {
|
||||
setSelectedYear(availableYears[0]);
|
||||
console.log('🎯 自動設定年份為:', availableYears[0]);
|
||||
}
|
||||
}
|
||||
}, [awards, selectedYear, getAvailableYears]);
|
||||
|
||||
// 載入應用數據
|
||||
const loadApps = async () => {
|
||||
try {
|
||||
@@ -595,8 +606,11 @@ export default function AIShowcasePlatform() {
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="2024">2024年</SelectItem>
|
||||
<SelectItem value="2023">2023年</SelectItem>
|
||||
{getAvailableYears().map((year) => (
|
||||
<SelectItem key={year} value={year.toString()}>
|
||||
{year}年
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
@@ -720,24 +734,26 @@ export default function AIShowcasePlatform() {
|
||||
{/* Statistics */}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mt-4">
|
||||
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
||||
<div className="text-lg font-bold text-blue-600">{filteredAwards.length}</div>
|
||||
<div className="text-lg font-bold text-blue-600">
|
||||
{loadingAwards ? '...' : filteredAwards.length}
|
||||
</div>
|
||||
<div className="text-xs text-blue-600">總獎項數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-yellow-50 rounded-lg">
|
||||
<div className="text-lg font-bold text-yellow-600">
|
||||
{filteredAwards.filter((a) => a.rank > 0 && a.rank <= 3).length}
|
||||
{loadingAwards ? '...' : filteredAwards.filter((a) => a.rank > 0 && a.rank <= 3).length}
|
||||
</div>
|
||||
<div className="text-xs text-yellow-600">前三名獎項</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-red-50 rounded-lg">
|
||||
<div className="text-lg font-bold text-red-600">
|
||||
{filteredAwards.filter((a) => a.awardType === "popular").length}
|
||||
{loadingAwards ? '...' : filteredAwards.filter((a) => a.awardType === "popular").length}
|
||||
</div>
|
||||
<div className="text-xs text-red-600">人氣獎項</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-green-50 rounded-lg">
|
||||
<div className="text-lg font-bold text-green-600">
|
||||
{new Set(filteredAwards.map((a) => `${a.year}-${a.month}`)).size}
|
||||
{loadingAwards ? '...' : new Set(filteredAwards.map((a) => `${a.year}-${a.month}`)).size}
|
||||
</div>
|
||||
<div className="text-xs text-green-600">競賽場次</div>
|
||||
</div>
|
||||
@@ -747,7 +763,12 @@ export default function AIShowcasePlatform() {
|
||||
</Card>
|
||||
|
||||
{/* Awards Grid with Enhanced Display */}
|
||||
{filteredAwards.length > 0 ? (
|
||||
{loadingAwards ? (
|
||||
<div className="text-center py-12">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入獎項資料中...</p>
|
||||
</div>
|
||||
) : filteredAwards.length > 0 ? (
|
||||
<div className="space-y-8">
|
||||
{/* Group awards by month */}
|
||||
{Array.from(new Set(filteredAwards.map((award) => award.month)))
|
||||
|
@@ -7877,14 +7877,14 @@ export function CompetitionManagement() {
|
||||
if (value === "custom-input") {
|
||||
setNewAward({ ...newAward, customAwardTypeId: "", awardName: "" })
|
||||
} else {
|
||||
// 檢查是否為自定義獎項類型
|
||||
const customAwardType = competitionAwardTypes.find(type => type.id === value)
|
||||
if (customAwardType) {
|
||||
setNewAward({
|
||||
...newAward,
|
||||
customAwardTypeId: value,
|
||||
awardName: customAwardType.name
|
||||
})
|
||||
// 檢查是否為自定義獎項類型
|
||||
const customAwardType = competitionAwardTypes.find(type => type.id === value)
|
||||
if (customAwardType) {
|
||||
setNewAward({
|
||||
...newAward,
|
||||
customAwardTypeId: value,
|
||||
awardName: customAwardType.name
|
||||
})
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -7896,12 +7896,12 @@ export function CompetitionManagement() {
|
||||
<SelectContent>
|
||||
<SelectItem value="custom-input">自定義輸入</SelectItem>
|
||||
{competitionAwardTypes.map((awardType) => (
|
||||
<SelectItem key={awardType.id} value={awardType.id}>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>{awardType.icon}</span>
|
||||
<span>{awardType.name}</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem key={awardType.id} value={awardType.id}>
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>{awardType.icon}</span>
|
||||
<span>{awardType.name}</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
908
components/competition/award-detail-dialog-backup.tsx
Normal file
908
components/competition/award-detail-dialog-backup.tsx
Normal file
@@ -0,0 +1,908 @@
|
||||
"use client"
|
||||
|
||||
import { useState, useEffect } 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,
|
||||
Download,
|
||||
} from "lucide-react"
|
||||
import type { Award as AwardType } from "@/types/competition"
|
||||
|
||||
interface AwardDetailDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
award: AwardType
|
||||
}
|
||||
|
||||
// Judge scoring data - will be loaded from API
|
||||
|
||||
// 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 [competitionJudges, setCompetitionJudges] = useState<any[]>([])
|
||||
const [judgeScores, setJudgeScores] = useState<any[]>([])
|
||||
const [loadingScores, setLoadingScores] = useState(false)
|
||||
|
||||
// 添加調試資訊
|
||||
console.log('🏆 AwardDetailDialog 渲染:', {
|
||||
open,
|
||||
award: award ? {
|
||||
id: award.id,
|
||||
competitionId: award.competitionId,
|
||||
awardName: award.awardName,
|
||||
hasCompetitionId: !!award.competitionId
|
||||
} : null
|
||||
});
|
||||
|
||||
const competition = competitions.find((c) => c.id === award.competitionId)
|
||||
const appData = getAppData(award.id)
|
||||
|
||||
// 載入競賽評審團資訊
|
||||
useEffect(() => {
|
||||
console.log('🔍 useEffect 觸發:', { open, competitionId: award.competitionId, awardId: award.id });
|
||||
|
||||
if (open && award.competitionId) {
|
||||
const loadCompetitionJudges = async (retryCount = 0) => {
|
||||
try {
|
||||
console.log('🔍 載入競賽評審團:', award.competitionId, '重試次數:', retryCount);
|
||||
console.log('🏆 獎項資料:', award);
|
||||
|
||||
// 添加時間戳防止快取,並設置快取控制標頭
|
||||
const timestamp = Date.now();
|
||||
const apiUrl = `/api/competitions/${award.competitionId}/judges?t=${timestamp}`;
|
||||
console.log('🌐 API URL:', apiUrl);
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('📡 API 回應狀態:', response.status);
|
||||
console.log('📡 API 回應標頭:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error('❌ API 錯誤回應:', errorText);
|
||||
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📄 API 回應資料:', JSON.stringify(data, null, 2));
|
||||
|
||||
if (data.success && data.data && data.data.judges) {
|
||||
console.log('✅ 獲取到評審團:', data.data.judges.length, '位');
|
||||
console.log('👥 評審團詳細資料:', data.data.judges);
|
||||
setCompetitionJudges(data.data.judges);
|
||||
} else {
|
||||
console.error('❌ 獲取評審團失敗:', data.message || '未知錯誤');
|
||||
console.error('❌ 完整錯誤資料:', data);
|
||||
|
||||
// 如果沒有評審資料且是第一次嘗試,重試一次
|
||||
if (retryCount === 0) {
|
||||
console.log('🔄 重試載入評審團...');
|
||||
setTimeout(() => loadCompetitionJudges(1), 1000);
|
||||
} else {
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評審團失敗:', error);
|
||||
|
||||
// 如果是網路錯誤且是第一次嘗試,重試一次
|
||||
if (retryCount === 0) {
|
||||
console.log('🔄 網路錯誤,重試載入評審團...');
|
||||
setTimeout(() => loadCompetitionJudges(1), 2000);
|
||||
} else {
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 清空之前的評審資料,確保重新載入
|
||||
setCompetitionJudges([]);
|
||||
loadCompetitionJudges();
|
||||
} else {
|
||||
console.log('❌ useEffect 條件不滿足:', {
|
||||
open,
|
||||
competitionId: award.competitionId,
|
||||
hasCompetitionId: !!award.competitionId
|
||||
});
|
||||
}
|
||||
}, [open, award.competitionId]);
|
||||
|
||||
// 載入評分詳情
|
||||
useEffect(() => {
|
||||
if (open && award.id) {
|
||||
const loadJudgeScores = async () => {
|
||||
try {
|
||||
setLoadingScores(true);
|
||||
console.log('🔍 載入評分詳情:', award.id);
|
||||
|
||||
const response = await fetch(`/api/awards/${award.id}/scores`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
console.log('✅ 載入評分詳情成功:', data.data.length, '筆');
|
||||
setJudgeScores(data.data);
|
||||
} else {
|
||||
console.error('❌ 載入評分詳情失敗:', data.message);
|
||||
setJudgeScores([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評分詳情錯誤:', error);
|
||||
setJudgeScores([]);
|
||||
} finally {
|
||||
setLoadingScores(false);
|
||||
}
|
||||
};
|
||||
|
||||
loadJudgeScores();
|
||||
} else {
|
||||
setJudgeScores([]);
|
||||
}
|
||||
}, [open, award.id]);
|
||||
|
||||
// Competition photos - empty for production
|
||||
const getCompetitionPhotos = () => {
|
||||
return []
|
||||
}
|
||||
|
||||
const competitionPhotos = getCompetitionPhotos()
|
||||
|
||||
const getCompetitionTypeIcon = (type: string) => {
|
||||
switch (type) {
|
||||
case "individual":
|
||||
return <Target className="w-4 h-4" />
|
||||
case "team":
|
||||
return <Users className="w-4 h-4" />
|
||||
case "proposal":
|
||||
return <Lightbulb className="w-4 h-4" />
|
||||
default:
|
||||
return <Trophy className="w-4 h-4" />
|
||||
}
|
||||
}
|
||||
|
||||
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 <FileText className="w-5 h-5 text-red-500" />
|
||||
case "pptx":
|
||||
case "ppt":
|
||||
return <FileText className="w-5 h-5 text-orange-500" />
|
||||
case "docx":
|
||||
case "doc":
|
||||
return <FileText className="w-5 h-5 text-blue-500" />
|
||||
default:
|
||||
return <FileText className="w-5 h-5 text-gray-500" />
|
||||
}
|
||||
}
|
||||
|
||||
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 = () => (
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<div className="text-6xl">{award.icon}</div>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-2xl">{award.awardName}</CardTitle>
|
||||
<CardDescription className="text-lg">
|
||||
{award.appName || award.proposalTitle || award.teamName}
|
||||
</CardDescription>
|
||||
<div className="flex items-center space-x-4 mt-2">
|
||||
<Badge variant="outline" className={getCompetitionTypeColor(award.competitionType)}>
|
||||
{getCompetitionTypeIcon(award.competitionType)}
|
||||
<span className="ml-1">{getCompetitionTypeText(award.competitionType)}</span>
|
||||
</Badge>
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className={`${
|
||||
award.awardType === "gold"
|
||||
? "bg-yellow-100 text-yellow-800 border-yellow-200"
|
||||
: award.awardType === "silver"
|
||||
? "bg-gray-100 text-gray-800 border-gray-200"
|
||||
: award.awardType === "bronze"
|
||||
? "bg-orange-100 text-orange-800 border-orange-200"
|
||||
: "bg-red-100 text-red-800 border-red-200"
|
||||
}`}
|
||||
>
|
||||
{award.awardName}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-3 gap-6 mb-6">
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600 mb-1">
|
||||
{award.awardType === "popular" && award.competitionType === "team"
|
||||
? `${award.score}`
|
||||
: award.awardType === "popular"
|
||||
? `${award.score}`
|
||||
: award.score}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{award.competitionType === "proposal"
|
||||
? "評審評分"
|
||||
: award.awardType === "popular"
|
||||
? award.competitionType === "team"
|
||||
? "人氣指數"
|
||||
: "收藏數"
|
||||
: "評審評分"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600 mb-1">
|
||||
{award.year}年{award.month}月
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">獲獎時間</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600 mb-1">{award.creator}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{award.competitionType === "team"
|
||||
? "團隊"
|
||||
: award.competitionType === "proposal"
|
||||
? "提案團隊"
|
||||
: "創作者"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||
<h4 className="font-semibold text-blue-900 mb-2 flex items-center">
|
||||
<Trophy className="w-5 h-5 mr-2" />
|
||||
競賽資訊
|
||||
</h4>
|
||||
<div className="text-blue-800">
|
||||
<p className="mb-2">
|
||||
<strong>競賽名稱:</strong>
|
||||
{award.competitionName || competition?.name || '未知競賽'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽描述:</strong>
|
||||
{award.competitionDescription || competition?.description || '暫無描述'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽期間:</strong>
|
||||
{award.competitionStartDate && award.competitionEndDate
|
||||
? `${award.competitionStartDate} ~ ${award.competitionEndDate}`
|
||||
: competition?.startDate && competition?.endDate
|
||||
? `${competition.startDate} ~ ${competition.endDate}`
|
||||
: '暫無時間資訊'
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
<strong>評審團:</strong>
|
||||
{competitionJudges && competitionJudges.length > 0 ? (
|
||||
<span className="text-green-700">
|
||||
{competitionJudges.length} 位評審
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-gray-500">暫無評審信息</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* App Links Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Link className="w-5 h-5 text-green-500" />
|
||||
<span>應用連結</span>
|
||||
</CardTitle>
|
||||
<CardDescription>相關應用和資源連結</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{(() => {
|
||||
// 解析 application_links 資料
|
||||
let applicationLinks = null;
|
||||
if (award.applicationLinks) {
|
||||
applicationLinks = award.applicationLinks;
|
||||
} else if (award.application_links) {
|
||||
try {
|
||||
applicationLinks = typeof award.application_links === 'string'
|
||||
? JSON.parse(award.application_links)
|
||||
: award.application_links;
|
||||
} catch (e) {
|
||||
console.error('解析 application_links 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!applicationLinks) {
|
||||
return (
|
||||
<div className="col-span-full text-center py-8 text-gray-500">
|
||||
<Link className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無應用連結</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{applicationLinks.production && (
|
||||
<div className="flex items-center justify-between p-3 bg-green-50 border border-green-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<ExternalLink className="w-5 h-5 text-green-600" />
|
||||
<div>
|
||||
<p className="font-medium text-green-800">正式應用</p>
|
||||
<p className="text-xs text-green-600">APP 連結</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-green-300 text-green-700 hover:bg-green-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.production, "_blank")}
|
||||
>
|
||||
訪問
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.demo && (
|
||||
<div className="flex items-center justify-between p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Eye className="w-5 h-5 text-blue-600" />
|
||||
<div>
|
||||
<p className="font-medium text-blue-800">演示版本</p>
|
||||
<p className="text-xs text-blue-600">體驗環境</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-blue-300 text-blue-700 hover:bg-blue-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.demo, "_blank")}
|
||||
>
|
||||
體驗
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.github && (
|
||||
<div className="flex items-center justify-between p-3 bg-gray-50 border border-gray-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<FileText className="w-5 h-5 text-gray-600" />
|
||||
<div>
|
||||
<p className="font-medium text-gray-800">源碼倉庫</p>
|
||||
<p className="text-xs text-gray-600">GitHub</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-gray-300 text-gray-700 hover:bg-gray-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.github, "_blank")}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Reports Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<FileText className="w-5 h-5 text-purple-500" />
|
||||
<span>相關報告</span>
|
||||
</CardTitle>
|
||||
<CardDescription>技術文檔和報告資料(僅供預覽)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-3">
|
||||
{(() => {
|
||||
// 解析 documents 資料
|
||||
let documents = [];
|
||||
if (award.documents) {
|
||||
documents = award.documents;
|
||||
} else if (award.documents) {
|
||||
try {
|
||||
documents = typeof award.documents === 'string'
|
||||
? JSON.parse(award.documents)
|
||||
: award.documents;
|
||||
} catch (e) {
|
||||
console.error('解析 documents 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!documents || documents.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<FileText className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無相關文件</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return documents.map((doc, index) => (
|
||||
<div
|
||||
key={doc.id || index}
|
||||
className="flex items-center justify-between p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<div className="flex items-center space-x-4">
|
||||
{getFileIcon(doc.type)}
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium text-gray-900">{doc.name || doc.title}</h4>
|
||||
<p className="text-sm text-gray-600">{doc.description}</p>
|
||||
<div className="flex items-center space-x-4 mt-1 text-xs text-gray-500">
|
||||
<span>大小:{doc.size}</span>
|
||||
<span>上傳:{doc.uploadDate || doc.upload_date}</span>
|
||||
<span className="uppercase">{doc.type}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
{doc.previewUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.previewUrl, "_blank")}
|
||||
className="text-blue-600 border-blue-300 hover:bg-blue-50"
|
||||
>
|
||||
<Eye className="w-4 h-4 mr-1" />
|
||||
預覽
|
||||
</Button>
|
||||
)}
|
||||
{doc.downloadUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.downloadUrl, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
{doc.url && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.url, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
));
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
|
||||
const renderCompetitionPhotos = () => (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Camera className="w-5 h-5 text-purple-500" />
|
||||
<span>競賽照片</span>
|
||||
</CardTitle>
|
||||
<CardDescription>競賽當天的精彩瞬間</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-4">
|
||||
{competitionPhotos.map((photo, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="relative group cursor-pointer overflow-hidden rounded-lg border hover:shadow-lg transition-all"
|
||||
onClick={() => {
|
||||
setCurrentPhotoIndex(index)
|
||||
setShowPhotoGallery(true)
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={photo.url || "/placeholder.svg"}
|
||||
alt={photo.title}
|
||||
className="w-full h-32 object-cover group-hover:scale-105 transition-transform"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all flex items-center justify-center">
|
||||
<ImageIcon className="w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity" />
|
||||
</div>
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black to-transparent p-2">
|
||||
<p className="text-white text-xs font-medium">{photo.title}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 text-center">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setCurrentPhotoIndex(0)
|
||||
setShowPhotoGallery(true)
|
||||
}}
|
||||
>
|
||||
<Camera className="w-4 h-4 mr-2" />
|
||||
查看所有照片
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
const renderJudgePanel = () => {
|
||||
if (!competitionJudges || competitionJudges.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Crown className="w-5 h-5 text-purple-500" />
|
||||
<span>評審團</span>
|
||||
</CardTitle>
|
||||
<CardDescription>本次競賽的專業評審團隊</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<Crown className="w-12 h-12 mx-auto mb-4 text-gray-300" />
|
||||
<p>暫無評審信息</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Crown className="w-5 h-5 text-purple-500" />
|
||||
<span>評審團</span>
|
||||
</CardTitle>
|
||||
<CardDescription>本次競賽的專業評審團隊</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{competitionJudges.map((judge) => (
|
||||
<div key={judge.id} className="flex items-center space-x-3 p-3 bg-gray-50 rounded-lg">
|
||||
<Avatar>
|
||||
<AvatarImage src={judge.avatar} />
|
||||
<AvatarFallback className="bg-purple-100 text-purple-700">{judge.name[0]}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium">{judge.name}</h4>
|
||||
<p className="text-sm text-gray-600">{judge.title}</p>
|
||||
<div className="flex flex-wrap gap-1 mt-1">
|
||||
{judge.expertise && judge.expertise.slice(0, 2).map((skill) => (
|
||||
<Badge key={skill} variant="secondary" className="text-xs">
|
||||
{skill}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
}
|
||||
|
||||
const renderJudgeScores = () => (
|
||||
<div className="space-y-6">
|
||||
{/* Overall Statistics */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<BarChart3 className="w-5 h-5 text-blue-500" />
|
||||
<span>評分統計</span>
|
||||
</CardTitle>
|
||||
<CardDescription>評審團整體評分概況</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評分資料中...</p>
|
||||
</div>
|
||||
) : judgeScores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<BarChart3 className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{(judgeScores.reduce((sum, score) => sum + score.overallScore, 0) / judgeScores.length).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">平均分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-green-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{Math.max(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">最高分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-orange-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-orange-600">
|
||||
{Math.min(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">最低分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-purple-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600">{judgeScores.length}</div>
|
||||
<div className="text-sm text-purple-600">評審人數</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Individual Judge Scores */}
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評審評分中...</p>
|
||||
</div>
|
||||
) : judgeScores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<Users className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評審評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
judgeScores.map((judgeScore, index) => (
|
||||
<Card key={judgeScore.judgeId}>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<Avatar className="w-12 h-12">
|
||||
<AvatarImage src={judgeScore.judgeAvatar} />
|
||||
<AvatarFallback className="bg-blue-100 text-blue-700">{judgeScore.judgeName[0]}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-lg">{judgeScore.judgeName}</CardTitle>
|
||||
<CardDescription>{judgeScore.judgeTitle}</CardDescription>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="flex items-center space-x-1">
|
||||
<Star className="w-5 h-5 text-yellow-500" />
|
||||
<span className="text-2xl font-bold text-gray-900">{judgeScore.overallScore}</span>
|
||||
<span className="text-gray-500">/5.0</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 mt-1">評分時間:{judgeScore.submittedAt}</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Criteria Scores */}
|
||||
<div className="space-y-4 mb-6">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<BarChart3 className="w-4 h-4 mr-2" />
|
||||
評分細項
|
||||
</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{judgeScore.criteria.map((criterion, criterionIndex) => (
|
||||
<div key={criterionIndex} className="space-y-2">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm font-medium text-gray-700">{criterion.name}</span>
|
||||
<span className="text-sm text-gray-600">
|
||||
{criterion.score}/{criterion.maxScore}
|
||||
</span>
|
||||
</div>
|
||||
<Progress value={(criterion.score / criterion.maxScore) * 100} className="h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Judge Comment */}
|
||||
<div className="space-y-3">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<MessageSquare className="w-4 h-4 mr-2" />
|
||||
評審評語
|
||||
</h4>
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-4">
|
||||
<p className="text-gray-700 leading-relaxed">{judgeScore.comment}</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-5xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-2xl flex items-center space-x-2">
|
||||
<Award className="w-6 h-6 text-purple-500" />
|
||||
<span>得獎作品詳情</span>
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{competition?.name} - {award.awardName}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="mt-6">
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsTrigger value="overview">獎項概覽</TabsTrigger>
|
||||
<TabsTrigger value="photos">競賽照片</TabsTrigger>
|
||||
<TabsTrigger value="judges">評審團</TabsTrigger>
|
||||
<TabsTrigger value="scores">評分詳情</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{renderAwardOverview()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos" className="space-y-6">
|
||||
{renderCompetitionPhotos()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="judges" className="space-y-6">
|
||||
{renderJudgePanel()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="scores" className="space-y-6">
|
||||
{renderJudgeScores()}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Photo Gallery Modal */}
|
||||
<Dialog open={showPhotoGallery} onOpenChange={setShowPhotoGallery}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] p-0">
|
||||
<div className="relative">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute top-2 right-2 z-10 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={() => setShowPhotoGallery(false)}
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<div className="relative">
|
||||
<img
|
||||
src={competitionPhotos[currentPhotoIndex]?.url || "/placeholder.svg"}
|
||||
alt={competitionPhotos[currentPhotoIndex]?.title}
|
||||
className="w-full h-96 object-cover"
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute left-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={prevPhoto}
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute right-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={nextPhoto}
|
||||
>
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black to-transparent p-4">
|
||||
<h3 className="text-white text-lg font-semibold">{competitionPhotos[currentPhotoIndex]?.title}</h3>
|
||||
<p className="text-white text-sm opacity-90">{competitionPhotos[currentPhotoIndex]?.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
<div className="flex items-center justify-center space-x-2">
|
||||
{competitionPhotos.map((_, index) => (
|
||||
<button
|
||||
key={index}
|
||||
className={`w-2 h-2 rounded-full transition-colors ${
|
||||
index === currentPhotoIndex ? "bg-purple-600" : "bg-gray-300"
|
||||
}`}
|
||||
onClick={() => setCurrentPhotoIndex(index)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="text-center text-sm text-gray-500 mt-2">
|
||||
{currentPhotoIndex + 1} / {competitionPhotos.length}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
765
components/competition/award-detail-dialog-fixed.tsx
Normal file
765
components/competition/award-detail-dialog-fixed.tsx
Normal file
@@ -0,0 +1,765 @@
|
||||
"use client"
|
||||
|
||||
import { useState, useEffect } 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,
|
||||
Download,
|
||||
} from "lucide-react"
|
||||
import type { Award as AwardType } from "@/types/competition"
|
||||
|
||||
interface AwardDetailDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
award: AwardType
|
||||
}
|
||||
|
||||
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 [competitionJudges, setCompetitionJudges] = useState<any[]>([])
|
||||
const [judgeScores, setJudgeScores] = useState<any[]>([])
|
||||
const [loadingScores, setLoadingScores] = useState(false)
|
||||
|
||||
// 添加調試資訊
|
||||
console.log('🏆 AwardDetailDialog 渲染:', {
|
||||
open,
|
||||
award: award ? {
|
||||
id: award.id,
|
||||
competitionId: award.competitionId,
|
||||
awardName: award.awardName,
|
||||
hasCompetitionId: !!award.competitionId
|
||||
} : null
|
||||
});
|
||||
|
||||
const competition = competitions.find((c) => c.id === award.competitionId)
|
||||
|
||||
// 載入競賽評審團資訊
|
||||
useEffect(() => {
|
||||
console.log('🔍 useEffect 觸發:', { open, competitionId: award.competitionId, awardId: award.id });
|
||||
|
||||
if (open && award.competitionId) {
|
||||
const loadCompetitionJudges = async (retryCount = 0) => {
|
||||
try {
|
||||
console.log('🔍 載入競賽評審團:', award.competitionId, '重試次數:', retryCount);
|
||||
|
||||
const response = await fetch(`/api/competitions/${award.competitionId}/judges?t=${Date.now()}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0'
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📊 評審團API回應:', data);
|
||||
|
||||
if (data.success) {
|
||||
console.log('✅ 載入評審團成功:', data.data.length, '位');
|
||||
setCompetitionJudges(data.data);
|
||||
} else {
|
||||
console.error('❌ 載入評審團失敗:', data.message);
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評審團錯誤:', error);
|
||||
if (retryCount < 2) {
|
||||
console.log('🔄 重試載入評審團...', retryCount + 1);
|
||||
setTimeout(() => loadCompetitionJudges(retryCount + 1), 1000);
|
||||
} else {
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loadCompetitionJudges();
|
||||
} else {
|
||||
console.log('❌ useEffect 條件不滿足:', {
|
||||
open,
|
||||
competitionId: award.competitionId,
|
||||
hasCompetitionId: !!award.competitionId
|
||||
});
|
||||
}
|
||||
}, [open, award.competitionId]);
|
||||
|
||||
// 載入評分詳情
|
||||
useEffect(() => {
|
||||
if (open && award.id) {
|
||||
const loadJudgeScores = async () => {
|
||||
try {
|
||||
setLoadingScores(true);
|
||||
console.log('🔍 載入評分詳情:', award.id);
|
||||
|
||||
const response = await fetch(`/api/awards/${award.id}/scores`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
console.log('✅ 載入評分詳情成功:', data.data.length, '筆');
|
||||
setJudgeScores(data.data);
|
||||
} else {
|
||||
console.error('❌ 載入評分詳情失敗:', data.message);
|
||||
setJudgeScores([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評分詳情錯誤:', error);
|
||||
setJudgeScores([]);
|
||||
} finally {
|
||||
setLoadingScores(false);
|
||||
}
|
||||
};
|
||||
|
||||
loadJudgeScores();
|
||||
} else {
|
||||
setJudgeScores([]);
|
||||
}
|
||||
}, [open, award.id]);
|
||||
|
||||
// Competition photos - empty for production
|
||||
const getCompetitionPhotos = () => {
|
||||
return []
|
||||
}
|
||||
|
||||
const competitionPhotos = getCompetitionPhotos()
|
||||
|
||||
const getCompetitionTypeIcon = (type: string) => {
|
||||
switch (type) {
|
||||
case "individual":
|
||||
return <Target className="w-4 h-4" />
|
||||
case "team":
|
||||
return <Users className="w-4 h-4" />
|
||||
case "proposal":
|
||||
return <Lightbulb className="w-4 h-4" />
|
||||
default:
|
||||
return <Trophy className="w-4 h-4" />
|
||||
}
|
||||
}
|
||||
|
||||
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 <FileText className="w-5 h-5 text-red-500" />
|
||||
case "pptx":
|
||||
case "ppt":
|
||||
return <FileText className="w-5 h-5 text-orange-500" />
|
||||
case "docx":
|
||||
case "doc":
|
||||
return <FileText className="w-5 h-5 text-blue-500" />
|
||||
default:
|
||||
return <FileText className="w-5 h-5 text-gray-500" />
|
||||
}
|
||||
}
|
||||
|
||||
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 = () => (
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<div className="text-6xl">{award.icon}</div>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-2xl">{award.awardName}</CardTitle>
|
||||
<CardDescription className="text-lg">
|
||||
{award.appName || award.proposalTitle || award.teamName}
|
||||
</CardDescription>
|
||||
<div className="flex items-center space-x-4 mt-2">
|
||||
<Badge variant="outline" className={getCompetitionTypeColor(award.competitionType)}>
|
||||
{getCompetitionTypeIcon(award.competitionType)}
|
||||
<span className="ml-1">{getCompetitionTypeText(award.competitionType)}</span>
|
||||
</Badge>
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className={`${
|
||||
award.awardType === "gold"
|
||||
? "bg-yellow-100 text-yellow-800 border-yellow-200"
|
||||
: award.awardType === "silver"
|
||||
? "bg-gray-100 text-gray-800 border-gray-200"
|
||||
: award.awardType === "bronze"
|
||||
? "bg-orange-100 text-orange-800 border-orange-200"
|
||||
: "bg-purple-100 text-purple-800 border-purple-200"
|
||||
}`}
|
||||
>
|
||||
{award.awardName}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div className="text-center p-4 bg-purple-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-purple-600">{award.score}</div>
|
||||
<div className="text-sm text-purple-600">評審評分</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-blue-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-blue-600">
|
||||
{award.year}年{award.month}月
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">獲獎時間</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-green-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-green-600">
|
||||
{award.teamName || award.creator || "創作者"}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">
|
||||
{award.competitionType === "team" ? "團隊" : "創作者"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||
<h4 className="font-semibold text-blue-900 mb-2 flex items-center">
|
||||
<Trophy className="w-5 h-5 mr-2" />
|
||||
競賽資訊
|
||||
</h4>
|
||||
<div className="text-blue-800">
|
||||
<p className="mb-2">
|
||||
<strong>競賽名稱:</strong>
|
||||
{award.competitionName || competition?.name || '未知競賽'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽描述:</strong>
|
||||
{award.competitionDescription || competition?.description || '暫無描述'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽期間:</strong>
|
||||
{award.competitionStartDate && award.competitionEndDate
|
||||
? `${award.competitionStartDate} ~ ${award.competitionEndDate}`
|
||||
: competition?.startDate && competition?.endDate
|
||||
? `${competition.startDate} ~ ${competition.endDate}`
|
||||
: '暫無時間資訊'
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
<strong>評審團:</strong>
|
||||
{competitionJudges && competitionJudges.length > 0 ? (
|
||||
<span className="text-green-700">
|
||||
{competitionJudges.length} 位評審
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-gray-500">暫無評審信息</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* App Links Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Link className="w-5 h-5 text-green-500" />
|
||||
<span>應用連結</span>
|
||||
</CardTitle>
|
||||
<CardDescription>相關應用和資源連結</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{(() => {
|
||||
// 解析 application_links 資料
|
||||
let applicationLinks = null;
|
||||
if (award.applicationLinks) {
|
||||
applicationLinks = award.applicationLinks;
|
||||
} else if (award.application_links) {
|
||||
try {
|
||||
applicationLinks = typeof award.application_links === 'string'
|
||||
? JSON.parse(award.application_links)
|
||||
: award.application_links;
|
||||
} catch (e) {
|
||||
console.error('解析 application_links 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!applicationLinks) {
|
||||
return (
|
||||
<div className="col-span-full text-center py-8 text-gray-500">
|
||||
<Link className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無應用連結</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{applicationLinks.production && (
|
||||
<div className="flex items-center justify-between p-3 bg-green-50 border border-green-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<ExternalLink className="w-5 h-5 text-green-600" />
|
||||
<div>
|
||||
<p className="font-medium text-green-800">正式應用</p>
|
||||
<p className="text-xs text-green-600">APP 連結</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-green-300 text-green-700 hover:bg-green-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.production, "_blank")}
|
||||
>
|
||||
訪問
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.demo && (
|
||||
<div className="flex items-center justify-between p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Eye className="w-5 h-5 text-blue-600" />
|
||||
<div>
|
||||
<p className="font-medium text-blue-800">演示版本</p>
|
||||
<p className="text-xs text-blue-600">體驗環境</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-blue-300 text-blue-700 hover:bg-blue-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.demo, "_blank")}
|
||||
>
|
||||
體驗
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.github && (
|
||||
<div className="flex items-center justify-between p-3 bg-gray-50 border border-gray-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<FileText className="w-5 h-5 text-gray-600" />
|
||||
<div>
|
||||
<p className="font-medium text-gray-800">源碼倉庫</p>
|
||||
<p className="text-xs text-gray-600">GitHub</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-gray-300 text-gray-700 hover:bg-gray-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.github, "_blank")}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Reports Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<FileText className="w-5 h-5 text-purple-500" />
|
||||
<span>相關報告</span>
|
||||
</CardTitle>
|
||||
<CardDescription>技術文檔和報告資料(僅供預覽)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-3">
|
||||
{(() => {
|
||||
// 解析 documents 資料
|
||||
let documents = [];
|
||||
if (award.documents) {
|
||||
documents = award.documents;
|
||||
} else if (award.documents) {
|
||||
try {
|
||||
documents = typeof award.documents === 'string'
|
||||
? JSON.parse(award.documents)
|
||||
: award.documents;
|
||||
} catch (e) {
|
||||
console.error('解析 documents 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!documents || documents.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<FileText className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無相關文件</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return documents.map((doc, index) => (
|
||||
<div
|
||||
key={doc.id || index}
|
||||
className="flex items-center justify-between p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<div className="flex items-center space-x-4">
|
||||
{getFileIcon(doc.type)}
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium text-gray-900">{doc.name || doc.title}</h4>
|
||||
<p className="text-sm text-gray-600">{doc.description}</p>
|
||||
<div className="flex items-center space-x-4 mt-1 text-xs text-gray-500">
|
||||
<span>大小:{doc.size}</span>
|
||||
<span>上傳:{doc.uploadDate || doc.upload_date}</span>
|
||||
<span className="uppercase">{doc.type}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
{doc.previewUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.previewUrl, "_blank")}
|
||||
className="text-blue-600 border-blue-300 hover:bg-blue-50"
|
||||
>
|
||||
<Eye className="w-4 h-4 mr-1" />
|
||||
預覽
|
||||
</Button>
|
||||
)}
|
||||
{doc.downloadUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.downloadUrl, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
{doc.url && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.url, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
));
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
|
||||
const renderJudgePanel = () => {
|
||||
// 確保 competitionJudges 是陣列
|
||||
const judges = Array.isArray(competitionJudges) ? competitionJudges : [];
|
||||
|
||||
if (judges.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Crown className="w-5 h-5 text-purple-500" />
|
||||
<span>評審團</span>
|
||||
</CardTitle>
|
||||
<CardDescription>本次競賽的專業評審團隊</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<Crown className="w-12 h-12 mx-auto mb-4 text-gray-300" />
|
||||
<p>暫無評審信息</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Crown className="w-5 h-5 text-purple-500" />
|
||||
<span>評審團</span>
|
||||
</CardTitle>
|
||||
<CardDescription>本次競賽的專業評審團隊</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{judges.map((judge, index) => (
|
||||
<div key={judge.id || index} className="text-center">
|
||||
<Avatar className="w-16 h-16 mx-auto mb-3">
|
||||
<AvatarImage src={judge.avatar} />
|
||||
<AvatarFallback className="bg-purple-100 text-purple-700 text-lg">
|
||||
{judge.name ? judge.name[0] : 'J'}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<h4 className="font-semibold text-gray-900 mb-1">{judge.name}</h4>
|
||||
<p className="text-sm text-gray-600 mb-2">{judge.title}</p>
|
||||
<div className="flex flex-wrap justify-center gap-1">
|
||||
{judge.skills && judge.skills.map((skill, skillIndex) => (
|
||||
<Badge key={skillIndex} variant="outline" className="text-xs">
|
||||
{skill}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
const renderJudgeScores = () => {
|
||||
// 確保 judgeScores 是陣列
|
||||
const scores = Array.isArray(judgeScores) ? judgeScores : [];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Overall Statistics */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<BarChart3 className="w-5 h-5 text-blue-500" />
|
||||
<span>評分統計</span>
|
||||
</CardTitle>
|
||||
<CardDescription>評審團整體評分概況</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評分資料中...</p>
|
||||
</div>
|
||||
) : scores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<BarChart3 className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{(scores.reduce((sum, score) => sum + score.overallScore, 0) / scores.length).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">平均分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-green-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{Math.max(...scores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">最高分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-orange-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-orange-600">
|
||||
{Math.min(...scores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">最低分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-purple-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600">{scores.length}</div>
|
||||
<div className="text-sm text-purple-600">評審人數</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Individual Judge Scores */}
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評審評分中...</p>
|
||||
</div>
|
||||
) : scores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<Users className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評審評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
scores.map((judgeScore, index) => (
|
||||
<Card key={judgeScore.judgeId}>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<Avatar className="w-12 h-12">
|
||||
<AvatarImage src={judgeScore.judgeAvatar} />
|
||||
<AvatarFallback className="bg-blue-100 text-blue-700">{judgeScore.judgeName[0]}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-lg">{judgeScore.judgeName}</CardTitle>
|
||||
<CardDescription>{judgeScore.judgeTitle}</CardDescription>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="flex items-center space-x-1">
|
||||
<Star className="w-5 h-5 text-yellow-500" />
|
||||
<span className="text-2xl font-bold text-gray-900">{judgeScore.overallScore}</span>
|
||||
<span className="text-gray-500">/5.0</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 mt-1">評分時間:{judgeScore.submittedAt}</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Criteria Scores */}
|
||||
<div className="space-y-4 mb-6">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<BarChart3 className="w-4 h-4 mr-2" />
|
||||
評分細項
|
||||
</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{judgeScore.criteria.map((criterion, criterionIndex) => (
|
||||
<div key={criterionIndex} className="space-y-2">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm font-medium text-gray-700">{criterion.name}</span>
|
||||
<span className="text-sm text-gray-600">
|
||||
{criterion.score}/{criterion.maxScore}
|
||||
</span>
|
||||
</div>
|
||||
<Progress value={(criterion.score / criterion.maxScore) * 100} className="h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Judge Comment */}
|
||||
<div className="space-y-3">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<MessageSquare className="w-4 h-4 mr-2" />
|
||||
評審評語
|
||||
</h4>
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-4">
|
||||
<p className="text-gray-700 leading-relaxed">{judgeScore.comment}</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const renderCompetitionPhotos = () => (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Camera className="w-5 h-5 text-blue-500" />
|
||||
<span>競賽照片</span>
|
||||
</CardTitle>
|
||||
<CardDescription>競賽活動精彩瞬間</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<ImageIcon className="w-12 h-12 mx-auto mb-4 text-gray-300" />
|
||||
<p>暫無競賽照片</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-5xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-2xl flex items-center space-x-2">
|
||||
<Award className="w-6 h-6 text-purple-500" />
|
||||
<span>得獎作品詳情</span>
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{award.competitionName} - {award.awardName}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="mt-6">
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsTrigger value="overview">獎項概覽</TabsTrigger>
|
||||
<TabsTrigger value="photos">競賽照片</TabsTrigger>
|
||||
<TabsTrigger value="judges">評審團</TabsTrigger>
|
||||
<TabsTrigger value="scores">評分詳情</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{renderAwardOverview()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos" className="space-y-6">
|
||||
{renderCompetitionPhotos()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="judges" className="space-y-6">
|
||||
{renderJudgePanel()}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="scores" className="space-y-6">
|
||||
{renderJudgeScores()}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
@@ -28,6 +28,7 @@ import {
|
||||
Eye,
|
||||
Link,
|
||||
FileText,
|
||||
Download,
|
||||
} from "lucide-react"
|
||||
import type { Award as AwardType } from "@/types/competition"
|
||||
|
||||
@@ -37,28 +38,14 @@ interface AwardDetailDialogProps {
|
||||
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 [competitionJudges, setCompetitionJudges] = useState<any[]>([])
|
||||
const [judgeScores, setJudgeScores] = useState<any[]>([])
|
||||
const [loadingScores, setLoadingScores] = useState(false)
|
||||
|
||||
// 添加調試資訊
|
||||
console.log('🏆 AwardDetailDialog 渲染:', {
|
||||
@@ -72,8 +59,6 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
});
|
||||
|
||||
const competition = competitions.find((c) => c.id === award.competitionId)
|
||||
const judgeScores = getJudgeScores(award.id)
|
||||
const appData = getAppData(award.id)
|
||||
|
||||
// 載入競賽評審團資訊
|
||||
useEffect(() => {
|
||||
@@ -83,14 +68,8 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
const loadCompetitionJudges = async (retryCount = 0) => {
|
||||
try {
|
||||
console.log('🔍 載入競賽評審團:', award.competitionId, '重試次數:', retryCount);
|
||||
console.log('🏆 獎項資料:', award);
|
||||
|
||||
// 添加時間戳防止快取,並設置快取控制標頭
|
||||
const timestamp = Date.now();
|
||||
const apiUrl = `/api/competitions/${award.competitionId}/judges?t=${timestamp}`;
|
||||
console.log('🌐 API URL:', apiUrl);
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
const response = await fetch(`/api/competitions/${award.competitionId}/judges?t=${Date.now()}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
@@ -99,49 +78,31 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
}
|
||||
});
|
||||
|
||||
console.log('📡 API 回應狀態:', response.status);
|
||||
console.log('📡 API 回應標頭:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error('❌ API 錯誤回應:', errorText);
|
||||
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📄 API 回應資料:', JSON.stringify(data, null, 2));
|
||||
console.log('📊 評審團API回應:', data);
|
||||
|
||||
if (data.success && data.data && data.data.judges) {
|
||||
console.log('✅ 獲取到評審團:', data.data.judges.length, '位');
|
||||
console.log('👥 評審團詳細資料:', data.data.judges);
|
||||
if (data.success) {
|
||||
console.log('✅ 載入評審團成功:', data.data.judges.length, '位');
|
||||
setCompetitionJudges(data.data.judges);
|
||||
} else {
|
||||
console.error('❌ 獲取評審團失敗:', data.message || '未知錯誤');
|
||||
console.error('❌ 完整錯誤資料:', data);
|
||||
|
||||
// 如果沒有評審資料且是第一次嘗試,重試一次
|
||||
if (retryCount === 0) {
|
||||
console.log('🔄 重試載入評審團...');
|
||||
setTimeout(() => loadCompetitionJudges(1), 1000);
|
||||
} else {
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
console.error('❌ 載入評審團失敗:', data.message);
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評審團失敗:', error);
|
||||
|
||||
// 如果是網路錯誤且是第一次嘗試,重試一次
|
||||
if (retryCount === 0) {
|
||||
console.log('🔄 網路錯誤,重試載入評審團...');
|
||||
setTimeout(() => loadCompetitionJudges(1), 2000);
|
||||
console.error('❌ 載入評審團錯誤:', error);
|
||||
if (retryCount < 2) {
|
||||
console.log('🔄 重試載入評審團...', retryCount + 1);
|
||||
setTimeout(() => loadCompetitionJudges(retryCount + 1), 1000);
|
||||
} else {
|
||||
setCompetitionJudges([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 清空之前的評審資料,確保重新載入
|
||||
setCompetitionJudges([]);
|
||||
loadCompetitionJudges();
|
||||
} else {
|
||||
console.log('❌ useEffect 條件不滿足:', {
|
||||
@@ -152,6 +113,38 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
}
|
||||
}, [open, award.competitionId]);
|
||||
|
||||
// 載入評分詳情
|
||||
useEffect(() => {
|
||||
if (open && award.id) {
|
||||
const loadJudgeScores = async () => {
|
||||
try {
|
||||
setLoadingScores(true);
|
||||
console.log('🔍 載入評分詳情:', award.id);
|
||||
|
||||
const response = await fetch(`/api/awards/${award.id}/scores`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
console.log('✅ 載入評分詳情成功:', data.data.length, '筆');
|
||||
setJudgeScores(data.data);
|
||||
} else {
|
||||
console.error('❌ 載入評分詳情失敗:', data.message);
|
||||
setJudgeScores([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 載入評分詳情錯誤:', error);
|
||||
setJudgeScores([]);
|
||||
} finally {
|
||||
setLoadingScores(false);
|
||||
}
|
||||
};
|
||||
|
||||
loadJudgeScores();
|
||||
} else {
|
||||
setJudgeScores([]);
|
||||
}
|
||||
}, [open, award.id]);
|
||||
|
||||
// Competition photos - empty for production
|
||||
const getCompetitionPhotos = () => {
|
||||
return []
|
||||
@@ -235,7 +228,10 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-2xl">{award.awardName}</CardTitle>
|
||||
<CardDescription className="text-lg">
|
||||
{award.appName || award.proposalTitle || award.teamName}
|
||||
{award.competitionType === "team"
|
||||
? (award.teamName || award.appName || "團隊名稱")
|
||||
: (award.appName || award.proposalTitle || award.teamName)
|
||||
}
|
||||
</CardDescription>
|
||||
<div className="flex items-center space-x-4 mt-2">
|
||||
<Badge variant="outline" className={getCompetitionTypeColor(award.competitionType)}>
|
||||
@@ -248,10 +244,10 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
award.awardType === "gold"
|
||||
? "bg-yellow-100 text-yellow-800 border-yellow-200"
|
||||
: award.awardType === "silver"
|
||||
? "bg-gray-100 text-gray-800 border-gray-200"
|
||||
: award.awardType === "bronze"
|
||||
? "bg-orange-100 text-orange-800 border-orange-200"
|
||||
: "bg-red-100 text-red-800 border-red-200"
|
||||
? "bg-gray-100 text-gray-800 border-gray-200"
|
||||
: award.awardType === "bronze"
|
||||
? "bg-orange-100 text-orange-800 border-orange-200"
|
||||
: "bg-purple-100 text-purple-800 border-purple-200"
|
||||
}`}
|
||||
>
|
||||
{award.awardName}
|
||||
@@ -261,75 +257,65 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-3 gap-6 mb-6">
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600 mb-1">
|
||||
{award.awardType === "popular" && award.competitionType === "team"
|
||||
? `${award.score}`
|
||||
: award.awardType === "popular"
|
||||
? `${award.score}`
|
||||
: award.score}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{award.competitionType === "proposal"
|
||||
? "評審評分"
|
||||
: award.awardType === "popular"
|
||||
? award.competitionType === "team"
|
||||
? "人氣指數"
|
||||
: "收藏數"
|
||||
: "評審評分"}
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div className="text-center p-4 bg-purple-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-purple-600">{award.score}</div>
|
||||
<div className="text-sm text-purple-600">評審評分</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600 mb-1">
|
||||
<div className="text-center p-4 bg-blue-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-blue-600">
|
||||
{award.year}年{award.month}月
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">獲獎時間</div>
|
||||
<div className="text-sm text-blue-600">獲獎時間</div>
|
||||
</div>
|
||||
<div className="text-center p-4 bg-gray-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600 mb-1">{award.creator}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
<div className="text-center p-4 bg-green-50 rounded-lg">
|
||||
<div className="text-3xl font-bold text-green-600">
|
||||
{award.competitionType === "team"
|
||||
? "團隊"
|
||||
: award.competitionType === "proposal"
|
||||
? "提案團隊"
|
||||
: "創作者"}
|
||||
? (award.appName || award.teamName || "應用名稱")
|
||||
: (award.teamName || award.creator || "創作者")
|
||||
}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">
|
||||
{award.competitionType === "team" ? "應用名稱" : "創作者"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{competition && (
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||
<h4 className="font-semibold text-blue-900 mb-2 flex items-center">
|
||||
<Trophy className="w-5 h-5 mr-2" />
|
||||
競賽資訊
|
||||
</h4>
|
||||
<div className="text-blue-800">
|
||||
<p className="mb-2">
|
||||
<strong>競賽名稱:</strong>
|
||||
{competition.name}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽描述:</strong>
|
||||
{competition.description}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽期間:</strong>
|
||||
{competition.startDate} ~ {competition.endDate}
|
||||
</p>
|
||||
<p>
|
||||
<strong>評審團:</strong>
|
||||
{competitionJudges && competitionJudges.length > 0 ? (
|
||||
<span className="text-green-700">
|
||||
{competitionJudges.length} 位評審
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-gray-500">暫無評審信息</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4 mt-4">
|
||||
<h4 className="font-semibold text-blue-900 mb-2 flex items-center">
|
||||
<Trophy className="w-5 h-5 mr-2" />
|
||||
競賽資訊
|
||||
</h4>
|
||||
<div className="text-blue-800">
|
||||
<p className="mb-2">
|
||||
<strong>競賽名稱:</strong>
|
||||
{award.competitionName || competition?.name || '未知競賽'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽描述:</strong>
|
||||
{award.competitionDescription || competition?.description || '暫無描述'}
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
<strong>競賽期間:</strong>
|
||||
{award.competitionStartDate && award.competitionEndDate
|
||||
? `${new Date(award.competitionStartDate).toLocaleDateString('zh-TW', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')} ~ ${new Date(award.competitionEndDate).toLocaleDateString('zh-TW', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')}`
|
||||
: competition?.startDate && competition?.endDate
|
||||
? `${new Date(competition.startDate).toLocaleDateString('zh-TW', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')} ~ ${new Date(competition.endDate).toLocaleDateString('zh-TW', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')}`
|
||||
: '暫無時間資訊'
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
<strong>評審團:</strong>
|
||||
{competitionJudges && competitionJudges.length > 0 ? (
|
||||
<span className="text-green-700">
|
||||
{competitionJudges.length} 位評審
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-gray-500">暫無評審信息</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -344,65 +330,94 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{appData.appUrl && (
|
||||
<div className="flex items-center justify-between p-3 bg-green-50 border border-green-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<ExternalLink className="w-5 h-5 text-green-600" />
|
||||
<div>
|
||||
<p className="font-medium text-green-800">正式應用</p>
|
||||
<p className="text-xs text-green-600">APP 連結</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-green-300 text-green-700 hover:bg-green-100 bg-transparent"
|
||||
onClick={() => window.open(appData.appUrl, "_blank")}
|
||||
>
|
||||
訪問
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{(() => {
|
||||
// 解析 application_links 資料
|
||||
let applicationLinks = null;
|
||||
if (award.applicationLinks) {
|
||||
applicationLinks = award.applicationLinks;
|
||||
} else if (award.application_links) {
|
||||
try {
|
||||
applicationLinks = typeof award.application_links === 'string'
|
||||
? JSON.parse(award.application_links)
|
||||
: award.application_links;
|
||||
} catch (e) {
|
||||
console.error('解析 application_links 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
{appData.demoUrl && (
|
||||
<div className="flex items-center justify-between p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Eye className="w-5 h-5 text-blue-600" />
|
||||
<div>
|
||||
<p className="font-medium text-blue-800">演示版本</p>
|
||||
<p className="text-xs text-blue-600">體驗環境</p>
|
||||
if (!applicationLinks) {
|
||||
return (
|
||||
<div className="col-span-full text-center py-8 text-gray-500">
|
||||
<Link className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無應用連結</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-blue-300 text-blue-700 hover:bg-blue-100 bg-transparent"
|
||||
onClick={() => window.open(appData.demoUrl, "_blank")}
|
||||
>
|
||||
體驗
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
);
|
||||
}
|
||||
|
||||
{appData.githubUrl && (
|
||||
<div className="flex items-center justify-between p-3 bg-gray-50 border border-gray-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<FileText className="w-5 h-5 text-gray-600" />
|
||||
<div>
|
||||
<p className="font-medium text-gray-800">源碼倉庫</p>
|
||||
<p className="text-xs text-gray-600">GitHub</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-gray-300 text-gray-700 hover:bg-gray-100 bg-transparent"
|
||||
onClick={() => window.open(appData.githubUrl, "_blank")}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
return (
|
||||
<>
|
||||
{applicationLinks.production && (
|
||||
<div className="flex items-center justify-between p-3 bg-green-50 border border-green-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<ExternalLink className="w-5 h-5 text-green-600" />
|
||||
<div>
|
||||
<p className="font-medium text-green-800">正式應用</p>
|
||||
<p className="text-xs text-green-600">APP 連結</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-green-300 text-green-700 hover:bg-green-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.production, "_blank")}
|
||||
>
|
||||
訪問
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.demo && (
|
||||
<div className="flex items-center justify-between p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Eye className="w-5 h-5 text-blue-600" />
|
||||
<div>
|
||||
<p className="font-medium text-blue-800">演示版本</p>
|
||||
<p className="text-xs text-blue-600">體驗環境</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-blue-300 text-blue-700 hover:bg-blue-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.demo, "_blank")}
|
||||
>
|
||||
體驗
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{applicationLinks.github && (
|
||||
<div className="flex items-center justify-between p-3 bg-gray-50 border border-gray-200 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<FileText className="w-5 h-5 text-gray-600" />
|
||||
<div>
|
||||
<p className="font-medium text-gray-800">源碼倉庫</p>
|
||||
<p className="text-xs text-gray-600">GitHub</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="border-gray-300 text-gray-700 hover:bg-gray-100 bg-transparent"
|
||||
onClick={() => window.open(applicationLinks.github, "_blank")}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -418,95 +433,96 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-3">
|
||||
{appData.reports.map((report) => (
|
||||
<div
|
||||
key={report.id}
|
||||
className="flex items-center justify-between p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<div className="flex items-center space-x-4">
|
||||
{getFileIcon(report.type)}
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium text-gray-900">{report.name}</h4>
|
||||
<p className="text-sm text-gray-600">{report.description}</p>
|
||||
<div className="flex items-center space-x-4 mt-1 text-xs text-gray-500">
|
||||
<span>大小:{report.size}</span>
|
||||
<span>上傳:{report.uploadDate}</span>
|
||||
<span className="uppercase">{report.type}</span>
|
||||
{(() => {
|
||||
// 解析 documents 資料
|
||||
let documents = [];
|
||||
if (award.documents) {
|
||||
documents = award.documents;
|
||||
} else if (award.documents) {
|
||||
try {
|
||||
documents = typeof award.documents === 'string'
|
||||
? JSON.parse(award.documents)
|
||||
: award.documents;
|
||||
} catch (e) {
|
||||
console.error('解析 documents 失敗:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!documents || documents.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<FileText className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無相關文件</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return documents.map((doc, index) => (
|
||||
<div
|
||||
key={doc.id || index}
|
||||
className="flex items-center justify-between p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<div className="flex items-center space-x-4">
|
||||
{getFileIcon(doc.type)}
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium text-gray-900">{doc.name || doc.title}</h4>
|
||||
<p className="text-sm text-gray-600">{doc.description}</p>
|
||||
<div className="flex items-center space-x-4 mt-1 text-xs text-gray-500">
|
||||
<span>大小:{doc.size}</span>
|
||||
<span>上傳:{doc.uploadDate || doc.upload_date}</span>
|
||||
<span className="uppercase">{doc.type}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
{doc.previewUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.previewUrl, "_blank")}
|
||||
className="text-blue-600 border-blue-300 hover:bg-blue-50"
|
||||
>
|
||||
<Eye className="w-4 h-4 mr-1" />
|
||||
預覽
|
||||
</Button>
|
||||
)}
|
||||
{doc.downloadUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.downloadUrl, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
{doc.url && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(doc.url, "_blank")}
|
||||
className="text-purple-600 border-purple-300 hover:bg-purple-50"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
下載
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => handlePreview(report)}
|
||||
className="text-blue-600 border-blue-300 hover:bg-blue-50"
|
||||
>
|
||||
<Eye className="w-4 h-4 mr-1" />
|
||||
預覽
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
));
|
||||
})()}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
|
||||
const renderCompetitionPhotos = () => (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Camera className="w-5 h-5 text-purple-500" />
|
||||
<span>競賽照片</span>
|
||||
</CardTitle>
|
||||
<CardDescription>競賽當天的精彩瞬間</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-4">
|
||||
{competitionPhotos.map((photo, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="relative group cursor-pointer overflow-hidden rounded-lg border hover:shadow-lg transition-all"
|
||||
onClick={() => {
|
||||
setCurrentPhotoIndex(index)
|
||||
setShowPhotoGallery(true)
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={photo.url || "/placeholder.svg"}
|
||||
alt={photo.title}
|
||||
className="w-full h-32 object-cover group-hover:scale-105 transition-transform"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all flex items-center justify-center">
|
||||
<ImageIcon className="w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity" />
|
||||
</div>
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black to-transparent p-2">
|
||||
<p className="text-white text-xs font-medium">{photo.title}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 text-center">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setCurrentPhotoIndex(0)
|
||||
setShowPhotoGallery(true)
|
||||
}}
|
||||
>
|
||||
<Camera className="w-4 h-4 mr-2" />
|
||||
查看所有照片
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
const renderJudgePanel = () => {
|
||||
if (!competitionJudges || competitionJudges.length === 0) {
|
||||
// 確保 competitionJudges 是陣列
|
||||
const judges = Array.isArray(competitionJudges) ? competitionJudges : [];
|
||||
|
||||
if (judges.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
@@ -536,23 +552,23 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
<CardDescription>本次競賽的專業評審團隊</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{competitionJudges.map((judge) => (
|
||||
<div key={judge.id} className="flex items-center space-x-3 p-3 bg-gray-50 rounded-lg">
|
||||
<Avatar>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{judges.map((judge, index) => (
|
||||
<div key={judge.id || index} className="text-center">
|
||||
<Avatar className="w-16 h-16 mx-auto mb-3">
|
||||
<AvatarImage src={judge.avatar} />
|
||||
<AvatarFallback className="bg-purple-100 text-purple-700">{judge.name[0]}</AvatarFallback>
|
||||
<AvatarFallback className="bg-purple-100 text-purple-700 text-lg">
|
||||
{judge.name ? judge.name[0] : 'J'}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<h4 className="font-medium">{judge.name}</h4>
|
||||
<p className="text-sm text-gray-600">{judge.title}</p>
|
||||
<div className="flex flex-wrap gap-1 mt-1">
|
||||
{judge.expertise && judge.expertise.slice(0, 2).map((skill) => (
|
||||
<Badge key={skill} variant="secondary" className="text-xs">
|
||||
{skill}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<h4 className="font-semibold text-gray-900 mb-1">{judge.name}</h4>
|
||||
<p className="text-sm text-gray-600 mb-2">{judge.title}</p>
|
||||
<div className="flex flex-wrap justify-center gap-1">
|
||||
{judge.expertise && judge.expertise.map((skill, skillIndex) => (
|
||||
<Badge key={skillIndex} variant="outline" className="text-xs">
|
||||
{skill}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -562,104 +578,151 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
)
|
||||
}
|
||||
|
||||
const renderJudgeScores = () => (
|
||||
<div className="space-y-6">
|
||||
{/* Overall Statistics */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<BarChart3 className="w-5 h-5 text-blue-500" />
|
||||
<span>評分統計</span>
|
||||
</CardTitle>
|
||||
<CardDescription>評審團整體評分概況</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{(judgeScores.reduce((sum, score) => sum + score.overallScore, 0) / judgeScores.length).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">平均分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-green-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{Math.max(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">最高分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-orange-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-orange-600">
|
||||
{Math.min(...judgeScores.map((s) => s.overallScore)).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">最低分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-purple-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600">{judgeScores.length}</div>
|
||||
<div className="text-sm text-purple-600">評審人數</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
const renderJudgeScores = () => {
|
||||
// 確保 judgeScores 是陣列
|
||||
const scores = Array.isArray(judgeScores) ? judgeScores : [];
|
||||
|
||||
{/* Individual Judge Scores */}
|
||||
{judgeScores.map((judgeScore, index) => (
|
||||
<Card key={judgeScore.judgeId}>
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Overall Statistics */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<Avatar className="w-12 h-12">
|
||||
<AvatarImage src={judgeScore.judgeAvatar} />
|
||||
<AvatarFallback className="bg-blue-100 text-blue-700">{judgeScore.judgeName[0]}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-lg">{judgeScore.judgeName}</CardTitle>
|
||||
<CardDescription>{judgeScore.judgeTitle}</CardDescription>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="flex items-center space-x-1">
|
||||
<Star className="w-5 h-5 text-yellow-500" />
|
||||
<span className="text-2xl font-bold text-gray-900">{judgeScore.overallScore}</span>
|
||||
<span className="text-gray-500">/5.0</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 mt-1">評分時間:{judgeScore.submittedAt}</div>
|
||||
</div>
|
||||
</div>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<BarChart3 className="w-5 h-5 text-blue-500" />
|
||||
<span>評分統計</span>
|
||||
</CardTitle>
|
||||
<CardDescription>評審團整體評分概況</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Criteria Scores */}
|
||||
<div className="space-y-4 mb-6">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<BarChart3 className="w-4 h-4 mr-2" />
|
||||
評分細項
|
||||
</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{judgeScore.criteria.map((criterion, criterionIndex) => (
|
||||
<div key={criterionIndex} className="space-y-2">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm font-medium text-gray-700">{criterion.name}</span>
|
||||
<span className="text-sm text-gray-600">
|
||||
{criterion.score}/{criterion.maxScore}
|
||||
</span>
|
||||
</div>
|
||||
<Progress value={(criterion.score / criterion.maxScore) * 100} className="h-2" />
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評分資料中...</p>
|
||||
</div>
|
||||
) : scores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<BarChart3 className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{scores.length > 0 ? (scores.reduce((sum, score) => sum + Number(score.overallScore), 0) / scores.length).toFixed(1) : '0.0'}
|
||||
</div>
|
||||
))}
|
||||
<div className="text-sm text-blue-600">平均分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-green-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{scores.length > 0 ? Math.max(...scores.map((s) => Number(s.overallScore))).toFixed(1) : '0.0'}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">最高分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-orange-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-orange-600">
|
||||
{scores.length > 0 ? Math.min(...scores.map((s) => Number(s.overallScore))).toFixed(1) : '0.0'}
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">最低分數</div>
|
||||
</div>
|
||||
<div className="text-center p-3 bg-purple-50 rounded-lg">
|
||||
<div className="text-2xl font-bold text-purple-600">{scores.length}</div>
|
||||
<div className="text-sm text-purple-600">評審人數</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Judge Comment */}
|
||||
<div className="space-y-3">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<MessageSquare className="w-4 h-4 mr-2" />
|
||||
評審評語
|
||||
</h4>
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-4">
|
||||
<p className="text-gray-700 leading-relaxed">{judgeScore.comment}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Individual Judge Scores */}
|
||||
{loadingScores ? (
|
||||
<div className="text-center py-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
|
||||
<p className="text-gray-600">載入評審評分中...</p>
|
||||
</div>
|
||||
) : scores.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<Users className="w-12 h-12 mx-auto mb-2 text-gray-300" />
|
||||
<p>暫無評審評分資料</p>
|
||||
</div>
|
||||
) : (
|
||||
scores.map((judgeScore, index) => (
|
||||
<Card key={judgeScore.judgeId}>
|
||||
<CardHeader>
|
||||
<div className="flex items-center space-x-4">
|
||||
<Avatar className="w-12 h-12">
|
||||
<AvatarImage src={judgeScore.judgeAvatar} />
|
||||
<AvatarFallback className="bg-blue-100 text-blue-700">{judgeScore.judgeName[0]}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-lg">{judgeScore.judgeName}</CardTitle>
|
||||
<CardDescription>{judgeScore.judgeTitle}</CardDescription>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="flex items-center space-x-1">
|
||||
<Star className="w-5 h-5 text-yellow-500" />
|
||||
<span className="text-2xl font-bold text-gray-900">{Number(judgeScore.overallScore).toFixed(1)}</span>
|
||||
<span className="text-gray-500">/100</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 mt-1">評分時間:{new Date(judgeScore.submittedAt).toLocaleDateString('zh-TW', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Criteria Scores */}
|
||||
<div className="space-y-4 mb-6">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<BarChart3 className="w-4 h-4 mr-2" />
|
||||
評分細項
|
||||
</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{judgeScore.criteria.map((criterion, criterionIndex) => (
|
||||
<div key={criterionIndex} className="space-y-2">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm font-medium text-gray-700">{criterion.name}</span>
|
||||
<span className="text-sm text-gray-600">
|
||||
{criterion.score}/{criterion.maxScore}
|
||||
</span>
|
||||
</div>
|
||||
<Progress value={(criterion.score / criterion.maxScore) * 100} className="h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Judge Comment */}
|
||||
<div className="space-y-3">
|
||||
<h4 className="font-semibold text-gray-900 flex items-center">
|
||||
<MessageSquare className="w-4 h-4 mr-2" />
|
||||
評審評語
|
||||
</h4>
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-4">
|
||||
<p className="text-gray-700 leading-relaxed">{judgeScore.comment}</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const renderCompetitionPhotos = () => (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Camera className="w-5 h-5 text-blue-500" />
|
||||
<span>競賽照片</span>
|
||||
</CardTitle>
|
||||
<CardDescription>競賽活動精彩瞬間</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<ImageIcon className="w-12 h-12 mx-auto mb-4 text-gray-300" />
|
||||
<p>暫無競賽照片</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -672,10 +735,9 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
<span>得獎作品詳情</span>
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{competition?.name} - {award.awardName}
|
||||
{award.competitionName} - {award.awardName}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="mt-6">
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
@@ -704,70 +766,6 @@ export function AwardDetailDialog({ open, onOpenChange, award }: AwardDetailDial
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Photo Gallery Modal */}
|
||||
<Dialog open={showPhotoGallery} onOpenChange={setShowPhotoGallery}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] p-0">
|
||||
<div className="relative">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute top-2 right-2 z-10 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={() => setShowPhotoGallery(false)}
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<div className="relative">
|
||||
<img
|
||||
src={competitionPhotos[currentPhotoIndex]?.url || "/placeholder.svg"}
|
||||
alt={competitionPhotos[currentPhotoIndex]?.title}
|
||||
className="w-full h-96 object-cover"
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute left-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={prevPhoto}
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="absolute right-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white hover:bg-opacity-70"
|
||||
onClick={nextPhoto}
|
||||
>
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black to-transparent p-4">
|
||||
<h3 className="text-white text-lg font-semibold">{competitionPhotos[currentPhotoIndex]?.title}</h3>
|
||||
<p className="text-white text-sm opacity-90">{competitionPhotos[currentPhotoIndex]?.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
<div className="flex items-center justify-center space-x-2">
|
||||
{competitionPhotos.map((_, index) => (
|
||||
<button
|
||||
key={index}
|
||||
className={`w-2 h-2 rounded-full transition-colors ${
|
||||
index === currentPhotoIndex ? "bg-purple-600" : "bg-gray-300"
|
||||
}`}
|
||||
onClick={() => setCurrentPhotoIndex(index)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="text-center text-sm text-gray-500 mt-2">
|
||||
{currentPhotoIndex + 1} / {competitionPhotos.length}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
@@ -67,6 +67,7 @@ interface CompetitionContextType {
|
||||
addAward: (award: Omit<Award, "id">) => void
|
||||
getAwardsByYear: (year: number) => Award[]
|
||||
getAwardsByMonth: (year: number, month: number) => Award[]
|
||||
getAvailableYears: () => number[]
|
||||
|
||||
// Rankings
|
||||
getCompetitionRankings: (competitionId?: string) => Array<{
|
||||
@@ -527,11 +528,13 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
const loadAwards = async () => {
|
||||
setLoadingAwards(true)
|
||||
try {
|
||||
console.log('🔍 開始載入前台獎項數據...')
|
||||
const response = await fetch('/api/admin/awards')
|
||||
const data = await response.json()
|
||||
|
||||
if (data.success) {
|
||||
console.log('📊 載入獎項數據:', data.data.length, '個')
|
||||
console.log('📋 獎項數據樣本:', data.data.slice(0, 2))
|
||||
setAwards(data.data)
|
||||
} else {
|
||||
console.error('載入獎項失敗:', data.message)
|
||||
@@ -572,6 +575,12 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
return awards.filter((award) => award.year === year)
|
||||
}
|
||||
|
||||
// 獲取所有可用的年份
|
||||
const getAvailableYears = (): number[] => {
|
||||
const years = [...new Set(awards.map(award => award.year))].sort((a, b) => b - a)
|
||||
return years
|
||||
}
|
||||
|
||||
const getAwardsByMonth = (year: number, month: number): Award[] => {
|
||||
return awards.filter((award) => award.year === year && award.month === month)
|
||||
}
|
||||
@@ -836,6 +845,7 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
addAward,
|
||||
getAwardsByYear,
|
||||
getAwardsByMonth,
|
||||
getAvailableYears,
|
||||
getCompetitionRankings,
|
||||
getAwardsByCompetitionType,
|
||||
getAwardsByCategory,
|
||||
|
@@ -4572,14 +4572,19 @@ export class AwardService extends DatabaseServiceBase {
|
||||
const simpleResult = await db.query<Award>(simpleSql);
|
||||
console.log('✅ 簡單查詢結果:', simpleResult?.length || 0, '個獎項');
|
||||
|
||||
// 再執行 JOIN 查詢
|
||||
// 再執行 JOIN 查詢,包含團隊資訊
|
||||
const sql = `
|
||||
SELECT
|
||||
a.*,
|
||||
c.name as competition_name,
|
||||
c.type as competition_type
|
||||
c.type as competition_type,
|
||||
c.description as competition_description,
|
||||
c.start_date as competition_start_date,
|
||||
c.end_date as competition_end_date,
|
||||
t.name as team_name_from_teams
|
||||
FROM awards a
|
||||
LEFT JOIN competitions c ON a.competition_id = c.id
|
||||
LEFT JOIN teams t ON a.team_id = t.id
|
||||
ORDER BY a.created_at DESC
|
||||
`;
|
||||
console.log('📝 執行JOIN查詢:', sql);
|
||||
@@ -4605,7 +4610,21 @@ export class AwardService extends DatabaseServiceBase {
|
||||
|
||||
// 根據競賽獲取獎項
|
||||
static async getAwardsByCompetition(competitionId: string): Promise<Award[]> {
|
||||
const sql = 'SELECT * FROM awards WHERE competition_id = ? ORDER BY created_at DESC';
|
||||
const sql = `
|
||||
SELECT
|
||||
a.*,
|
||||
c.name as competition_name,
|
||||
c.type as competition_type,
|
||||
c.description as competition_description,
|
||||
c.start_date as competition_start_date,
|
||||
c.end_date as competition_end_date,
|
||||
t.name as team_name_from_teams
|
||||
FROM awards a
|
||||
LEFT JOIN competitions c ON a.competition_id = c.id
|
||||
LEFT JOIN teams t ON a.team_id = t.id
|
||||
WHERE a.competition_id = ?
|
||||
ORDER BY a.created_at DESC
|
||||
`;
|
||||
return await db.query<Award>(sql, [competitionId]);
|
||||
}
|
||||
|
||||
|
@@ -83,6 +83,8 @@ export interface Award {
|
||||
appId?: string // 個人賽和團隊賽使用
|
||||
teamId?: string // 團隊賽和提案賽使用
|
||||
appName?: string
|
||||
teamName?: string
|
||||
proposalTitle?: string
|
||||
creator: string
|
||||
awardType: "gold" | "silver" | "bronze" | "popular" | "innovation" | "technical" | "custom"
|
||||
awardName: string
|
||||
@@ -91,7 +93,7 @@ export interface Award {
|
||||
month: number
|
||||
icon: string
|
||||
customAwardTypeId?: string // 如果是自定義獎項類型
|
||||
competitionType: "individual" | "team" // 競賽類型
|
||||
competitionType: "individual" | "team" | "proposal" // 競賽類型
|
||||
rank: number // 0 for non-ranking awards, 1-3 for top 3
|
||||
category: "innovation" | "technical" | "practical" | "popular" | "teamwork" | "solution" | "creativity"
|
||||
}
|
||||
|
Reference in New Issue
Block a user