實現完整的後台得獎資訊
This commit is contained in:
@@ -134,7 +134,7 @@ export async function GET(request: NextRequest) {
|
||||
awards = awards.filter(award => award.month === parseInt(month));
|
||||
}
|
||||
|
||||
// 解析 JSON 欄位
|
||||
// 解析 JSON 欄位並統一欄位命名
|
||||
const processedAwards = awards.map(award => {
|
||||
console.log('🔍 處理獎項:', {
|
||||
id: award.id,
|
||||
@@ -145,7 +145,15 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
return {
|
||||
...award,
|
||||
application_links: award.application_links ? JSON.parse(award.application_links) : null,
|
||||
// 統一欄位命名:將下劃線命名轉換為駝峰命名
|
||||
competitionId: award.competition_id,
|
||||
competitionName: (award as any).competition_name,
|
||||
competitionType: (award as any).competition_type,
|
||||
awardName: award.award_name,
|
||||
awardType: award.award_type,
|
||||
teamName: award.team_name,
|
||||
appName: award.app_name,
|
||||
applicationLinks: award.application_links ? JSON.parse(award.application_links) : null,
|
||||
documents: award.documents ? JSON.parse(award.documents) : [],
|
||||
photos: award.photos ? JSON.parse(award.photos) : [],
|
||||
};
|
||||
|
@@ -3,7 +3,7 @@
|
||||
// =====================================================
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { AwardService } from '@/lib/services/database-service';
|
||||
import { CompetitionService } from '@/lib/services/database-service';
|
||||
|
||||
// 獲取競賽評審列表
|
||||
export async function GET(
|
||||
@@ -22,7 +22,7 @@ export async function GET(
|
||||
|
||||
console.log('🔍 獲取競賽評審:', competitionId);
|
||||
|
||||
const judges = await AwardService.getCompetitionJudges(competitionId);
|
||||
const judges = await CompetitionService.getCompetitionJudges(competitionId);
|
||||
|
||||
console.log('✅ 獲取到評審數量:', judges?.length || 0);
|
||||
|
||||
|
@@ -9,10 +9,12 @@ import { CompetitionService } from '@/lib/services/database-service';
|
||||
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
console.log('🔍 獲取競賽評審團 API 被調用,競賽ID:', id);
|
||||
|
||||
// 獲取競賽信息
|
||||
const competition = await CompetitionService.getCompetitionWithDetails(id);
|
||||
if (!competition) {
|
||||
console.log('❌ 競賽不存在:', id);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '競賽不存在',
|
||||
@@ -20,14 +22,22 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
|
||||
}, { status: 404 });
|
||||
}
|
||||
|
||||
console.log('✅ 找到競賽:', competition.name);
|
||||
|
||||
// 獲取競賽的評審團
|
||||
const judges = await CompetitionService.getCompetitionJudges(id);
|
||||
console.log('📊 查詢到評審數量:', judges.length);
|
||||
console.log('👥 評審詳細資料:', judges);
|
||||
|
||||
return NextResponse.json({
|
||||
const response = NextResponse.json({
|
||||
success: true,
|
||||
message: '競賽評審團獲取成功',
|
||||
data: {
|
||||
competition,
|
||||
competition: {
|
||||
id: competition.id,
|
||||
name: competition.name,
|
||||
type: competition.type
|
||||
},
|
||||
judges: judges.map(judge => ({
|
||||
id: judge.id,
|
||||
name: judge.name,
|
||||
@@ -43,8 +53,15 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
|
||||
}
|
||||
});
|
||||
|
||||
// 設置快取控制標頭,防止快取
|
||||
response.headers.set('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
response.headers.set('Pragma', 'no-cache');
|
||||
response.headers.set('Expires', '0');
|
||||
|
||||
return response;
|
||||
|
||||
} catch (error) {
|
||||
console.error('獲取競賽評審團失敗:', error);
|
||||
console.error('❌ 獲取競賽評審團失敗:', error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '獲取競賽評審團失敗',
|
||||
|
27
app/page.tsx
27
app/page.tsx
@@ -185,6 +185,13 @@ export default function AIShowcasePlatform() {
|
||||
)
|
||||
const [showAwardDetail, setShowAwardDetail] = useState(false)
|
||||
const [selectedAward, setSelectedAward] = useState<any>(null)
|
||||
|
||||
// 添加頁面調試資訊
|
||||
console.log('🏠 主頁面渲染:', {
|
||||
awardsCount: awards.length,
|
||||
selectedAward: selectedAward ? selectedAward.id : null,
|
||||
showAwardDetail
|
||||
});
|
||||
|
||||
// 載入應用數據
|
||||
const loadApps = async () => {
|
||||
@@ -418,6 +425,14 @@ export default function AIShowcasePlatform() {
|
||||
}
|
||||
|
||||
const handleShowAwardDetail = (award: any) => {
|
||||
console.log('🎯 handleShowAwardDetail 被調用:', {
|
||||
award: award ? {
|
||||
id: award.id,
|
||||
competitionId: award.competitionId,
|
||||
awardName: award.awardName,
|
||||
hasCompetitionId: !!award.competitionId
|
||||
} : null
|
||||
});
|
||||
setSelectedAward(award)
|
||||
setShowAwardDetail(true)
|
||||
}
|
||||
@@ -931,7 +946,17 @@ export default function AIShowcasePlatform() {
|
||||
|
||||
{/* Award Detail Dialog */}
|
||||
{selectedAward && (
|
||||
<AwardDetailDialog open={showAwardDetail} onOpenChange={setShowAwardDetail} award={selectedAward} />
|
||||
<>
|
||||
{console.log('🎯 渲染 AwardDetailDialog:', {
|
||||
selectedAward: selectedAward ? {
|
||||
id: selectedAward.id,
|
||||
competitionId: selectedAward.competitionId,
|
||||
awardName: selectedAward.awardName
|
||||
} : null,
|
||||
showAwardDetail
|
||||
})}
|
||||
<AwardDetailDialog open={showAwardDetail} onOpenChange={setShowAwardDetail} award={selectedAward} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
|
Reference in New Issue
Block a user